@@ -164,7 +164,7 @@ class ChatGPTBot(Bot, OpenAIImage): | |||
content=response.choices[0]["message"]["content"] | |||
description = '' | |||
userSelectOptions = [] | |||
if isinstance(content, list): | |||
if isinstance(content, list) and any(item.get("type") == "interactive" for item in content): | |||
# print(content) | |||
for item in content: | |||
if item["type"] == "interactive" and item["interactive"]["type"] == "userSelect": | |||
@@ -181,6 +181,27 @@ class ChatGPTBot(Bot, OpenAIImage): | |||
"completion_tokens": response["usage"]["completion_tokens"], | |||
"content": description + '------------------------------\n'+values_string, | |||
} | |||
elif isinstance(content, list) and any(item.get("type") == "text" for item in content): | |||
memory.USER_INTERACTIVE_CACHE[session.session_id] = { | |||
"interactive":False | |||
} | |||
text='' | |||
for item in content: | |||
if item["type"] == "text": | |||
text=item["text"]["content"] | |||
if text=='': | |||
args.pop('chatId', None) # The second argument (None) is the default return value if the key doesn't exist | |||
args.pop('detail', None) | |||
response = openai.ChatCompletion.create(api_key=api_key, messages=messages_to_send, **args) | |||
text=response.choices[0]["message"]["content"] | |||
return { | |||
"total_tokens": response["usage"]["total_tokens"], | |||
"completion_tokens": response["usage"]["completion_tokens"], | |||
"content": text, | |||
} | |||
else: | |||
memory.USER_INTERACTIVE_CACHE[session.session_id] = { | |||
"interactive":False | |||
@@ -503,7 +503,7 @@ def wx_messages_process_callback(user_nickname,message): | |||
kafka_helper.kafka_client.produce_message(message) | |||
logger.info("发送对话 %s",message) | |||
# 等待随机时间 | |||
time.sleep(random.uniform(30, 60)) | |||
time.sleep(random.uniform(5, 15)) | |||
# 处理图片 | |||
elif wx_content.get("type",None) == 'image_url': | |||
print('发送图片') | |||
@@ -536,7 +536,7 @@ def wx_messages_process_callback(user_nickname,message): | |||
kafka_helper.kafka_client.produce_message(message) | |||
logger.info("发送对话 %s",message) | |||
# 等待随机时间 | |||
time.sleep(random.uniform(30, 60)) | |||
time.sleep(random.uniform(5, 15)) | |||
#处理文件 | |||
elif wx_content.get("type",None) == 'file': | |||
print('处理文件') | |||
@@ -564,7 +564,7 @@ def wx_messages_process_callback(user_nickname,message): | |||
kafka_helper.kafka_client.produce_message(message) | |||
logger.info("发送对话 %s",message) | |||
# 等待随机时间 | |||
time.sleep(random.uniform(30, 60)) | |||
time.sleep(random.uniform(5, 15)) | |||
elif ext in ['.mp4']: | |||
@@ -580,7 +580,7 @@ def wx_messages_process_callback(user_nickname,message): | |||
kafka_helper.kafka_client.produce_message(message) | |||
logger.info("发送对话 %s",message) | |||
# 等待随机时间 | |||
time.sleep(random.uniform(30, 60)) | |||
time.sleep(random.uniform(5, 15)) | |||
else: | |||
logger.warning(f'暂不支持 {ext} 文件的处理') | |||
@@ -6,7 +6,7 @@ | |||
"claude_api_key": "YOUR API KEY", | |||
"proxy": "", | |||
"hot_reload": true, | |||
"debug": true, | |||
"debug": false, | |||
"single_chat_reply_prefix": "", | |||
"group_chat_prefix": [ | |||
"zhushou" | |||
@@ -19,8 +19,9 @@ | |||
"group_welcome_msg": "", | |||
"trigger_by_self": true, | |||
"voice_to_text":"ali", | |||
"text_to_voice":"ali", | |||
"speech_recognition": true, | |||
"group_speech_recognition": true, | |||
"group_speech_recognition": false, | |||
"voice_reply_voice": true, | |||
"conversation_max_tokens": 2500, | |||
"expires_in_seconds": 300, | |||
@@ -36,7 +37,7 @@ | |||
"redis_password":"telpo#1234", | |||
"redis_db":3, | |||
"kafka_bootstrap_servers":"192.168.2.121:9092", | |||
"kafka_bootstrap_servers":"172.19.42.53:9092", | |||
"aiops_api":"https://id.ssjlai.com/aiopsadmin" | |||
} |
@@ -12,7 +12,6 @@ | |||
"zhushou" | |||
], | |||
"group_name_white_list": [ | |||
"AI好蕴测试群3" | |||
], | |||
"image_create_prefix": [ | |||