mirror of https://github.com/microsoft/autogen.git
remove name from tool response (#1263)
* remove name from tool response * fix tool response tests * fix output string
This commit is contained in:
parent
bde2fc9398
commit
d1c1548888
|
@ -484,7 +484,12 @@ class ConversableAgent(Agent):
|
|||
return # If role is tool, then content is just a concatenation of all tool_responses
|
||||
|
||||
if message.get("role") in ["function", "tool"]:
|
||||
func_print = f"***** Response from calling {message['role']} \"{message['name']}\" *****"
|
||||
if message["role"] == "function":
|
||||
id_key = "name"
|
||||
else:
|
||||
id_key = "tool_call_id"
|
||||
|
||||
func_print = f"***** Response from calling {message['role']} \"{message[id_key]}\" *****"
|
||||
print(colored(func_print, "green"), flush=True)
|
||||
print(message["content"], flush=True)
|
||||
print(colored("*" * len(func_print), "green"), flush=True)
|
||||
|
@ -884,10 +889,9 @@ class ConversableAgent(Agent):
|
|||
return False, None
|
||||
|
||||
def _str_for_tool_response(self, tool_response):
|
||||
func_name = tool_response.get("name", "")
|
||||
func_id = tool_response.get("tool_call_id", "")
|
||||
response = tool_response.get("content", "")
|
||||
return f"Tool call: {func_name}\nId: {func_id}\n{response}"
|
||||
return f"Tool Call Id: {func_id}\n{response}"
|
||||
|
||||
def generate_tool_calls_reply(
|
||||
self,
|
||||
|
@ -913,7 +917,6 @@ class ConversableAgent(Agent):
|
|||
{
|
||||
"tool_call_id": id,
|
||||
"role": "tool",
|
||||
"name": func_return.get("name", ""),
|
||||
"content": func_return.get("content", ""),
|
||||
}
|
||||
)
|
||||
|
@ -932,7 +935,6 @@ class ConversableAgent(Agent):
|
|||
return {
|
||||
"tool_call_id": id,
|
||||
"role": "tool",
|
||||
"name": func_return.get("name", ""),
|
||||
"content": func_return.get("content", ""),
|
||||
}
|
||||
|
||||
|
|
|
@ -245,32 +245,27 @@ def test_multi_tool_call():
|
|||
{
|
||||
"role": "tool",
|
||||
"tool_responses": [
|
||||
{"tool_call_id": "tool_1", "role": "tool", "name": "echo", "content": "hello world"},
|
||||
{"tool_call_id": "tool_1", "role": "tool", "content": "hello world"},
|
||||
{
|
||||
"tool_call_id": "tool_2",
|
||||
"role": "tool",
|
||||
"name": "echo",
|
||||
"content": "goodbye and thanks for all the fish",
|
||||
},
|
||||
{
|
||||
"tool_call_id": "tool_3",
|
||||
"role": "tool",
|
||||
"name": "multi_tool_call_echo",
|
||||
"content": "Error: Function multi_tool_call_echo not found.",
|
||||
},
|
||||
],
|
||||
"content": inspect.cleandoc(
|
||||
"""
|
||||
Tool call: echo
|
||||
Id: tool_1
|
||||
Tool Call Id: tool_1
|
||||
hello world
|
||||
|
||||
Tool call: echo
|
||||
Id: tool_2
|
||||
Tool Call Id: tool_2
|
||||
goodbye and thanks for all the fish
|
||||
|
||||
Tool call: multi_tool_call_echo
|
||||
Id: tool_3
|
||||
Tool Call Id: tool_3
|
||||
Error: Function multi_tool_call_echo not found.
|
||||
"""
|
||||
),
|
||||
|
@ -348,32 +343,27 @@ async def test_async_multi_tool_call():
|
|||
{
|
||||
"role": "tool",
|
||||
"tool_responses": [
|
||||
{"tool_call_id": "tool_1", "role": "tool", "name": "a_echo", "content": "hello world"},
|
||||
{"tool_call_id": "tool_1", "role": "tool", "content": "hello world"},
|
||||
{
|
||||
"tool_call_id": "tool_2",
|
||||
"role": "tool",
|
||||
"name": "echo",
|
||||
"content": "goodbye and thanks for all the fish",
|
||||
},
|
||||
{
|
||||
"tool_call_id": "tool_3",
|
||||
"role": "tool",
|
||||
"name": "multi_tool_call_echo",
|
||||
"content": "Error: Function multi_tool_call_echo not found.",
|
||||
},
|
||||
],
|
||||
"content": inspect.cleandoc(
|
||||
"""
|
||||
Tool call: a_echo
|
||||
Id: tool_1
|
||||
Tool Call Id: tool_1
|
||||
hello world
|
||||
|
||||
Tool call: echo
|
||||
Id: tool_2
|
||||
Tool Call Id: tool_2
|
||||
goodbye and thanks for all the fish
|
||||
|
||||
Tool call: multi_tool_call_echo
|
||||
Id: tool_3
|
||||
Tool Call Id: tool_3
|
||||
Error: Function multi_tool_call_echo not found.
|
||||
"""
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue