- TextPart: default import → named import - MaterialCard: 使用 formatDateLabel 显示今天/昨天/日期 - 清理旧测试文件,新增 ResourceTable 测试
37 lines
938 B
TypeScript
37 lines
938 B
TypeScript
import { Typography } from "antd";
|
|
import { Markdown } from "markdown-to-jsx/react";
|
|
|
|
import type { PartProps } from "./types";
|
|
|
|
import { CodeBlock } from "./CodeBlock";
|
|
import { MarkdownTable } from "./MarkdownTable";
|
|
|
|
interface TextPartProps extends PartProps {
|
|
isStreaming: boolean;
|
|
role: string;
|
|
}
|
|
|
|
export function TextPart({ isStreaming, part, role }: TextPartProps) {
|
|
const text = typeof part["text"] === "string" ? part["text"] : "";
|
|
|
|
return (
|
|
<div className="part-body">
|
|
{role === "user" ? (
|
|
<Typography.Paragraph className="message-body-text">{text}</Typography.Paragraph>
|
|
) : (
|
|
<Markdown
|
|
options={{
|
|
optimizeForStreaming: isStreaming,
|
|
overrides: {
|
|
pre: { component: CodeBlock, props: { isStreaming } },
|
|
table: MarkdownTable,
|
|
},
|
|
}}
|
|
>
|
|
{text}
|
|
</Markdown>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|