feat(stage-ui): process for reasoning models#859
Conversation
…sness-module-categorisation
This reverts commit dcfe785.
Summary of ChangesHello @TECozens, 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 significantly enhances the chat assistant's user experience by intelligently separating AI-generated reasoning from direct speech. It introduces a dedicated, collapsible UI element to present the AI's thought process, while simultaneously ensuring that Text-to-Speech (TTS) output remains clear and concise by excluding this reasoning. The changes involve robust streaming categorization logic and new utility functions to manage and leverage this categorized content, improving both visual clarity and audio relevance in AI interactions. Highlights
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.
Code Review
This PR introduces a great feature for separating reasoning from speech in assistant responses. The implementation is comprehensive, covering streaming, UI display, and data storage. I've found a few areas for improvement:
- A critical bug in the
llmmarkerParserthat could duplicate text. - A potential data inconsistency in the
chat.tsstore when reconciling streamed content. - Some opportunities for code simplification and performance improvement in the Vue component and composables.
- The streaming response categorizer has some fragility in its tag parsing that could be improved for robustness.
Overall, this is a solid contribution. Addressing these points will make it even better.
packages/stage-ui/src/components/scenarios/chat/ChatResponseCategorization.vue
Outdated
Show resolved
Hide resolved
Applying suggestion 1 Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…com/TECozens/airi-lab into consciousness-module-categorisation
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a well-architected feature to separate "reasoning" from "speech" in assistant responses using tagged content. The implementation is clean, adding new components and composables to handle the UI and logic, and integrating them effectively into the chat store's streaming process. My review focuses on a few areas for improvement, including enhancing code clarity by removing redundancy, improving robustness by avoiding non-null assertions, addressing a potential performance bottleneck in the streaming parser, and improving maintainability by replacing a magic number with a constant. Overall, this is a solid contribution that adds valuable capabilities.
packages/stage-ui/src/components/scenarios/chat/ChatResponseCategorization.vue
Outdated
Show resolved
Hide resolved
packages/stage-ui/src/components/scenarios/chat/ChatResponseCategorization.vue
Outdated
Show resolved
Hide resolved
…sness-module-categorisation, erm hoping this merge conflict is resolved
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a robust mechanism for separating 'reasoning' from 'speech' in assistant responses by parsing XML-like tags. The implementation is well-structured, adding a new responseCategorizer composable that handles both streaming and full-text categorization, and integrates it into the chat store to filter content for TTS and display. The UI is updated with a collapsible section for reasoning. I've identified a few areas for improvement, mainly around error handling and robustness in the new parsing logic.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Would be useful to log this to add further compatibility in the future Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
Updated 👍🏼 ready for review |
packages/stage-ui/src/components/scenarios/chat/ChatAssistantItem.vue
Outdated
Show resolved
Hide resolved
…com/TECozens/airi-lab into consciousness-module-categorisation
…sness-module-categorisation
I think now it should (Hooray, shall be my first open source contribution) |
packages/stage-ui/src/components/scenarios/chat/ChatResponsePart.vue
Outdated
Show resolved
Hide resolved
…com/TECozens/airi-lab into consciousness-module-categorisation
✅ Deploy to Cloudflare Workers (Preview) for stage-web ready!
|
Description
Before
After
New Features
This PR will provide a collapsible reasoning box to the assistant chat, it renders only the speech in the chat
TTS ignores reasoning
Reasoning is defined by any response which is wrapped in tags
<think>,<thoughts>etc, this excludes and does not have an affect on SPECIAL_TOKENSProvided is
use-chat-session/summary.tscontaining helper functions to grab the reasoning from a chat session, I believe we can use this to create summaries and store those are memories or use the reasoning directly with little processing.Linked Issues
#835
Additional Context
There were a lot of challenges in retrospect so I have kept a couple of the ideas in mind for future feature requests and PRs
I think the biggest challenge is determining if the input comes from a reasoning model and what parts of text were reasoning.
I think that if a toggle is needed I could add one to enable/disable reasoning filter, but at present it moves reasoning content if found to a collapsible box and TTS ignores it during stream.
Still i found the streaming and tts to be quite difficult to understand at first like if the response was completed and we performed TTS on the final response that might be easier than doing it per chunk we parse as we do.
Open to suggestions but I found limitations in trying to work around the current approach, if all if fine then we can push this!
I also think that this burns tokens like crazy (Current Release) Significantly less now with only speech parts

Testing
Unit Test Response Categoriser
Example Test Input
Sample Output: