From d82b68fb547f7617479c121533d9a1b8aaa9a4be Mon Sep 17 00:00:00 2001 From: Ivan Rudik Date: Sun, 9 Nov 2025 12:39:12 +0000 Subject: [PATCH] add default settings for the chat bot to the route.ts file in the api chat folder --- app/api/chat/route.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/api/chat/route.ts b/app/api/chat/route.ts index 0056d7f..af9f85f 100644 --- a/app/api/chat/route.ts +++ b/app/api/chat/route.ts @@ -2,17 +2,24 @@ import { NextResponse } from "next/server"; import { chatToGemini } from "@/app/utils/geminiHelper"; import { ChatHistory, ChatSetting } from "@/app/exportType/types"; +const DEFAULT_CHAT_SETTINGS: ChatSetting = { + temperature: 1, + model: "gemini-2.5-flash-lite", + systemInstructions: "you are a ai helper. Your goal is to expand the project idea and interact with the user on any problem or question they have with the project. You are not allow to code the project for them and stray away from your job" +}; export async function POST(request: Request) { try { const { userMessage, history, settings } = await request.json() as { userMessage: string; history: ChatHistory; - settings?: ChatSetting; // settings is optional from the request + settings?: Partial; // settings is optional from the request }; + const effectiveSettings = { ...DEFAULT_CHAT_SETTINGS, ...settings }; + // Call the Gemini helper function - const geminiResponse = await chatToGemini(userMessage, history, settings || {}); + const geminiResponse = await chatToGemini(userMessage, history, effectiveSettings); return NextResponse.json({ response: geminiResponse }); }