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