doc:修复第七章 tiny-agent
This commit is contained in:
@@ -51,14 +51,15 @@ class Agent:
|
||||
stream=False,
|
||||
)
|
||||
if response.choices[0].message.tool_calls:
|
||||
self.messages.append({"role": "assistant", "content": response.choices[0].message.content})
|
||||
# 处理工具调用
|
||||
tool_list = []
|
||||
for tool_call in response.choices[0].message.tool_calls:
|
||||
# 处理工具调用并将结果添加到消息列表中
|
||||
self.messages.append(self.handle_tool_call(tool_call))
|
||||
tool_list.append(tool_call.function.name)
|
||||
tool_list.append([tool_call.function.name, tool_call.function.arguments])
|
||||
if self.verbose:
|
||||
print("调用工具:", tool_list)
|
||||
print("调用工具:", response.choices[0].message.content, tool_list)
|
||||
# 再次获取模型的完成响应,这次包含工具调用的结果
|
||||
response = self.client.chat.completions.create(
|
||||
model=self.model,
|
||||
|
||||
Reference in New Issue
Block a user