|
|
@@ -356,16 +356,26 @@ class FunctionKnowledge:
|
|
|
cached_tool_call = self.cache.get(combined_question, 'function_knowledge', 'tool_call.json')
|
|
|
if cached_tool_call:
|
|
|
logger.info(f"✓ 使用缓存的工具调用结果")
|
|
|
- tool_result = cached_tool_call.get('result', {})
|
|
|
+ response = cached_tool_call.get('response', {})
|
|
|
+ # tool_result = self.organize_tool_result(response)
|
|
|
+ # # 保存工具调用信息(包含工具名、入参、结果)
|
|
|
+ # tool_call_data = {
|
|
|
+ # "tool_name": tool_id,
|
|
|
+ # "arguments": arguments,
|
|
|
+ # "result": tool_result,
|
|
|
+ # "response": response
|
|
|
+ # }
|
|
|
+ # self.cache.set(combined_question, 'function_knowledge', 'tool_call.json', tool_call_data)
|
|
|
else:
|
|
|
logger.info(f" → 调用工具,参数: {arguments}")
|
|
|
- tool_result = call_tool(tool_id, arguments)
|
|
|
- tool_result = self.organize_tool_result(tool_result)
|
|
|
+ rs = call_tool(tool_id, arguments)
|
|
|
+ tool_result = self.organize_tool_result(rs)
|
|
|
# 保存工具调用信息(包含工具名、入参、结果)
|
|
|
tool_call_data = {
|
|
|
"tool_name": tool_id,
|
|
|
"arguments": arguments,
|
|
|
- "result": tool_result
|
|
|
+ "result": tool_result,
|
|
|
+ "response": rs
|
|
|
}
|
|
|
self.cache.set(combined_question, 'function_knowledge', 'tool_call.json', tool_call_data)
|
|
|
else:
|