-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
When using the Gemini API with grounding enabled (enableGrounding: true
), the grounding sources (citations) are displayed as a separate message after the assistant's response, rather than being integrated into the assistant's message itself. This creates a poor user experience where the conversation flow appears fragmented.
Current Behavior
When Gemini returns a response with grounding metadata:
- The assistant's response appears as one message
- The grounding sources appear as a separate message immediately after
- This creates a visual separation that makes it seem like the sources are unrelated to the response
Example of current display:
[Assistant message with response content]
[User's next message or interaction]
[Sources: [1](url1), [2](url2)] <- Appears as separate message
Expected Behavior
The grounding sources should be integrated into the assistant's message, appearing as part of the same message block:
[Assistant message with response content]
Sources: [1](url1), [2](url2)
Technical Context
- The issue occurs in
src/api/providers/gemini.ts
- Grounding metadata is extracted correctly via
extractCitationsOnly()
method - The sources are currently yielded as a separate text chunk in the stream
- This separate chunk is interpreted by the UI as a new message
Proposed Solution
The sources should be appended to the assistant's message content before the final text chunk is yielded, ensuring they appear as part of the same message in the UI. This requires modifying the streaming logic to buffer and combine the content appropriately.
Impact
This affects all users who have enabled grounding/Google Search integration with Gemini models, causing a fragmented conversation experience when sources are displayed.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status