diff --git a/examples/chat-ui/src/components/ChatMessage.tsx b/examples/chat-ui/src/components/ChatMessage.tsx index d904b74..cdf674f 100644 --- a/examples/chat-ui/src/components/ChatMessage.tsx +++ b/examples/chat-ui/src/components/ChatMessage.tsx @@ -34,7 +34,7 @@ const ChatMessage: React.FC = ({ className={` ${ message.role === "user" - ? "max-w-[80%] rounded-2xl px-3 py-2 border border-zinc-200/10 bg-zinc-100 text-black" + ? "max-w-[80%] rounded-2xl px-3 py-2 border border-zinc-200/10 bg-white text-black" : " text-zinc-900 w-full" }`} > diff --git a/examples/chat-ui/src/hooks/useStreamResponse.ts b/examples/chat-ui/src/hooks/useStreamResponse.ts index b4004a0..cea27d5 100644 --- a/examples/chat-ui/src/hooks/useStreamResponse.ts +++ b/examples/chat-ui/src/hooks/useStreamResponse.ts @@ -271,9 +271,18 @@ export const useStreamResponse = ({ // Remove thinking tags from the display text (they should be extracted by middleware) let cleanedResponse = aiResponse if (supportsReasoning(selectedModel)) { + debugLog(`[useStreamResponse] Original response:`, aiResponse.substring(0, 100)) + // Remove complete thinking blocks cleanedResponse = aiResponse.replace(/[\s\S]*?<\/think>/g, '').trim() - // Also handle unclosed think tags + // Remove unclosed think tags (everything from to end) cleanedResponse = cleanedResponse.replace(/[\s\S]*$/g, '').trim() + // Remove any remaining opening think tags + cleanedResponse = cleanedResponse.replace(//g, '').trim() + // Remove any remaining closing think tags + cleanedResponse = cleanedResponse.replace(/<\/think>/g, '').trim() + // Clean up any remaining whitespace or newlines at the start + cleanedResponse = cleanedResponse.replace(/^\s+/, '') + debugLog(`[useStreamResponse] Cleaned response:`, cleanedResponse.substring(0, 100)) } setConversations((prev) => {