From 1d49a3f49c8e42205cdc5cc892bd85489a08cfa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?th=E1=BB=8Bnh?= Date: Mon, 23 Dec 2024 17:01:19 +0700 Subject: [PATCH] Use a better model for specific people --- personas-open-source/src/app/api/chat/route.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/personas-open-source/src/app/api/chat/route.ts b/personas-open-source/src/app/api/chat/route.ts index 3335c1a76..91156a99b 100644 --- a/personas-open-source/src/app/api/chat/route.ts +++ b/personas-open-source/src/app/api/chat/route.ts @@ -18,6 +18,7 @@ export async function POST(req: Request) { const { message, botId, conversationHistory } = await req.json(); var chatPrompt; + var isInfluencer = false; if (!botId) return NextResponse.json({ message: "Bad param" }, { status: 400 }); @@ -26,6 +27,7 @@ export async function POST(req: Request) { if (botDoc.exists()) { const bot = botDoc.data(); chatPrompt = bot.chat_prompt; + isInfluencer = bot.is_influencer ?? false; } } catch (error) { console.error('Error fetching bot data:', error); @@ -54,8 +56,15 @@ export async function POST(req: Request) { console.log('Formatted messages:', formattedMessages); + + // LLM model, use a better model for specific people + var llmModel = "google/gemini-flash-1.5-8b"; + if (isInfluencer) { + llmModel = "anthropic/claude-3.5-sonnet"; + } + const stream = await openai.chat.completions.create({ - model: "google/gemini-flash-1.5-8b", + model: llmModel, messages: formattedMessages, stream: true, temperature: 0.8,