Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output format? {"answer": "insert your final answer here"} or "insert your final answer here" ? #304

Open
joaopauloschuler opened this issue Jan 22, 2025 · 0 comments

Comments

@joaopauloschuler
Copy link
Contributor

joaopauloschuler commented Jan 22, 2025

Hello and congrats for your job.

The output format seems to vary. These are examples from the constant TOOL_CALLING_SYSTEM_PROMPT :

To provide the final answer to the task, use an action blob with "tool_name": "final_answer" tool. It is the only way to complete the task, else you will be stuck on a loop. So your final output should look like this:
Action:
{
  "tool_name": "final_answer",
  "tool_arguments": {"answer": "insert your final answer here"}
}

...

Task: "What is the result of the following operation: 5 + 3 + 1294.678?"

Action:
{
    "tool_name": "python_interpreter",
    "tool_arguments": {"code": "5 + 3 + 1294.678"}
}
Observation: 1302.678

Action:
{
  "tool_name": "final_answer",
  "tool_arguments": "1302.678"
}

In the first example, the result is {"answer": "insert your final answer here"}. In the last, it is "1302.678". Just to share food for thought, I escaped the problem with:

def get_result_str(result_str):
  try:
    result_obj = json.loads(result_str)
    result = result_obj['answer']
  except ValueError as e:
    result = result_str
  return result

And then, get_result_str can be used with:

get_result_str(agent.run(task_str, reset=True, single_step=False))

In the case that you would like me to to try to code something, let me know.

Live long and prosper.

@joaopauloschuler joaopauloschuler changed the title Output format? Output format? {"answer": "insert your final answer here"} or "insert your final answer here" ? Jan 22, 2025
@joaopauloschuler joaopauloschuler changed the title Output format? {"answer": "insert your final answer here"} or "insert your final answer here" ? Output format? {"answer": "insert your final answer here"} or "insert your final answer here" ? Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant