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

Adds final answer tool for all agents #31703

Merged
merged 5 commits into from
Jul 3, 2024
Merged

Conversation

aymeric-roucher
Copy link
Contributor

@aymeric-roucher aymeric-roucher commented Jun 28, 2024

What does this PR do?

Fixes a few errors reported by @MoritzLaurer .

  • Fixes typo in doc
  • Explains agent.logs in doc

Important change:
The CodeAgent would not always return the right output, because it would always only return the last element, regardless of wether the important element to return was the last one or not.

For instance, when asked to generate an image, the generated code could look like:

image = image_generator("Draw me a lamb")
print("Image correctly generated!")

Which returned string "Image correctly generated!" instead of the expected image.

To fix this, I just make all agents use the final_answer tool: thus the agent can return one specific outcome of its run by passing it to final_answer.
This also simplifies the code!

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Thanks @aymeric-roucher

@LysandreJik LysandreJik merged commit 0fd885b into main Jul 3, 2024
22 checks passed
@LysandreJik LysandreJik deleted the agents-fix-final-answer branch July 3, 2024 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants