-
-
Notifications
You must be signed in to change notification settings - Fork 334
Add Gemini reasoning support #2306
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
Open
Davidyz
wants to merge
12
commits into
olimorris:main
Choose a base branch
from
Davidyz:feat/gemini_reasoning
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
46c11a4
feat(gemini): add Gemini reasoning support
Davidyz 41ba540
fix(gemini): rename thinkingBudget to thinking_budget
Davidyz c632f23
fix(gemini): remove thought tags from inline output
Davidyz 34d2aee
docs(gemini): add gemini adapter setup guide
Davidyz 4caf5f8
refactor(gemini): improve gemini reasoning and thinking tag handling
Davidyz 7cb0bef
tests(gemini): add test cases for gemini reasoning
Davidyz 4acfc8a
fix: set default thinking_budget to `nil`
Davidyz b62b9be
Merge branch 'main' into feat/gemini_reasoning
Davidyz 2707411
refactor: use `parse_message_meta` for handling reasoning summary
Davidyz 3614e88
fix: handle trivial reasoning structure in `Chat`
Davidyz 8acd7f9
Merge branch 'main' into feat/gemini_reasoning
Davidyz af31023
Merge branch 'main' into feat/gemini_reasoning
Davidyz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
25 changes: 25 additions & 0 deletions
25
tests/adapters/http/stubs/gemini_reasoning_no_streaming.txt
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 |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "choices": [ | ||
| { | ||
| "finish_reason": "stop", | ||
| "index": 0, | ||
| "message": { | ||
| "content": "<thought>This is a dummy thinking summary</thought>Elegant, dynamic.\\n\\nNext question?\\n", | ||
| "role": "assistant", | ||
| "extra_content": { | ||
| "google": { | ||
| "thought": true | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| "created": 1743460357, | ||
| "model": "gemini-2.5-flash", | ||
| "object": "chat.completion", | ||
| "usage": { | ||
| "completion_tokens": 9, | ||
| "prompt_tokens": 419, | ||
| "total_tokens": 428 | ||
| } | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| data: {"choices":[{"delta":{"content":"<thought>This is a dummy reasoning segment","role":"assistant", "extra_content":{"google":{"thought":true}}},"index":0}],"created":1743460108,"model":"gemini-2.5-flash","object":"chat.completion.chunk","usage":{"completion_tokens":0,"prompt_tokens":425,"total_tokens":425}} | ||
| data: {"choices":[{"delta":{"content":"</thought>Elegant","role":"assistant"},"index":0}],"created":1743460109,"model":"gemini-2.5-flash","object":"chat.completion.chunk","usage":{"completion_tokens":0,"prompt_tokens":425,"total_tokens":425}} | ||
| Tokens: 425 | ||
| data: {"choices":[{"delta":{"content":", dynamic.\n\nNext question?\n","role":"assistant"},"finish_reason":"stop","index":0}],"created":1743460109,"model":"gemini-2.5-flash","object":"chat.completion.chunk","usage":{"completion_tokens":9,"prompt_tokens":419,"total_tokens":428}} | ||
| Tokens: 428 | ||
| data: [DONE] |
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.
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.
Since different models have different thinking budget, we might need to change
validateso that it also acceptsselfin the parameters (something likevalidate(self, n)instead of the currentvalidate(n). @olimorris would that be alright?