-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Open
google-labs-jules
wants to merge
13
commits into
main
Choose a base branch
from
reasoning-ui-implementation-14906469948929511061
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a71976c
feat: Implement reasoning UI for model thinking process
google-labs-jules[bot] 9c557bf
feat: Implement reasoning UI for model thinking process
google-labs-jules[bot] dd4ebe7
Of course! Here is the rewritten message from the perspective of Jules:
google-labs-jules[bot] 54fdc7a
fix: build errors, added pg dependency and fixed google generative ai…
ngoiyaeric 51f7d62
feat: Implement reasoning UI for model thinking process
google-labs-jules[bot] 465e97c
feat: implement cross-provider reasoning options
ngoiyaeric a72cc00
chore: update model defaults for reasoning support
ngoiyaeric 7cc9f52
Merge branch 'main' into reasoning-ui-implementation-1490646994892951…
ngoiyaeric de446b7
Merge branch 'main' into reasoning-ui-implementation-1490646994892951…
ngoiyaeric 6fdcab6
chore: verify build and reasoning ui compatibility
ngoiyaeric 05ea3ca
feat: implement collapsible reasoning dropdown and fix build errors
CJWTRUST 173e499
Merge branch 'main' into reasoning-ui-implementation-1490646994892951…
ngoiyaeric 794d022
reasoning model change
ngoiyaeric File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| 'use client' | ||
|
|
||
| import { StreamableValue, useStreamableValue } from 'ai/rsc' | ||
| import { MemoizedReactMarkdown } from './ui/markdown' | ||
| import { useState, useEffect } from 'react' | ||
| import { ChevronDown, ChevronUp } from 'lucide-react' | ||
| import { cn } from '@/lib/utils' | ||
|
|
||
| export function ReasoningDisplay({ | ||
| content | ||
| }: { | ||
| content: StreamableValue<string> | ||
| }) { | ||
| const [data, error, pending] = useStreamableValue(content) | ||
| const [isExpanded, setIsExpanded] = useState(true) | ||
|
|
||
| // Auto-expand when new data arrives if it was previously empty | ||
| useEffect(() => { | ||
| if (data && data.length > 0 && pending) { | ||
| setIsExpanded(true) | ||
| } | ||
| }, [data, pending]) | ||
|
|
||
| if (error) { | ||
| return <div className="text-red-500 text-sm">Error loading reasoning</div> | ||
| } | ||
|
|
||
| const hasContent = data && data.length > 0 | ||
|
|
||
| return ( | ||
| <div className="my-2 border border-primary/10 rounded-lg overflow-hidden bg-primary/5"> | ||
| <button | ||
| onClick={() => setIsExpanded(!isExpanded)} | ||
| className="w-full flex items-center justify-between px-4 py-2 text-sm font-medium text-primary/70 hover:bg-primary/10 transition-colors" | ||
| > | ||
| <div className="flex items-center gap-2"> | ||
| <span>Research Process</span> | ||
| {pending && ( | ||
| <span className="flex h-2 w-2 relative"> | ||
| <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75"></span> | ||
| <span className="relative inline-flex rounded-full h-2 w-2 bg-primary"></span> | ||
| </span> | ||
| )} | ||
| </div> | ||
| {isExpanded ? <ChevronUp size={16} /> : <ChevronDown size={16} />} | ||
| </button> | ||
|
|
||
| <div | ||
| className={cn( | ||
| "overflow-hidden transition-all duration-200 ease-in-out", | ||
| isExpanded ? "max-h-[1000px] opacity-100" : "max-h-0 opacity-0" | ||
| )} | ||
| > | ||
| <div className="px-4 pb-4 pt-2 border-t border-primary/10"> | ||
| {hasContent ? ( | ||
| <div className="overflow-x-auto"> | ||
| <MemoizedReactMarkdown className="prose-sm prose-neutral prose-a:text-accent-foreground/50 dark:prose-invert max-w-none"> | ||
| {data} | ||
| </MemoizedReactMarkdown> | ||
| </div> | ||
| ) : ( | ||
| <div className="text-sm text-primary/40 italic"> | ||
| {pending ? 'Thinking...' : 'No reasoning available.'} | ||
| </div> | ||
| )} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.