-
Notifications
You must be signed in to change notification settings - Fork 351
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
Showing the Think process for Deep Seek R1 in Cody UI #6896
base: main
Are you sure you want to change the base?
Conversation
This PR adds support for rendering <think> tags in the ChatMessageContent component. The <think> content is displayed in a collapsible details element, allowing users to view the AI's internal thought process. The MarkdownFromCody component is also updated to allow the <think> element.
open | ||
className={clsx( | ||
"tw-container tw-mb-4", | ||
"tw-border tw-border-gray-600/15 dark:tw-border-gray-500/20", |
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.
Will fix all the CSS in proper files separately AFTER the design has been approved.
@arafatkatze If you need some inspirations how I implemented it, have a look at https://github.com/PriNova/cody/blob/dev/vscode/webviews/chat/ChatMessageContent/ChatMessageContent.tsx I used special thinking tags to separate them from the model response for future changes. |
@@ -217,3 +217,140 @@ body[data-vscode-theme-kind='vscode-light'] .content pre > code { | |||
color: var(--vscode-descriptionForeground); | |||
margin-left: auto; | |||
} | |||
|
|||
/* Think Container Styles */ | |||
.thinkContainer { |
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.
@taiyab I don't actually know much about how CSS works and this code was mostly LLM generated so
How about this? @abeatrix tests this code on functionality and verifies if this does what it claims to do. We can merge this in for now but down the line when you do a much proper cleanup and merger for agentic/normal chat you can take care of this too.
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.
Any reason we want to do this in a stylesheet instead of using tailwind?
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.
Left some comments in line. I think it'd be easier if you could change the merge into branch for this PR from main to the bee/think-tag branch so we can see what the changes are between this branch and the original branch, and then merge them together before we can ask design or product for the final review.
} | ||
|
||
const extractThinkContent = (content: string): StreamingContent => { | ||
const thinkRegex = /<think>([\s\S]*?)<\/think>/g |
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.
const thinkRegex = /<think>([\s\S]*?)<\/think>/g | |
const thinkRegex = /^<think>([\s\S]*?)<\/think>/g |
Do we want to make sure only the tags at the beginning are being considered? I know I wrote the original regex but haven't really tested it throughoutly 😆
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.
Also, do we want to consider "thinking" in additional to "think" for other provider? For example, Anthropic suggested using "" tags for CoT https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/chain-of-thought#how-to-prompt-for-thinking
displayContent, | ||
thinkContent, | ||
hasThinkTag: thinkMatches.length > 0 || hasOpenThinkTag, | ||
isThinking: hasOpenThinkTag, |
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.
isThinking: hasOpenThinkTag, |
If hasThinkTag is false it already means isThinking is true? Alternatively we can rename hasThinkTag
to isThinking
if you think that's more clear, but I don't think we will need both.
displayContent: string | ||
thinkContent: string | ||
hasThinkTag: boolean | ||
isThinking: boolean |
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.
isThinking: boolean |
@@ -217,3 +217,140 @@ body[data-vscode-theme-kind='vscode-light'] .content pre > code { | |||
color: var(--vscode-descriptionForeground); | |||
margin-left: auto; | |||
} | |||
|
|||
/* Think Container Styles */ | |||
.thinkContainer { |
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.
Any reason we want to do this in a stylesheet instead of using tailwind?
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.
width: 1.5rem; | ||
height: 1.5rem; | ||
border-radius: 0.375rem; | ||
background-color: rgba(229, 231, 235, 0.5); |
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.
vscode/webviews/chat/ChatMessageContent/ChatMessageContent.module.css
Outdated
Show resolved
Hide resolved
…ule.css Co-authored-by: Beatrix <[email protected]>
Originally a PR from @abeatrix on having a thinktag UX.
Loom Video
This PR adds a simple hack to support rendering tags in the ChatMessageContent component. The content is displayed in a collapsible details element, allowing users to view the AI's internal thought process.
The MarkdownFromCody component is also updated to allow the element.
Test plan
fake-think-tag