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