-
Notifications
You must be signed in to change notification settings - Fork 12.2k
server
: update deepseek reasoning format (pass reasoning_content as diffs)
#13933
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
Changes from 5 commits
961635c
98acde2
abdb499
8faafcd
de81d4c
e9a0e2d
3ea2e7d
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 |
---|---|---|
|
@@ -12,12 +12,6 @@ import { | |
import ChatInputExtraContextItem from './ChatInputExtraContextItem'; | ||
import { BtnWithTooltips } from '../utils/common'; | ||
|
||
interface SplitMessage { | ||
content: PendingMessage['content']; | ||
thought?: string; | ||
isThinking?: boolean; | ||
} | ||
|
||
export default function ChatMessage({ | ||
msg, | ||
siblingLeafNodeIds, | ||
|
@@ -55,32 +49,6 @@ export default function ChatMessage({ | |
const nextSibling = siblingLeafNodeIds[siblingCurrIdx + 1]; | ||
const prevSibling = siblingLeafNodeIds[siblingCurrIdx - 1]; | ||
|
||
// for reasoning model, we split the message into content and thought | ||
// TODO: implement this as remark/rehype plugin in the future | ||
const { content, thought, isThinking }: SplitMessage = useMemo(() => { | ||
if (msg.content === null || msg.role !== 'assistant') { | ||
return { content: msg.content }; | ||
} | ||
let actualContent = ''; | ||
let thought = ''; | ||
let isThinking = false; | ||
let thinkSplit = msg.content.split('<think>', 2); | ||
actualContent += thinkSplit[0]; | ||
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. If user doesn't explicitly enable Unless we can control thinking format per-request, I don't think we can remove this code block 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. reverted UI changes |
||
while (thinkSplit[1] !== undefined) { | ||
// <think> tag found | ||
thinkSplit = thinkSplit[1].split('</think>', 2); | ||
thought += thinkSplit[0]; | ||
isThinking = true; | ||
if (thinkSplit[1] !== undefined) { | ||
// </think> closing tag found | ||
isThinking = false; | ||
thinkSplit = thinkSplit[1].split('<think>', 2); | ||
actualContent += thinkSplit[0]; | ||
} | ||
} | ||
return { content: actualContent, thought, isThinking }; | ||
}, [msg]); | ||
|
||
if (!viewingChat) return null; | ||
|
||
const isUser = msg.role === 'user'; | ||
|
@@ -141,7 +109,7 @@ export default function ChatMessage({ | |
{/* not editing content, render message */} | ||
{editingContent === null && ( | ||
<> | ||
{content === null ? ( | ||
{msg.content === null ? ( | ||
<> | ||
{/* show loading dots for pending message */} | ||
<span className="loading loading-dots loading-md"></span> | ||
|
@@ -150,16 +118,16 @@ export default function ChatMessage({ | |
<> | ||
{/* render message as markdown */} | ||
<div dir="auto" tabIndex={0}> | ||
{thought && ( | ||
{msg.reasoningContent && ( | ||
<ThoughtProcess | ||
isThinking={!!isThinking && !!isPending} | ||
content={thought} | ||
isThinking={!!msg.reasoningContent && !!isPending} | ||
content={msg.reasoningContent} | ||
open={config.showThoughtInProgress} | ||
/> | ||
)} | ||
|
||
<MarkdownDisplay | ||
content={content} | ||
content={msg.content} | ||
isGenerating={isPending} | ||
/> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ export interface Message { | |
timestamp: number; // timestamp from Date.now() | ||
role: 'user' | 'assistant' | 'system'; | ||
content: string; | ||
reasoningContent: string | null; | ||
timings?: TimingReport; | ||
extra?: MessageExtra[]; | ||
// node based system for branching | ||
|
@@ -112,6 +113,7 @@ export interface ViewingChat { | |
|
||
export type PendingMessage = Omit<Message, 'content'> & { | ||
content: string | null; | ||
reasoningContent: string | null; | ||
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. Tbh I'm not very confident adding this, because it is not future-proof. If you look at how chatgpt structure their message, the |
||
}; | ||
|
||
export enum CanvasType { | ||
|
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.
should we add a help message to explain this mode?