Skip to content

Conversation

@HwVanICI
Copy link
Collaborator

Description

This PR fixes bugs of the Camel example training code. In the run_agent() function of CamelMathAgent class is updated to pass the max_tokens and step_timeout parameter properly as follows.

  • Remove the "token_limit" parameter which is not accepted by CamelAgent.
  • Create a new "model_config_dict" dictionary including "max_tokens" elememnt, and pass it to the model parameter when creating ChatAgent instance.
  • Pass the "step_timeout" parameter when creating a ChatAgent instance. The "step_timeout" parameter is set using the "request_timeout" rollout configuration from yaml file to make it consistent with rollout timeout.
  • Added additional rollout configuration in the config.yaml file to set "request_timeout" which can be used to set the "step_timeout".

Related Issue

Fixes #(issue)

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not
    work as expected)
  • Documentation update
  • Code refactoring (no functional changes)
  • Performance improvement
  • Test coverage improvement

Checklist

  • I have read the Contributing Guide
  • I have run formatting tools (pre-commit or manual)
  • I have run relevant unit tests and they pass
  • I have added tests for new functionality
  • I have updated documentation if needed
  • My branch is up to date with main
  • This PR introduces breaking changes (if yes, fill out details below)
  • If this PR changes documentation, I have built and previewed it locally with
    jb build docs
  • No critical issues raised by AI reviewers (/gemini review)

Need help? Check the Contributing Guide or ask in
GitHub Discussions!

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @HwVanICI, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses several bugs within the Camel example's training code, specifically focusing on how agent configuration parameters are managed. The changes ensure that critical arguments like token limits and step timeouts are correctly passed to the underlying agent and model components, aligning them with the expected API and system-wide rollout configurations. This improves the robustness and consistency of the Camel example's agent behavior.

Highlights

  • Agent Argument Handling: The run_agent function in CamelMathAgent has been updated to correctly pass max_tokens and step_timeout parameters to ChatAgent and AReaLOpenAICompatibleModel instances.
  • Removed token_limit: The token_limit parameter, which was not accepted by CamelAgent, has been removed from the ChatAgent instantiation.
  • Configuration for max_tokens: A model_config_dict is now used to pass max_tokens to the AReaLOpenAICompatibleModel, ensuring proper token limit configuration.
  • Consistent step_timeout: The step_timeout parameter for ChatAgent is now set using a new request_timeout configuration from the config.yaml file, ensuring consistency with rollout timeouts.
  • New Rollout Configuration: An additional request_timeout configuration has been added to examples/camel/config.yaml to support the consistent step_timeout setting.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses issues with incorrect and missing arguments in the Camel example. The changes correctly pass step_timeout to the ChatAgent and add the request_timeout configuration. However, there is an issue with how the token limit is specified. The max_tokens parameter is used, but max_total_tokens should be used instead to correctly limit the total length of the generated trajectory. I have provided a specific comment with a suggested fix.

self.async_reward_fn = AsyncRewardWrapper(gsm8k_reward_fn)

async def run_agent(self, data, client: ArealOpenAI):
model_config_dict = {"max_tokens": self.max_total_tokens}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The parameter max_tokens is being used here, but based on the variable name self.max_total_tokens and the implementation in areal/experimental/openai/client.py, it seems max_total_tokens should be used instead.

Using max_tokens sets the maximum number of new tokens to be generated, ignoring the length of the prompt. Using max_total_tokens will correctly limit the total length of the prompt and the completion to self.max_total_tokens by calculating max_new_tokens as max_total_tokens - prompt_length.

This could lead to generating sequences longer than intended, potentially causing issues.

Suggested change
model_config_dict = {"max_tokens": self.max_total_tokens}
model_config_dict = {"max_total_tokens": self.max_total_tokens}

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

Successfully merging this pull request may close these issues.

2 participants