mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-18 20:14:44 +08:00
fix: lastStep could be empty
This commit is contained in:
@@ -41,7 +41,7 @@ export function MessageGroup({
|
|||||||
const steps = useMemo(() => convertToSteps(messages), [messages]);
|
const steps = useMemo(() => convertToSteps(messages), [messages]);
|
||||||
const rehypePlugins = useRehypeSplitWordsIntoSpans(isLoading);
|
const rehypePlugins = useRehypeSplitWordsIntoSpans(isLoading);
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const lastStep = steps[steps.length - 1]!;
|
const lastStep = steps[steps.length - 1];
|
||||||
const { label, icon } = describeStep(lastStep);
|
const { label, icon } = describeStep(lastStep);
|
||||||
return (
|
return (
|
||||||
<ChainOfThought
|
<ChainOfThought
|
||||||
@@ -289,10 +289,13 @@ function convertToSteps(messages: Message[]): CoTStep[] {
|
|||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
function describeStep(step: CoTStep): {
|
function describeStep(step: CoTStep | undefined): {
|
||||||
label: string;
|
label: string;
|
||||||
icon: React.ReactElement;
|
icon: React.ReactElement;
|
||||||
} {
|
} {
|
||||||
|
if (!step) {
|
||||||
|
return { label: "Thinking", icon: <LightbulbIcon className="size-4" /> };
|
||||||
|
}
|
||||||
if (step.type === "reasoning") {
|
if (step.type === "reasoning") {
|
||||||
return { label: "Thinking", icon: <LightbulbIcon className="size-4" /> };
|
return { label: "Thinking", icon: <LightbulbIcon className="size-4" /> };
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user