An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
Remove Ollama AI provider and update model references
Yoshiki Miurab55c49df51fc
diff --git a/bun.lock b/bun.lockindex 1093579b..bbb0d699 100644--- a/bun.lock+++ b/bun.lock@@ -51,7 +51,6 @@"next": "^15.2.3","next-themes": "^0.3.0","node-html-parser": "^6.1.13",- "ollama-ai-provider": "^1.2.0","postgres": "^3.4.5","react": "^19.0.0","react-dom": "^19.0.0",@@ -1348,8 +1347,6 @@"object.values": ["[email protected]", "", { "dependencies": { "call-bind": "^1.0.8", "call-bound": "^1.0.3", "define-properties": "^1.2.1", "es-object-atoms": "^1.0.0" } }, "sha512-gXah6aZrcUxjWg2zR2MwouP2eHlCBzdV4pygudehaKXSGW4v2AsRQUK+lwwXhii6KFZcunEnmSUoYp5CXibxtA=="],- "ollama-ai-provider": ["[email protected]", "", { "dependencies": { "@ai-sdk/provider": "^1.0.0", "@ai-sdk/provider-utils": "^2.0.0", "partial-json": "0.1.7" }, "peerDependencies": { "zod": "^3.0.0" }, "optionalPeers": ["zod"] }, "sha512-jTNFruwe3O/ruJeppI/quoOUxG7NA6blG3ZyQj3lei4+NnJo7bi3eIRWqlVpRlu/mbzbFXeJSBuYQWF6pzGKww=="],-"once": ["[email protected]", "", { "dependencies": { "wrappy": "1" } }, "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w=="],"optionator": ["[email protected]", "", { "dependencies": { "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", "type-check": "^0.4.0", "word-wrap": "^1.2.5" } }, "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g=="],@@ -1368,8 +1365,6 @@"parse5": ["[email protected]", "", { "dependencies": { "entities": "^6.0.0" } }, "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw=="],- "partial-json": ["[email protected]", "", {}, "sha512-Njv/59hHaokb/hRUjce3Hdv12wd60MtM9Z5Olmn+nehe0QDAsRtRbJPvJ0Z91TusF0SuZRIvnM+S4l6EIP8leA=="],-"path-exists": ["[email protected]", "", {}, "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w=="],"path-is-absolute": ["[email protected]", "", {}, "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg=="],@@ -1528,8 +1523,6 @@"scheduler": ["[email protected]", "", {}, "sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA=="],- "secure-json-parse": ["[email protected]", "", {}, "sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw=="],-"semver": ["[email protected]", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],"set-cookie-parser": ["[email protected]", "", {}, "sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ=="],@@ -1880,10 +1873,6 @@"node-fetch/whatwg-url": ["[email protected]", "", { "dependencies": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" } }, "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw=="],- "ollama-ai-provider/@ai-sdk/provider": ["@ai-sdk/[email protected]", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-qZMxYJ0qqX/RfnuIaab+zp8UAeJn/ygXXAffR5I4N0n1IrvA6qBsjc8hXLmBiMV2zoXlifkacF7sEFnYnjBcqg=="],-- "ollama-ai-provider/@ai-sdk/provider-utils": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "1.1.3", "nanoid": "^3.3.8", "secure-json-parse": "^2.7.0" }, "peerDependencies": { "zod": "^3.23.8" } }, "sha512-kM0xS3GWg3aMChh9zfeM+80vEZfXzR3JEUBdycZLtbRZ2TRT8xOj3WodGHPb06sUK5yD7pAXC/P7ctsi2fvUGQ=="],-"path-scurry/lru-cache": ["[email protected]", "", {}, "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="],"pretty-format/ansi-styles": ["[email protected]", "", {}, "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA=="],diff --git a/lib/agents/generate-related-questions.ts b/lib/agents/generate-related-questions.tsindex 0d5ebe7a..c5085234 100644--- a/lib/agents/generate-related-questions.ts+++ b/lib/agents/generate-related-questions.ts@@ -1,11 +1,6 @@import { relatedSchema } from '@/lib/schema/related'-import { openai } from '@ai-sdk/openai'import { ModelMessage, generateObject } from 'ai'-import {- getModel,- getToolCallModel,- isToolCallSupported-} from '../utils/registry'+import { getModel } from '../utils/registry'export async function generateRelatedQuestions(messages: ModelMessage[],@@ -16,14 +11,8 @@ export async function generateRelatedQuestions(role: 'user'})) as ModelMessage[]- const supportedModel = isToolCallSupported(model)- const currentModel = supportedModel- ? getModel(model)- : getToolCallModel(model)-const result = await generateObject({- // model: currentModel, //- model: openai('gpt-4o-mini'),+ model: getModel(model),system: `As a professional web researcher, your task is to generate a set of three queries that explore the subject matter more deeply, building upon the initial query and the information uncovered in its search results.For instance, if the original query was "Starship's third test flight key milestones", your output should follow this format:diff --git a/lib/agents/researcher.ts b/lib/agents/researcher.tsindex d0533aad..bcf2714d 100644--- a/lib/agents/researcher.ts+++ b/lib/agents/researcher.ts@@ -1,9 +1,9 @@-import { openai } from '@ai-sdk/openai'import { ModelMessage, smoothStream, streamText } from 'ai'import { createQuestionTool } from '../tools/question'import { retrieveTool } from '../tools/retrieve'import { createSearchTool } from '../tools/search'import { createVideoSearchTool } from '../tools/video-search'+import { getModel } from '../utils/registry'const SYSTEM_PROMPT = `Instructions:@@ -51,7 +51,7 @@ export function researcher({const askQuestionTool = createQuestionTool(model)const config = {- model: openai('gpt-4o-mini'), // TODO: Make this configurable+ model: getModel(model),system: `${SYSTEM_PROMPT}\nCurrent date and time: ${currentDate}`,messages,tools: {diff --git a/lib/agents/title-generator.ts b/lib/agents/title-generator.tsindex 78d9d75b..7d71dfeb 100644--- a/lib/agents/title-generator.ts+++ b/lib/agents/title-generator.ts@@ -1,9 +1,9 @@-import { openai } from '@ai-sdk/openai'-import { generateText, LanguageModel } from 'ai'+import { generateText } from 'ai'+import { getModel } from '../utils/registry'interface GenerateChatTitleParams {userMessageContent: string- model: LanguageModel+ model: string}/**@@ -23,7 +23,7 @@ export async function generateChatTitle({const systemPrompt = `System: You are an AI assistant specialized in creating very short, concise, and informative titles for chat conversations based on the user's first message. The title should ideally be 3-5 words long, and no more than 10 words. Only output the title itself, with no prefixes, labels, or quotation marks.`const { text: generatedTitle } = await generateText({- model: openai('gpt-4o-mini'), // TODO: Make this configurable+ model: getModel(model),system: systemPrompt,prompt: userMessageContent})diff --git a/lib/utils/registry.ts b/lib/utils/registry.tsindex 896ff546..2c89e317 100644--- a/lib/utils/registry.ts+++ b/lib/utils/registry.ts@@ -9,9 +9,9 @@ import { xai } from '@ai-sdk/xai'import {createProviderRegistry,extractReasoningMiddleware,+ LanguageModel,wrapLanguageModel} from 'ai'-import { createOllama } from 'ollama-ai-provider'export const registry = createProviderRegistry({openai,@@ -37,19 +37,9 @@ export const registry = createProviderRegistry({xai})-export function getModel(model: string) {+export function getModel(model: string): LanguageModel {const [provider, ...modelNameParts] = model.split(':') ?? []const modelName = modelNameParts.join(':')- if (model.includes('ollama')) {- const ollama = createOllama({- baseURL: `${process.env.OLLAMA_BASE_URL}/api`- })-- // if ollama provider, set simulateStreaming to true- return ollama(modelName, {- simulateStreaming: true- })- }// if model is groq and includes deepseek-r1, add reasoning middlewareif (model.includes('groq') && model.includes('deepseek-r1')) {diff --git a/package.json b/package.jsonindex af50a114..fa304a3d 100644--- a/package.json+++ b/package.json@@ -60,7 +60,6 @@"next": "^15.2.3","next-themes": "^0.3.0","node-html-parser": "^6.1.13",- "ollama-ai-provider": "^1.2.0","postgres": "^3.4.5","react": "^19.0.0","react-dom": "^19.0.0",