feat(新功能):
fix(修复bug): chat robot “parameters”修复 docs(文档变更): refactor(重构): test(增加测试):
This commit is contained in:
@@ -200,6 +200,18 @@ def get_response(messages):
|
||||
return response
|
||||
|
||||
|
||||
def get_assistant_response(messages):
|
||||
response = Generation.call(
|
||||
model='qwen-max',
|
||||
api_key=QWEN_API_KEY,
|
||||
messages=messages,
|
||||
# seed=random.randint(1, 10000), # 设置随机数种子seed,如果没有设置,则随机数种子默认为1234
|
||||
result_format='message', # 将输出设置为message形式
|
||||
enable_search='false'
|
||||
)
|
||||
return response
|
||||
|
||||
|
||||
def call_with_messages(message, gender):
|
||||
global tool_info
|
||||
user_input = message
|
||||
@@ -271,7 +283,7 @@ def call_with_messages(message, gender):
|
||||
elif assistant_output.tool_calls[0]['function']['name'] == 'get_image_from_vector_db':
|
||||
content = json.loads(assistant_output.tool_calls[0]['function']['arguments'])
|
||||
tool_info = {"name": "get_image_from_vector_db", "role": "tool",
|
||||
'content': get_image_from_vector_db(gender, content['parameters']['content'])}
|
||||
'content': get_image_from_vector_db(gender, content['parameters']['content'] if "parameters" in content.keys() else content['content'])}
|
||||
flag = False
|
||||
result_content = tool_info['content']
|
||||
response_type = "image"
|
||||
@@ -329,7 +341,7 @@ def get_language(message: str) -> str:
|
||||
}
|
||||
]
|
||||
|
||||
first_response = get_response(messages)
|
||||
first_response = get_assistant_response(messages)
|
||||
assistant_output = first_response.output.choices[0].message.content
|
||||
logging.info(f"大模型输出信息:{first_response}\n判断用户输入的语言为:{assistant_output}")
|
||||
# print(f"大模型输出信息:{first_response}\n判断用户输入的语言为:{assistant_output}")
|
||||
|
||||
Reference in New Issue
Block a user