Hide Gemma models reasoning tags#7948
Conversation
Code Review — first reviewSummaryFixes an issue where Gemma models' What works well
Issues
Recommendation: improve neededThe fix is correct and addresses a real user-facing bug, but the duplication and hardcoded detection should be cleaned up before merging. Tests should be added to cover the new |
0d069b7 to
0d585d5
Compare
Please check new 2 commits with no hardcode and tests added |
Code Review — follow-up reviewNew commits since last review
The PR was fully rewritten as three clean atomic commits. Analysis below. Previous feedback addressed
New observations
Recommendation: can merge |
|
Please rebase |
…h `<think>` and `<thought>` tags. This ensures that reasoning blocks from models using the `<thought>` format are correctly identified and displayed in the user interface.
Introduces a `REASONING_TAG_MAP` and a `getReasoningTagName` helper function to centralize the logic for determining reasoning tags based on model IDs. This replaces repeated inline ternary checks across the `ModelFactory` class, improving maintainability and making it easier to add support for new models with specific reasoning tags.
Add comprehensive tests for the `parseReasoning` utility to ensure correct extraction of reasoning segments across various formats, including `<think>`, `<thought>`, and analysis channel tags. Additionally, refactor `model-factory.ts` to extract the default reasoning tag into a constant `DEFAULT_REASONING_TAG` and add descriptive documentation for better maintainability.
0d585d5 to
09680d3
Compare
done |
* Update the reasoning parser and UI message converter to recognize both `<think>` and `<thought>` tags. This ensures that reasoning blocks from models using the `<thought>` format are correctly identified and displayed in the user interface. * refactor(model-factory): extract reasoning tag logic to helper function Introduces a `REASONING_TAG_MAP` and a `getReasoningTagName` helper function to centralize the logic for determining reasoning tags based on model IDs. This replaces repeated inline ternary checks across the `ModelFactory` class, improving maintainability and making it easier to add support for new models with specific reasoning tags. * test(web-app): add unit tests for parseReasoning Add comprehensive tests for the `parseReasoning` utility to ensure correct extraction of reasoning segments across various formats, including `<think>`, `<thought>`, and analysis channel tags. Additionally, refactor `model-factory.ts` to extract the default reasoning tag into a constant `DEFAULT_REASONING_TAG` and add descriptive documentation for better maintainability.
Describe Your Changes
Fixed an issue where reasoning/thought tags (e.g.,
<thought>...</thought>) remained visible in the chat UI during the streaming of a new response, despite being correctly hidden in the message history.The issue was caused by the
extractReasoningMiddlewarenot correctly utilizing the model-specifictagNameduring the streaming process. I updated the logic to ensure that reasoning tags are properly detected and extracted based on the current model configuration in real-time, ensuring a consistent user experience between active streaming and message history.Before:
<thought>tags were rendered as plain text in the UI during the first response of a new chat.After:
<thought>tags are correctly extracted and hidden/collapsed during streaming, matching the behavior of the message history.Fixes Issues