An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
feat: enhance reasoning answer section and update tool execution logic
Yoshiki Miuraaa065ee0319e
diff --git a/components/chat.tsx b/components/chat.tsxindex ce895460..01431e09 100644--- a/components/chat.tsx+++ b/components/chat.tsx@@ -39,7 +39,7 @@ export function Chat({onError: error => {toast.error(`Error in chat: ${error.message}`)},- sendExtraMessageFields: true+ sendExtraMessageFields: false // Disable extra message fields})useEffect(() => {diff --git a/components/reasoning-answer-section.tsx b/components/reasoning-answer-section.tsxindex 5349af16..4806db85 100644--- a/components/reasoning-answer-section.tsx+++ b/components/reasoning-answer-section.tsx@@ -72,14 +72,16 @@ export function ReasoningAnswerSection({isCollapsible={false}showIcon={false}>- <div className="flex flex-col gap-4">- <BotMessage message={content.answer || ''} />- <MessageActions- message={content.answer || ''}- chatId={chatId}- enableShare={enableShare}- />- </div>+ {content.answer && (+ <div className="flex flex-col gap-4">+ <BotMessage message={content.answer || ''} />+ <MessageActions+ message={content.answer || ''}+ chatId={chatId}+ enableShare={enableShare}+ />+ </div>+ )}</CollapsibleMessage></div>)diff --git a/lib/streaming/create-manual-tool-stream.ts b/lib/streaming/create-manual-tool-stream.tsindex ac7d563d..f4649216 100644--- a/lib/streaming/create-manual-tool-stream.ts+++ b/lib/streaming/create-manual-tool-stream.ts@@ -24,7 +24,7 @@ export function createManualToolStreamResponse(config: BaseStreamConfig) {)const { toolCallDataAnnotation, toolCallMessages } =- await executeToolCall(truncatedMessages, dataStream)+ await executeToolCall(truncatedMessages, dataStream, model)const researcherConfig = manualResearcher({messages: [...truncatedMessages, ...toolCallMessages],diff --git a/lib/streaming/tool-execution.ts b/lib/streaming/tool-execution.tsindex bc0ed6d0..87d3e790 100644--- a/lib/streaming/tool-execution.ts+++ b/lib/streaming/tool-execution.ts@@ -31,6 +31,7 @@ export async function executeToolCall(return `- ${key}${isOptional ? ' (optional)' : ''}: ${description}`}).join('\n')+ const defaultMaxResults = model?.includes('ollama') ? 5 : 20// Generate tool selection using XML formatconst toolSelectionResponse = await generateText({@@ -45,7 +46,7 @@ export async function executeToolCall(<tool>tool_name</tool><parameters><query>search query text</query>- <max_results>number - 20 by default</max_results>+ <max_results>number - ${defaultMaxResults} by default</max_results><search_depth>basic or advanced</search_depth><include_domains>domain1,domain2</include_domains><exclude_domains>domain1,domain2</exclude_domains>diff --git a/lib/utils/registry.ts b/lib/utils/registry.tsindex aac08d3c..f81c8b20 100644--- a/lib/utils/registry.ts+++ b/lib/utils/registry.ts@@ -115,14 +115,16 @@ export function isProviderEnabled(providerId: string): boolean {export function getToolCallModel(model?: string) {const provider = model?.split(':')[0]switch (provider) {- case 'groq':- return getModel('groq:llama-3.1-8b-instant')case 'deepseek':return getModel('deepseek:deepseek-chat')case 'fireworks':return getModel('fireworks:accounts/fireworks/models/llama-v3p1-8b-instruct')+ case 'groq':+ return getModel('groq:llama-3.1-8b-instant')+ case 'ollama':+ return getModel('ollama:phi4')default:return getModel('openai:gpt-4o-mini')}@@ -131,8 +133,7 @@ export function getToolCallModel(model?: string) {export function isToolCallSupported(model?: string) {const modelName = model?.split(':')[1]- return (- !modelName?.includes('deepseek-r1') &&- !modelName?.includes('deepseek-reasoner')- )+ // Deepseek R1 is not supported+ // Deepseek v3's tool call is unstable, so we include it in the list+ return !modelName?.includes('deepseek')}diff --git a/public/providers/logos/deepseek.svg b/public/providers/logos/deepseek.svgindex dc224e43..ffd3c15a 100644--- a/public/providers/logos/deepseek.svg+++ b/public/providers/logos/deepseek.svg@@ -1 +1,11 @@-<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>DeepSeek</title><path d="M23.748 4.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526 5.526 0 01-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365 11.365 0 00-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055 3.055 0 01-.465.137 9.597 9.597 0 00-2.883-.102c-1.885.21-3.39 1.102-4.497 2.623C.082 8.606-.231 10.684.152 12.85c.403 2.284 1.569 4.175 3.36 5.653 1.858 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.133-.284 4.994-1.86.47.234.962.327 1.78.397.63.059 1.236-.03 1.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926 1.096-1.296 2.746-2.642 3.392-7.003.05-.347.007-.565 0-.845-.004-.17.035-.237.23-.256a4.173 4.173 0 001.545-.475c1.396-.763 1.96-2.015 2.093-3.517.02-.23-.004-.467-.247-.588zM11.581 18c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696 4.696 0 011.529-.039c2.132.312 3.946 1.265 5.468 2.774.868.86 1.525 1.887 2.202 2.891.72 1.066 1.494 2.082 2.48 2.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306 0 01.415-.287.302.302 0 01.2.288.306.306 0 01-.31.307.303.303 0 01-.304-.308zm3.11 1.596c-.2.081-.399.151-.59.16a1.245 1.245 0 01-.798-.254c-.274-.23-.47-.358-.552-.758a1.73 1.73 0 01.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559 0 01-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z"></path></svg>\ No newline at end of file+<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">+<g clip-path="url(#clip0_4_13)">+<rect width="100" height="100" fill="white"/>+<path fill-rule="evenodd" clip-rule="evenodd" d="M98.9498 19.174C97.8915 18.6573 97.4331 19.6448 96.8165 20.149C96.604 20.3115 96.4248 20.524 96.2456 20.7157C94.6956 22.3698 92.8873 23.4532 90.5248 23.324C87.0706 23.1323 84.1206 24.2157 81.5123 26.8573C80.9581 23.599 79.1165 21.6573 76.3165 20.4073C74.8498 19.7573 73.3665 19.1115 72.3373 17.699C71.6206 16.6948 71.4248 15.574 71.0665 14.474C70.8373 13.8073 70.6081 13.1282 69.8456 13.0157C69.0123 12.8865 68.6873 13.5823 68.3623 14.1657C67.0581 16.549 66.554 19.174 66.604 21.8323C66.7165 27.8157 69.2415 32.5823 74.2623 35.9698C74.8331 36.3573 74.979 36.749 74.7998 37.3157C74.4581 38.4823 74.0498 39.6157 73.6915 40.7865C73.4623 41.5323 73.1206 41.6907 72.3206 41.3698C69.6175 40.2081 67.1621 38.5391 65.0873 36.4531C61.5165 33.0031 58.2915 29.1948 54.2665 26.2115C53.3339 25.5224 52.3763 24.8678 51.3956 24.249C47.2915 20.2615 51.9373 16.9865 53.0123 16.599C54.1373 16.1907 53.3998 14.799 49.7665 14.8157C46.1331 14.8323 42.8081 16.0448 38.5706 17.6657C37.9409 17.9069 37.2931 18.0978 36.6331 18.2365C32.6732 17.4904 28.6233 17.3471 24.6206 17.8115C16.7665 18.6865 10.4956 22.4032 5.88312 28.7407C0.341457 36.3573 -0.96271 45.0157 0.633124 54.0407C2.31229 63.5573 7.17062 71.4365 14.6331 77.5948C22.3748 83.9823 31.2873 87.1115 41.4581 86.5115C47.6331 86.1573 54.5123 85.3282 62.2665 78.7615C64.2248 79.7365 66.2748 80.124 69.6831 80.4157C72.3081 80.6615 74.8331 80.2907 76.7873 79.8823C79.8498 79.2323 79.6373 76.3948 78.5331 75.8782C69.554 71.6948 71.5248 73.399 69.729 72.0198C74.2956 66.6198 81.1706 61.0115 83.8623 42.8407C84.0706 41.3948 83.8915 40.4865 83.8623 39.3198C83.8456 38.6115 84.0081 38.3323 84.8206 38.2532C87.0749 38.0193 89.2618 37.347 91.2581 36.274C97.0748 33.0948 99.4248 27.8782 99.979 21.6198C100.062 20.6615 99.9623 19.6782 98.9498 19.174ZM48.254 75.499C39.5498 68.6573 35.329 66.4032 33.5873 66.499C31.954 66.599 32.2498 68.4615 32.6081 69.6782C32.9831 70.8782 33.4706 71.7031 34.154 72.7573C34.629 73.4532 34.954 74.4907 33.6831 75.2698C30.879 77.0032 26.0081 74.6865 25.779 74.574C20.1081 71.2323 15.3623 66.824 12.0248 60.7948C8.79979 54.9907 6.92479 48.7657 6.61646 42.1198C6.53312 40.5115 7.00396 39.9448 8.60396 39.6532C10.7044 39.2512 12.8566 39.1963 14.9748 39.4907C23.8581 40.7907 31.4165 44.7615 37.7581 51.049C41.3748 54.6323 44.1123 58.9115 46.9331 63.0948C49.9331 67.5365 53.1581 71.7698 57.2665 75.2365C58.7165 76.4532 59.8706 77.3782 60.979 78.0573C57.6373 78.4323 52.0623 78.5157 48.254 75.499ZM52.4206 48.6657C52.4199 48.4587 52.4696 48.2546 52.5654 48.0711C52.6611 47.8877 52.8002 47.7303 52.9704 47.6125C53.1406 47.4948 53.337 47.4203 53.5425 47.3954C53.7479 47.3706 53.9564 47.3961 54.1498 47.4698C54.3963 47.5582 54.6091 47.7214 54.7584 47.9365C54.9078 48.1516 54.9864 48.408 54.9831 48.6698C54.9837 48.839 54.9506 49.0066 54.8857 49.1629C54.8208 49.3192 54.7255 49.461 54.6053 49.58C54.4851 49.6991 54.3424 49.793 54.1855 49.8564C54.0286 49.9197 53.8606 49.9512 53.6915 49.949C53.5235 49.9496 53.3572 49.9166 53.2022 49.8521C53.0471 49.7876 52.9065 49.6929 52.7886 49.5734C52.6706 49.4539 52.5777 49.312 52.5152 49.1562C52.4528 49.0003 52.4179 48.8335 52.4206 48.6657ZM65.379 55.3157C64.5456 55.6532 63.7165 55.9448 62.9206 55.9823C61.7233 56.0241 60.5485 55.6501 59.5956 54.924C58.454 53.9657 57.6373 53.4323 57.2956 51.7657C57.1778 50.9512 57.2004 50.1225 57.3623 49.3157C57.654 47.9532 57.329 47.0782 56.3665 46.2865C55.5873 45.6365 54.5915 45.4573 53.4998 45.4573C53.126 45.4356 52.763 45.3241 52.4415 45.1323C51.9831 44.9073 51.6081 44.3407 51.9665 43.6407C52.0831 43.4157 52.6331 42.8657 52.7665 42.7657C54.2498 41.924 55.9623 42.199 57.5415 42.8323C59.0081 43.4323 60.1165 44.5323 61.7123 46.0907C63.3415 47.9698 63.6373 48.4907 64.5665 49.899C65.2998 51.0032 65.9665 52.1365 66.4206 53.4323C66.6998 54.2448 66.3415 54.9073 65.379 55.3157Z" fill="#4F6BFE"/>+</g>+<defs>+<clipPath id="clip0_4_13">+<rect width="100" height="100" fill="white"/>+</clipPath>+</defs>+</svg>diff --git a/public/providers/logos/groq.svg b/public/providers/logos/groq.svgindex 53700d20..3d78d168 100644--- a/public/providers/logos/groq.svg+++ b/public/providers/logos/groq.svg@@ -1,3 +1,11 @@<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">-<path d="M50.1202 18.0007C38.018 17.9033 28.118 27.6084 28.001 39.7106C27.8841 51.8128 37.6087 61.7128 49.7109 61.8297C49.8473 61.8297 49.9837 61.8297 50.1202 61.8297H57.3308V53.6252H50.1202C42.5587 53.7226 36.3615 47.6618 36.264 40.1004C36.1666 32.5389 42.2274 26.3417 49.7889 26.2442C49.8863 26.2442 50.0032 26.2442 50.1007 26.2442C57.6426 26.2442 63.8204 32.383 63.8204 39.9444V60.1147C63.8204 67.6177 57.7206 73.7175 50.2371 73.815C46.6513 73.776 43.2408 72.3533 40.7074 69.8004L34.8999 75.5884C38.9339 79.6419 44.3906 81.9415 50.1007 82H50.393C62.3393 81.8246 71.947 72.139 72.0054 60.1927V39.3793C71.7131 27.4915 61.9885 18.0202 50.1202 18.0007Z" fill="black"/>+<rect width="100" height="100" fill="#F55036"/>+<g clip-path="url(#clip0_4_12)">+<path d="M50.0502 10.0009C34.9224 9.87911 22.5475 22.0105 22.4013 37.1382C22.2551 52.266 34.411 64.641 49.5386 64.7872C49.7092 64.7872 49.8796 64.7872 50.0502 64.7872H59.0636V54.5314H50.0502C40.5984 54.6532 32.8518 47.0772 32.73 37.6254C32.6082 28.1737 40.1842 20.4271 49.636 20.3053C49.7578 20.3053 49.904 20.3053 50.0258 20.3053C59.4532 20.3053 67.1754 27.9788 67.1754 37.4306V62.6434C67.1754 72.0222 59.5508 79.6468 50.1964 79.7686C45.714 79.72 41.451 77.9416 38.2842 74.7504L31.0248 81.9854C36.0674 87.0524 42.8882 89.927 50.0258 90H50.3912C65.324 89.7808 77.3336 77.6738 77.4068 62.7408V36.7242C77.0414 21.8644 64.8856 10.0253 50.0502 10.0009Z" fill="white"/>+</g>+<defs>+<clipPath id="clip0_4_12">+<rect width="80" height="80" fill="white" transform="translate(10 10)"/>+</clipPath>+</defs></svg>