Skip to content

An AI-powered search engine with a generative UI

refactor: rename model parameter to modelId in title generator and update usage

Yoshiki Miura2143686d7e0e
diff --git a/lib/agents/title-generator.ts b/lib/agents/title-generator.ts
index 7d71dfeb..4b22aeb5 100644
--- a/lib/agents/title-generator.ts
+++ b/lib/agents/title-generator.ts
@@ -3,7 +3,7 @@ import { getModel } from '../utils/registry'
interface GenerateChatTitleParams {
userMessageContent: string
- model: string
+ modelId: string
}
/**
@@ -14,7 +14,7 @@ interface GenerateChatTitleParams {
*/
export async function generateChatTitle({
userMessageContent,
- model
+ modelId
}: GenerateChatTitleParams): Promise<string> {
// Fallback title uses the first 75 characters of the message or a default string.
const fallbackTitle = userMessageContent.substring(0, 75).trim() || 'New Chat'
@@ -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: getModel(model),
+ model: getModel(modelId),
system: systemPrompt,
prompt: userMessageContent
})
diff --git a/lib/streaming/create-chat-stream-response.ts b/lib/streaming/create-chat-stream-response.ts
index 6f15870b..635dddc4 100644
--- a/lib/streaming/create-chat-stream-response.ts
+++ b/lib/streaming/create-chat-stream-response.ts
@@ -1,5 +1,4 @@
import { researcher } from '@/lib/agents/researcher'
-import { openai } from '@ai-sdk/openai'
import {
appendClientMessage,
convertToModelMessages,
@@ -41,7 +40,7 @@ export async function createChatStreamResponse(
const userContent = getTextFromParts(message.parts)
const title = await generateChatTitle({
userMessageContent: userContent,
- model: openai('gpt-4o-mini') // TODO: Consider making this model configurable
+ modelId
})
await saveChatMessage(chatId, message, userId, title)
} else {