Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.9k
feat: allow thinking_config in generate_content_config (#4108)#4117
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
Closed
Akshat8510
wants to merge
24
commits into
google:main
from
Akshat8510:feat/allow-thinking-config-4108
Uh oh!
There was an error while loading. Please reload this page.
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
0883d5f
feat: allow thinking_config in generate_content_config (#4108)
Akshat8510 2d485cb
fix: address review comments regarding imports and logging
Akshat8510 25a9186
style: improve readability of precedence check in LlmAgent
Akshat8510 c5aa50e
docs: update LlmAgent docstring and use explicit None checks
Akshat8510 abce588
docs: update doc
Akshat8510 3a492da
docs: update doc
Akshat8510 d8dd6c9
test: update unit tests to allow thinking_config and verify precedenc…
Akshat8510 bec52bb
test: remove obsolete failing test and add new verification tests
Akshat8510 a631439
test: cleanup duplicate test definitions and fix imports
Akshat8510 412447a
refactor: simplify precedence check and remove duplicate tests
Akshat8510 8438ed6
test: cleanup unit tests and fix logging test placement
Akshat8510 4b23903
test:clean up
Akshat8510 072f8ad
style: move test imports to top level per PEP 8
Akshat8510 74600d8
refactor: simplify apply_thinking_config and cleanup test imports
Akshat8510 f137045
fix: address maintainer feedback on logic bug and redundant comments
Akshat8510 56526d9
Merge branch 'main' into feat/allow-thinking-config-4108
Akshat8510 978d7d1
fix: resolve logic bug in planner and refactor for consistency
Akshat8510 01462c4
Merge branch 'main' into feat/allow-thinking-config-4108
wuliang229 fdaed09
Merge branch 'main' into feat/allow-thinking-config-4108
Akshat8510 cd2c510
style: automatic cleanup of imports and formatting via isort and pyink
Akshat8510 7d3c06f
style: final manual fix for import grouping and hierarchical logging
Akshat8510 39b55ec
fix: address bot suggestions for stacklevel and redundant config init…
Akshat8510 c98e51f
Merge branch 'main' into feat/allow-thinking-config-4108
Akshat8510 98dfe12
Merge branch 'main' into feat/allow-thinking-config-4108
Akshat8510 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -285,7 +285,7 @@ class LlmAgent(BaseAgent): | ||
| """The additional content generation configurations. | ||
| NOTE: not all fields are usable, e.g. tools must be configured via `tools`, | ||
| thinking_config must be configured via `planner` in LlmAgent. | ||
| thinking_config can be configured here or via the `planner`. If both are set, the planner's configuration takes precedence. | ||
| For example: use this config to adjust model temperature, configure safety | ||
| settings, etc. | ||
| @@ -849,8 +849,6 @@ def validate_generate_content_config( | ||
| ) -> types.GenerateContentConfig: | ||
| if not generate_content_config: | ||
| return types.GenerateContentConfig() | ||
| if generate_content_config.thinking_config: | ||
| raise ValueError('Thinking config should be set via LlmAgent.planner.') | ||
| if generate_content_config.tools: | ||
| raise ValueError('All tools must be set via LlmAgent.tools.') | ||
| if generate_content_config.system_instruction: | ||
| @@ -863,6 +861,23 @@ def validate_generate_content_config( | ||
| ) | ||
| return generate_content_config | ||
| @override | ||
| def model_post_init(self, __context: Any) -> None: | ||
| """Provides a warning if multiple thinking configurations are found.""" | ||
| super().model_post_init(__context) | ||
| # Note: Using getattr to check both locations for thinking_config | ||
| if getattr( | ||
| self.generate_content_config, 'thinking_config', None | ||
| ) and getattr(self.planner, 'thinking_config', None): | ||
| warnings.warn( | ||
| 'Both `thinking_config` in `generate_content_config` and a ' | ||
| 'planner with `thinking_config` are provided. The ' | ||
| "planner's configuration will take precedence.", | ||
| UserWarning, | ||
| stacklevel=5, | ||
| ) | ||
Akshat8510 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| @classmethod | ||
| @experimental | ||
| def _resolve_tools( | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.