mirror of
https://github.com/PinkSheep27/SBU-Hackathon.git
synced 2026-10-10 23:40:27 -04:00
add default settings for the chat bot to the route.ts file in the api chat folder
This commit is contained in:
@@ -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<ChatSetting>; // 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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user