mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-10-26 13:16:24 +00:00
* test: stabilize reporter evidence and guard missing chat nodes * feat(models): scope Web model choices to tasks, turns and conversations * test(e2e): mock model-control preview for ordinary chat submissions * fix(models): harden scoped choices and stale Agent submissions --------- Co-authored-by: Totoro-qaq <279883115+Totoro-qaq@users.noreply.github.com>
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import type { Message } from "@langchain/langgraph-sdk";
|
|
|
|
/** Presentation only. This metadata never authorizes a model or an action. */
|
|
export function modelControlDisplayText(message: Message): string | null {
|
|
if (message.type !== "human") return null;
|
|
if (typeof message.content !== "string" && !Array.isArray(message.content))
|
|
return null;
|
|
const value: unknown = message.additional_kwargs?.model_control;
|
|
if (!value || typeof value !== "object") return null;
|
|
const data = value as Record<string, unknown>;
|
|
if (
|
|
data.version !== 1 ||
|
|
typeof data.original_text !== "string" ||
|
|
typeof data.execution_text !== "string"
|
|
)
|
|
return null;
|
|
const content =
|
|
typeof message.content === "string"
|
|
? message.content
|
|
: message.content
|
|
.map((part) =>
|
|
typeof part === "string"
|
|
? part
|
|
: part.type === "text"
|
|
? part.text
|
|
: "",
|
|
)
|
|
.join("");
|
|
// Edited/replayed content must never display an earlier control statement.
|
|
return content.trim() === data.execution_text.trim()
|
|
? data.original_text
|
|
: null;
|
|
}
|