Spaces:
Running
Running
File size: 1,077 Bytes
aa01edd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import { TypographyStylesProvider } from "@mantine/core";
import { lazy } from "react";
import { useReasoningContent } from "./hooks/useReasoningContent";
const MarkdownRenderer = lazy(() => import("./MarkdownRenderer"));
const ReasoningSection = lazy(() => import("./ReasoningSection"));
interface FormattedMarkdownProps {
children: string;
className?: string;
enableCopy?: boolean;
}
export default function FormattedMarkdown({
children,
className = "",
enableCopy = true,
}: FormattedMarkdownProps) {
const { reasoningContent, mainContent, isGenerating } =
useReasoningContent(children);
if (!children) {
return null;
}
return (
<TypographyStylesProvider p="lg">
{reasoningContent && (
<ReasoningSection
content={reasoningContent}
isGenerating={isGenerating}
/>
)}
{!isGenerating && mainContent && (
<MarkdownRenderer
content={mainContent}
enableCopy={enableCopy}
className={className}
/>
)}
</TypographyStylesProvider>
);
}
|