-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: Add tool call output cache function in ChatAgent #3296
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
base: master
Are you sure you want to change the base?
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
hesamsheikh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR @MuggleJinx
I added a few comments.
| self._tool_output_cache_threshold = ( | ||
| tool_call_cache_threshold if tool_call_cache_threshold else 2000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this overrides the tool_call_cache_threshold=0 for caching disabling.
| self, | ||
| input_message: Union[BaseMessage, str], | ||
| response_format: Optional[Type[BaseModel]] = None, | ||
| tool_call_history_cache: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we actually rename this to tool_call_cache_history to make it consistent with tool_call_cache_threshold and tool_call_cache_dir?
| def _ensure_tool_cache_lookup_tool(self) -> None: | ||
| if not self._tool_output_cache_enabled: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add docstrings to these new methods.
| # Multiple cache_ids - return JSON dictionary | ||
| import json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json imported in the script already
| return self._tool_output_cache_manager.load(cache_id) | ||
| except FileNotFoundError: | ||
| return ( | ||
| f"Cache entry '{cache_id}' was not found. " | ||
| "Verify the identifier and try again." | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not return the single cache_id as json too to make the types consistent?
Description
Address issue #3376. The previous implementation of the tool cache is improved by adding an argument to control in the
step()function. So the default behavior will not change if it the tool cache argument is set to befalseChecklist
Go over all the following points, and put an
xin all the boxes that apply.Fixes #issue-numberin the PR description (required)pyproject.tomlanduv lockIf you are unsure about any of these, don't hesitate to ask. We are here to help!