@@ -18,7 +18,8 @@ import {
18
18
SelectTrigger ,
19
19
SelectValue ,
20
20
} from "@/components/ui/select" ;
21
- import { AIModel , APIResponseMetrics , CustomModel , Message , availableModels } from "@/lib/types" ;
21
+ import { AIModel , APIResponseMetrics , CustomModel , Message } from "@/lib/types" ;
22
+ import { availableModels } from "@/lib/remotemodels" ;
22
23
import { cn , isEqual , sanitizeChatMessages } from "@/lib/utils" ;
23
24
import { useStore } from "@/lib/store" ;
24
25
import { Copy , Check } from "lucide-react" ;
@@ -34,6 +35,8 @@ import { CodeBlock } from "./CodeBlock";
34
35
import remarkGfm from 'remark-gfm' ;
35
36
import { countTokens } from "@/lib/toksec" ;
36
37
import { useMetricsStore } from "@/lib/metricstore" ;
38
+ import { processThinkingContent } from "@/lib/utils" ;
39
+ import { ThinkingBlock } from "./ThinkingBlock" ;
37
40
38
41
export function ChatNode ( { id, data : initialData } : NodeProps ) {
39
42
const [ input , setInput ] = useState ( "" ) ;
@@ -848,6 +851,58 @@ export function ChatNode({ id, data: initialData }: NodeProps) {
848
851
className = "max-w-sm rounded-md"
849
852
/>
850
853
) }
854
+ { msg . content && ( ( ) => {
855
+ const { blocks, processedContent } = processThinkingContent ( msg . content ) ;
856
+ return (
857
+ < >
858
+ { blocks . map ( ( block ) =>
859
+ block . type === 'thinking' ? (
860
+ < ThinkingBlock key = { block . key } >
861
+ < ReactMarkdown
862
+ components = { {
863
+ code : CodeBlock as any ,
864
+ pre : ( { children } ) => < pre className = "p-0 m-0" onClick = { e => e . stopPropagation ( ) } > { children } </ pre > ,
865
+ h1 : ( { children } ) => < h1 className = "text-2xl font-bold mb-2" > { children } </ h1 > ,
866
+ h2 : ( { children } ) => < h2 className = "text-xl font-bold mb-2" > { children } </ h2 > ,
867
+ h3 : ( { children } ) => < h3 className = "text-lg font-bold mb-2" > { children } </ h3 > ,
868
+ h4 : ( { children } ) => < h4 className = "text-base font-bold mb-2" > { children } </ h4 > ,
869
+ p : ( { children } ) => < p className = "mt-1 mb-2" > { children } </ p > ,
870
+ ul : ( { children } ) => < ul className = "list-disc list-inside mb-4" > { children } </ ul > ,
871
+ ol : ( { children } ) => < ol className = "list-decimal list-inside mb-4" > { children } </ ol > ,
872
+ li : ( { children } ) => < li className = "mb-2" > { children } </ li > ,
873
+ a : ( { href, children } ) => (
874
+ < a href = { href } className = "text-primary hover:underline" target = "_blank" rel = "noopener noreferrer" >
875
+ { children }
876
+ </ a >
877
+ ) ,
878
+ blockquote : ( { children } ) => (
879
+ < blockquote className = "border-l-4 border-primary pl-4 italic mb-4" >
880
+ { children }
881
+ </ blockquote >
882
+ ) ,
883
+ img : ( { src, alt } ) => (
884
+ < img src = { src } alt = { alt } className = "max-w-full h-auto rounded-lg mb-4" />
885
+ ) ,
886
+ table : ( { children } ) => (
887
+ < div className = "overflow-x-auto mb-4" >
888
+ < table className = "min-w-full divide-y divide-border" >
889
+ { children }
890
+ </ table >
891
+ </ div >
892
+ ) ,
893
+ th : ( { children } ) => (
894
+ < th className = "px-4 py-2 bg-muted font-medium" > { children } </ th >
895
+ ) ,
896
+ td : ( { children } ) => (
897
+ < td className = "px-4 py-2 border-t" > { children } </ td >
898
+ ) ,
899
+ } }
900
+ remarkPlugins = { [ remarkGfm ] } >
901
+ { block . content }
902
+ </ ReactMarkdown >
903
+ </ ThinkingBlock >
904
+ ) : null
905
+ ) }
851
906
< ReactMarkdown
852
907
components = { {
853
908
code : CodeBlock as any ,
@@ -889,8 +944,11 @@ export function ChatNode({ id, data: initialData }: NodeProps) {
889
944
} }
890
945
remarkPlugins = { [ remarkGfm ] }
891
946
>
892
- { msg . content }
893
- </ ReactMarkdown >
947
+ { processedContent }
948
+ </ ReactMarkdown >
949
+ </ >
950
+ ) ;
951
+ } ) ( ) }
894
952
{ msg . role === "assistant" && msg . metrics && (
895
953
< div className = "text-xs text-gray-500 mt-1" >
896
954
{ msg . metrics . totalTokens && `${ msg . metrics . totalTokens } tokens` }
0 commit comments