mirror of
https://github.com/microsoft/autogen.git
synced 2026-04-20 03:02:16 -04:00
@@ -855,24 +855,23 @@ class ConversableAgent(Agent):
|
||||
if messages is None:
|
||||
messages = self._oai_messages[sender]
|
||||
message = messages[-1]
|
||||
if "tool_calls" in message and message["tool_calls"]:
|
||||
tool_calls = message["tool_calls"]
|
||||
tool_returns = []
|
||||
for tool_call in tool_calls:
|
||||
id = tool_call["id"]
|
||||
function_call = tool_call.get("function", {})
|
||||
func = self._function_map.get(function_call.get("name", None), None)
|
||||
if asyncio.coroutines.iscoroutinefunction(func):
|
||||
continue
|
||||
_, func_return = self.execute_function(function_call)
|
||||
tool_returns.append(
|
||||
{
|
||||
"tool_call_id": id,
|
||||
"role": "tool",
|
||||
"name": func_return.get("name", ""),
|
||||
"content": func_return.get("content", ""),
|
||||
}
|
||||
)
|
||||
tool_returns = []
|
||||
for tool_call in message.get("tool_calls", []):
|
||||
id = tool_call["id"]
|
||||
function_call = tool_call.get("function", {})
|
||||
func = self._function_map.get(function_call.get("name", None), None)
|
||||
if asyncio.coroutines.iscoroutinefunction(func):
|
||||
continue
|
||||
_, func_return = self.execute_function(function_call)
|
||||
tool_returns.append(
|
||||
{
|
||||
"tool_call_id": id,
|
||||
"role": "tool",
|
||||
"name": func_return.get("name", ""),
|
||||
"content": func_return.get("content", ""),
|
||||
}
|
||||
)
|
||||
if len(tool_returns) > 0:
|
||||
return True, {
|
||||
"role": "tool",
|
||||
"tool_responses": tool_returns,
|
||||
|
||||
Reference in New Issue
Block a user