-
-
Notifications
You must be signed in to change notification settings - Fork 8
Implement Reasoning UI #408
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?
Changes from 2 commits
a71976c
9c557bf
dd4ebe7
54fdc7a
51f7d62
465e97c
a72cc00
7cc9f52
de446b7
6fdcab6
05ea3ca
173e499
794d022
e5c03b2
896348f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,3 +52,4 @@ aef_index.csv | |
| # Environment variables with GCP credentials | ||
| .env.local | ||
| .env.production.local | ||
| dev_server.log | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| 'use client' | ||
|
|
||
| import { StreamableValue, useStreamableValue } from 'ai/rsc' | ||
| import { MemoizedReactMarkdown } from './ui/markdown' | ||
|
|
||
| export function ReasoningDisplay({ | ||
| content | ||
| }: { | ||
| content: StreamableValue<string> | ||
| }) { | ||
| const [data, error, pending] = useStreamableValue(content) | ||
|
|
||
| if (error) { | ||
| return <div>Error</div> | ||
| } | ||
|
|
||
| if (pending) { | ||
| return null | ||
| } | ||
|
|
||
| return ( | ||
| <div className="overflow-x-auto"> | ||
| <MemoizedReactMarkdown className="prose-sm prose-neutral prose-a:text-accent-foreground/50"> | ||
| {data || ''} | ||
| </MemoizedReactMarkdown> | ||
| </div> | ||
| ) | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,12 +41,22 @@ export function getModel(requireVision: boolean = false) { | |
| // Gemini 3 Pro | ||
| if (gemini3ProApiKey) { | ||
| const google = createGoogleGenerativeAI({ | ||
| apiKey: gemini3ProApiKey, | ||
| apiKey: gemini3ProApiKey | ||
| }) | ||
| try { | ||
| return google('gemini-3-pro-preview') | ||
| // Enable Gemini's "thinking mode" to stream reasoning steps. | ||
| // See: https://ai-sdk.dev/cookbook/guides/gemini#enhanced-reasoning-with-thinking-mode | ||
| const google = createGoogleGenerativeAI({ | ||
| apiKey: gemini3ProApiKey | ||
| }) | ||
| return google('gemini-3-pro-preview', { | ||
| thinkingLevel: 'low' | ||
| }) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
SuggestionCreate the client once and reuse it. Also avoid shadowing the // Gemini 3 Pro
if (gemini3ProApiKey) {
const gemini = createGoogleGenerativeAI({ apiKey: gemini3ProApiKey })
try {
return gemini('gemini-3-pro-preview', {
// Enable Gemini's "thinking mode"
thinkingLevel: 'low'
})
} catch (error) {
console.warn('Gemini 3 Pro API unavailable, falling back to next provider:', error)
}
}Reply with "@CharlieHelps yes please" if you'd like me to add a commit with this suggestion. |
||
| } catch (error) { | ||
| console.warn('Gemini 3 Pro API unavailable, falling back to next provider:', error) | ||
| console.warn( | ||
| 'Gemini 3 Pro API unavailable, falling back to next provider:', | ||
| error | ||
| ) | ||
| } | ||
| } | ||
|
|
||
|
|
||
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 writes
reasoningResponseto persistedaiStateand renders it withMemoizedReactMarkdown. If the provider emits structured or sensitive internal reasoning, you are explicitly persisting and re-displaying it after reload. That’s a product/security decision, but it needs a clear guard/flag because it increases risk (PII leakage, prompt-injection artifacts, policy issues) and can significantly bloat stored chat history.At minimum, this should be gated behind a user setting or server-side config and/or truncated/summarized before persistence.
Suggestion
Gate persistence behind an explicit flag (e.g.,
persistReasoning), and consider truncation to a safe max length.Reply with "@CharlieHelps yes please" if you'd like me to add a commit with this suggestion.