mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-24 17:06:00 +00:00
fix: improve MiniMax code plan integration (#1169)
This PR improves MiniMax Code Plan integration in DeerFlow by fixing three issues in the current flow: stream errors were not clearly surfaced in the UI, the frontend could not display the actual provider model ID, and MiniMax reasoning output could leak into final assistant content as inline <think>...</think>. The change adds a MiniMax-specific adapter, exposes real model IDs end-to-end, and adds a frontend fallback for historical messages. Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
This commit is contained in:
@@ -127,7 +127,7 @@ export function groupMessages<T>(
|
||||
|
||||
export function extractTextFromMessage(message: Message) {
|
||||
if (typeof message.content === "string") {
|
||||
return message.content.trim();
|
||||
return splitInlineReasoningFromAIMessage(message)?.content ?? message.content.trim();
|
||||
}
|
||||
if (Array.isArray(message.content)) {
|
||||
return message.content
|
||||
@@ -138,9 +138,36 @@ export function extractTextFromMessage(message: Message) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const THINK_TAG_RE = /<think>\s*([\s\S]*?)\s*<\/think>/g;
|
||||
|
||||
function splitInlineReasoning(content: string) {
|
||||
const reasoningParts: string[] = [];
|
||||
const cleaned = content
|
||||
.replace(THINK_TAG_RE, (_, reasoning: string) => {
|
||||
const normalized = reasoning.trim();
|
||||
if (normalized) {
|
||||
reasoningParts.push(normalized);
|
||||
}
|
||||
return "";
|
||||
})
|
||||
.trim();
|
||||
|
||||
return {
|
||||
content: cleaned,
|
||||
reasoning: reasoningParts.length > 0 ? reasoningParts.join("\n\n") : null,
|
||||
};
|
||||
}
|
||||
|
||||
function splitInlineReasoningFromAIMessage(message: Message) {
|
||||
if (message.type !== "ai" || typeof message.content !== "string") {
|
||||
return null;
|
||||
}
|
||||
return splitInlineReasoning(message.content);
|
||||
}
|
||||
|
||||
export function extractContentFromMessage(message: Message) {
|
||||
if (typeof message.content === "string") {
|
||||
return message.content.trim();
|
||||
return splitInlineReasoningFromAIMessage(message)?.content ?? message.content.trim();
|
||||
}
|
||||
if (Array.isArray(message.content)) {
|
||||
return message.content
|
||||
@@ -177,6 +204,9 @@ export function extractReasoningContentFromMessage(message: Message) {
|
||||
return part.thinking as string;
|
||||
}
|
||||
}
|
||||
if (typeof message.content === "string") {
|
||||
return splitInlineReasoning(message.content).reasoning;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -202,7 +232,9 @@ export function extractURLFromImageURLContent(
|
||||
|
||||
export function hasContent(message: Message) {
|
||||
if (typeof message.content === "string") {
|
||||
return message.content.trim().length > 0;
|
||||
return (
|
||||
splitInlineReasoningFromAIMessage(message)?.content ?? message.content.trim()
|
||||
).length > 0;
|
||||
}
|
||||
if (Array.isArray(message.content)) {
|
||||
return message.content.length > 0;
|
||||
@@ -222,6 +254,9 @@ export function hasReasoning(message: Message) {
|
||||
// Compatible with the Anthropic gateway
|
||||
return (part as unknown as { type: "thinking" })?.type === "thinking";
|
||||
}
|
||||
if (typeof message.content === "string") {
|
||||
return splitInlineReasoning(message.content).reasoning !== null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user