-
Notifications
You must be signed in to change notification settings - Fork 117
Adapt to the Ollama reasoning platform and use the "reasoning" JSON k… #268
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: main
Are you sure you want to change the base?
Conversation
…ey to return the reasoning content
Summary of ChangesHello @zhujunling-nj, 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 enhances the system's compatibility with the Ollama reasoning platform by modifying how reasoning content is parsed from model outputs. It introduces a more robust mechanism to retrieve reasoning information, allowing the system to correctly process responses that might use an alternative key for this data. This ensures smoother integration and improved functionality when interacting with Ollama. Highlights
🧠 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 AssistThe 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
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 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
|
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.
Code Review
This pull request adapts the code to support the reasoning key from the Ollama reasoning platform, in addition to the existing reasoning_content key. The change is straightforward and correct. My review includes two points of feedback: one to improve the robustness of the code against potential type errors, and another to update the documentation to reflect this change, ensuring better maintainability.
|
|
||
| content = delta.get("content") or "" | ||
| reasoning_content = delta.get("reasoning_content") | ||
| reasoning_content = delta.get("reasoning_content") or delta.get("reasoning") |
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.
This change, combined with the existing logic, could lead to a TypeError if delta.get('reasoning_content') or delta.get('reasoning') returns a truthy non-string value (e.g., a dictionary or a list). The string concatenation on line 542 would fail. To make the code more robust and prevent runtime errors, it's best to explicitly convert the result to a string. Using str() and providing an empty string as a final fallback will handle None and other falsy values correctly while safely converting any other types.
| reasoning_content = delta.get("reasoning_content") or delta.get("reasoning") | |
| reasoning_content = str(delta.get("reasoning_content") or delta.get("reasoning") or "") |
|
Please also add some tests to ensure your code works, of course, this enforces others will not break your fixes. |
|
I mean you can add some unittests to the repo. |
|
Added 3 test cases:
Test execution results:
|


…ey to return the reasoning content
Pull Request Checklist
Thank you for your contribution! Before submitting your PR, please make sure you have completed the following checks:
Compatibility Check
README.mdREADME.mdREADME.mdREADME.mdAvailable Checks