diff --git a/app/api/chat/title/route.ts b/app/api/chat/title/route.ts index 2b38948..d4d7c68 100644 --- a/app/api/chat/title/route.ts +++ b/app/api/chat/title/route.ts @@ -6,18 +6,24 @@ interface Message { content: string; } +// Use a fast, consistent model for title generation +const TITLE_MODEL = 'deepseek-r1:8b'; + /** * Generate a short, descriptive title for a chat based on the conversation */ export async function POST(request: NextRequest) { try { - const { model, messages } = await request.json(); + const { messages } = await request.json(); // eslint-disable-next-line no-console - console.log('[Title API] Request received:', { model, messageCount: messages?.length }); + console.log('[Title API] Request received:', { + model: TITLE_MODEL, + messageCount: messages?.length, + }); - if (!model || !messages || !Array.isArray(messages) || messages.length === 0) { - return NextResponse.json({ error: 'Model and messages array are required' }, { status: 400 }); + if (!messages || !Array.isArray(messages) || messages.length === 0) { + return NextResponse.json({ error: 'Messages array is required' }, { status: 400 }); } // Format the conversation for context (truncate long messages) @@ -44,7 +50,7 @@ Rules: - "React Component Tutorial"`; const response = await ollama.chat({ - model, + model: TITLE_MODEL, messages: [ { role: 'system', content: systemPrompt }, { @@ -54,7 +60,7 @@ Rules: ], options: { temperature: 0.3, // Lower temperature for more focused output - num_predict: 20, // Limit output length + num_predict: 50, // Allow more tokens for thinking models }, }); diff --git a/components/Chat/ChatLayout.tsx b/components/Chat/ChatLayout.tsx index ac6de0c..2c95bef 100644 --- a/components/Chat/ChatLayout.tsx +++ b/components/Chat/ChatLayout.tsx @@ -449,7 +449,7 @@ export default function ChatLayout() { // Generate a title for new chats using the model let chatTitle = `${userMessage.content.slice(0, 30)}...`; // Fallback title - if (isNewChat && selectedModel) { + if (isNewChat) { try { // Build conversation context (excluding the initial greeting) const conversationForTitle = [...newMessages, responseMessage] @@ -460,7 +460,6 @@ export default function ChatLayout() { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ - model: selectedModel, messages: conversationForTitle, }), });