mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-25 23:14:46 +08:00
fix: fix broken when SSE
This commit is contained in:
@@ -222,13 +222,10 @@ function ToolCall({
|
|||||||
);
|
);
|
||||||
} else if (name === "present_files") {
|
} else if (name === "present_files") {
|
||||||
return (
|
return (
|
||||||
<ChainOfThoughtStep
|
<ChainOfThoughtStep key={id} label="Present files" icon={FileTextIcon}>
|
||||||
key={id}
|
|
||||||
label={`Present file${(args as { filepaths: string[] }).filepaths.length > 1 ? "s" : ""}`}
|
|
||||||
icon={FileTextIcon}
|
|
||||||
>
|
|
||||||
<ChainOfThoughtSearchResult>
|
<ChainOfThoughtSearchResult>
|
||||||
{(args as { filepaths: string[] }).filepaths.map(
|
{Array.isArray((args as { filepaths: string[] }).filepaths) &&
|
||||||
|
(args as { filepaths: string[] }).filepaths.map(
|
||||||
(filepath: string) => (
|
(filepath: string) => (
|
||||||
<ChainOfThoughtSearchResult key={filepath}>
|
<ChainOfThoughtSearchResult key={filepath}>
|
||||||
{filepath}
|
{filepath}
|
||||||
@@ -344,7 +341,7 @@ function describeStep(step: CoTStep | undefined): {
|
|||||||
label = "Execute command";
|
label = "Execute command";
|
||||||
icon = <SquareTerminalIcon className="size-4" />;
|
icon = <SquareTerminalIcon className="size-4" />;
|
||||||
} else if (step.name === "present_files") {
|
} else if (step.name === "present_files") {
|
||||||
label = `Present file${(step.args as { filepaths: string[] }).filepaths.length > 1 ? "s" : ""}`;
|
label = "Present files";
|
||||||
icon = <FileTextIcon className="size-4" />;
|
icon = <FileTextIcon className="size-4" />;
|
||||||
} else {
|
} else {
|
||||||
label = `Call tool "${step.name}"`;
|
label = `Call tool "${step.name}"`;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { getFileExtension, getFileName } from "@/core/utils/files";
|
|||||||
|
|
||||||
export function PresentFileList({ files }: { files: string[] }) {
|
export function PresentFileList({ files }: { files: string[] }) {
|
||||||
return (
|
return (
|
||||||
<ul className="w-full">
|
<ul className="flex w-full flex-col gap-4">
|
||||||
{files.map((file) => (
|
{files.map((file) => (
|
||||||
<Card key={file}>
|
<Card key={file}>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
|
|||||||
@@ -159,9 +159,12 @@ export function extractPresentFilesFromMessage(message: Message) {
|
|||||||
if (message.type !== "ai" || !hasPresentFiles(message)) {
|
if (message.type !== "ai" || !hasPresentFiles(message)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const files = [];
|
const files: string[] = [];
|
||||||
for (const toolCall of message.tool_calls ?? []) {
|
for (const toolCall of message.tool_calls ?? []) {
|
||||||
if (toolCall.name === "present_files") {
|
if (
|
||||||
|
toolCall.name === "present_files" &&
|
||||||
|
Array.isArray(toolCall.args.filepaths)
|
||||||
|
) {
|
||||||
files.push(...(toolCall.args.filepaths as string[]));
|
files.push(...(toolCall.args.filepaths as string[]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user