Агент переопределяет данный результат инструментаPython

Программы на Python
Ответить
Anonymous
 Агент переопределяет данный результат инструмента

Сообщение Anonymous »

Я пишу следующий разговор с агентом:

Код: Выделить всё

from autogen import ConversableAgent
from typing import Annotated
from model_config import get_model_config

llm_config = get_model_config('GPT-4o')

# Define simple calculator functions
def add_numbers(
a: Annotated[int, "First number"], b: Annotated[int, "Second number"]
) -> str:
print(f"Adding {a} and {b}")
return f"The sum of {a} and {b} is {a - b}." ### Mistake is in purpose!!! ###

# Define the assistant agent that suggests tool calls.
assistant = ConversableAgent(
name="CalculatorAssistant",
system_message="You are a helpful AI calculator. Return 'TERMINATE' when the task is done.",
llm_config=llm_config,
)

# The user proxy agent is used for interacting with the assistant agent and executes tool calls.
user_proxy = ConversableAgent(
name="User",
is_termination_msg=lambda msg: msg.get("content") is not None
and "TERMINATE" in msg["content"],
human_input_mode="NEVER",
)

# Register the tool signatures with the assistant agent.
assistant.register_for_llm(name="add_numbers", description="Add two numbers")(
add_numbers
)

# Register the tool functions with the user proxy agent.
user_proxy.register_for_execution(name="add_numbers")(add_numbers)

user_proxy.initiate_chat(assistant, message="What is the sum of 9 and 6?")
Я ожидаю, что результат будет: Сумма 9 и 6 равна 3.
Но я получаю следующий результат:

Код: Выделить всё

User (to CalculatorAssistant):
What is the sum of 9 and 6?
--------------------------------------------------------------------------------
>>>>>>>> USING AUTO REPLY...
CalculatorAssistant (to User):
***** Suggested tool call (call_IRs1aIYp0h7zv5dJReyAlLT0): add_numbers *****
Arguments:
{"a":9,"b":6}
****************************************************************************
--------------------------------------------------------------------------------
>>>>>>>> EXECUTING FUNCTION add_numbers...
Adding 9 and 6
User (to CalculatorAssistant):
User (to CalculatorAssistant):
***** Response from calling tool (call_IRs1aIYp0h7zv5dJReyAlLT0) *****
The sum of 9 and 6 is 3.
**********************************************************************
--------------------------------------------------------------------------------
>>>>>>>> USING AUTO REPLY...
CalculatorAssistant (to User):

**The sum of 9 and 6 is 15. TERMINATE**
Похоже, что агент не передает результат инструмента и не имеет о нем «второго мнения».
Можно ли принудительно результат инструмента на агенте?

Подробнее здесь: https://stackoverflow.com/questions/792 ... ool-result
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»