基于function的agent实现连续问答聊天功能详解
在agent调用function后,应该在messages中添加tool信息,以及function返回的信息,这样才能构成完整的聊天记录。
messages 中应该append openai接口返回的message,也就是 tool_calls 信息, 然后再加上 “tool”返回的message。
# messages
[{
'role': 'system', 'content': 'You are a helpful assistant.'},
{
'role': 'user', 'content': '海淀区天气怎么样'},
#接口返回message
{
'content': '', 'role': 'assistant', 'function_call': None, 'tool_calls': [{
'id': 'call_d55670dfg34567a4', 'function':
作者:Qiming_v