ResponseView
模型的响应在到达时的样子:首个 Token 到达前不显示任何内容,流式返回时显示 Markdown,推理放在“思考中”折叠区内,停止、截断和失败状态都保持克制。
Subject: Your order #4471 is on its way — and we’re sorry it’s late
Hi Maya,
Your order #4471 left our warehouse on time, but a delay with our carrier held it up for three days. That’s not the experience we want for you, and I’m sorry.
It’s moving again and should arrive by Thursday. As a thank-you for your patience, your next order ships free — the code is applied to your account automatically.
Warmly,
The Northwind team
- 首个 Token
- 1.18 秒
- 总计
- 6.12 秒
function Stream() {
const [state, setState] = useState<{ status: ResponseStatus; text: string; reasoning: string; took?: number; started?: number; total?: number }>({
status: "done",
text: gpt.text,
reasoning: gpt.reasoning!,
took: 3800,
total: 6120,
});
const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
useEffect(() => () => clearTimeout(timer.current), []);
const play = () => {
clearTimeout(timer.current);
const started = Date.now();
let r = 0;
let t = 0;
let took: number | undefined;
setState({ status: "pending", text: "", reasoning: "", started });
const tick = () => {
if (r < gpt.reasoning!.length) r += 8;
else {
took ??= Date.now() - started;
t += 6;
}
const done = t >= gpt.text.length;
setState({
status: done ? "done" : "streaming",
reasoning: gpt.reasoning!.slice(0, r),
text: gpt.text.slice(0, t),
started,
...(took !== undefined ? { took } : {}),
...(done ? { total: Date.now() - started } : {}),
});
if (!done) timer.current = setTimeout(tick, 24);
};
timer.current = setTimeout(tick, 700);
};
return (
<div className="flex w-full max-w-560 flex-col gap-16">
<div>
<Button size="sm" onClick={play} disabled={state.status === "pending" || state.status === "streaming"}>
Stream it again
</Button>
</div>
<ResponseView
aria-label="GPT-5 response"
status={state.status}
text={state.text}
reasoning={state.reasoning}
{...(state.took !== undefined ? { reasoningDuration: state.took } : {})}
footer={
<ResponseMetrics
live={state.status === "pending" || state.status === "streaming"}
startedAt={state.started}
duration={state.total}
timeToFirstToken={state.status === "pending" ? undefined : 1180}
/>
}
/>
</div>
);
}import { ResponseView, UserMessage, Thread } from "@logicplanes/kaeso-ui/playground";属性
aria-labelstring回复的无障碍名称(对比时如“GPT-5 回复”)。默认为 LocaleProvider 语言中的“回复”。
defaultReasoningOpenboolean推理过程是否初始展开。
errorstring回复失败的原因,在状态为 "error" 时显示在“无响应”下方:网关的消息,使用读者的语言;
code片段以代码形式显示。footerReactNode在响应下方、复制和重试所在行之后:其指标。
incompleteReasonstring模型截断回复的原因,在状态为 "incomplete" 时使用:
max_output_tokens显示“达到输出限额后停止”,content_filter会指明过滤器。onReasoningOpenChange((open: boolean) => void)推理过程展开或收起时调用。
onRetry(() => void)重新发送该轮:在停止、被截断的回复或出错后显示“重试”按钮,在完成的回复下方显示低调的“重试”圆形按钮。
reasoningstring目前为止的推理摘要,为 Markdown。由“思考中”折叠区显示,默认收起。
reasoningDurationnumber模型推理的时长(毫秒):“思考了 4.2 秒”。
reasoningOpenboolean受控时,推理过程是否展开。
status"done" | "error" | "streaming" | "pending" | "stopped" | "incomplete" = done回复所处的状态:等待中、流式输出中、已完成、已停止、被模型截断(incomplete)或失败。
textstring目前为止的输出文本,为 Markdown。