mirror of
https://github.com/PinkSheep27/SBU-Hackathon.git
synced 2026-10-11 00:30:26 -04:00
fix the ai and it should be working
This commit is contained in:
@@ -3,22 +3,13 @@ import { useRef, useEffect } from "react";
|
||||
import { ChatHistory } from "@/app/exportType/types";
|
||||
import { User, Bot } from "lucide-react"
|
||||
|
||||
<<<<<<< HEAD
|
||||
interface MessageWindowProps{
|
||||
history :ChatHistory;
|
||||
isLoading: boolean;
|
||||
}
|
||||
|
||||
export default function MessageWindow({history, isLoading}:MessageWindowProps){
|
||||
const messageEndRef = useRef<HTMLDivVElement>(null);
|
||||
=======
|
||||
interface MessageWindowProps {
|
||||
history: ChatHistory
|
||||
}
|
||||
|
||||
export default function MessageWindow({ history }: MessageWindowProps) {
|
||||
const messageEndRef = useRef<HTMLDivElement>(null);
|
||||
>>>>>>> ce9e6f34ed31b7bff736cc9ba9a1b8dcdec85f3a
|
||||
|
||||
useEffect(() => {
|
||||
messageEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
||||
@@ -59,7 +50,6 @@ export default function MessageWindow({ history }: MessageWindowProps) {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<<<<<<< HEAD
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -79,14 +69,7 @@ export default function MessageWindow({ history }: MessageWindowProps) {
|
||||
)}
|
||||
{/* Invisible element to help scroll to bottom */}
|
||||
<div ref={messageEndRef} />
|
||||
=======
|
||||
);
|
||||
})}
|
||||
|
||||
{/* Invisible element to help scroll to bottom */}
|
||||
<div ref={messageEndRef} />
|
||||
</div>
|
||||
>>>>>>> ce9e6f34ed31b7bff736cc9ba9a1b8dcdec85f3a
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -10,7 +10,6 @@ if (!apiKey) {
|
||||
const genAI = new GoogleGenerativeAI(apiKey);
|
||||
|
||||
export async function chatToGemini(
|
||||
<<<<<<< HEAD
|
||||
userMessage:string ,
|
||||
history:ChatHistory,
|
||||
settings:ChatSetting
|
||||
@@ -26,23 +25,6 @@ export async function chatToGemini(
|
||||
responseMimeType: "text/plain",
|
||||
maxOutputTokens: 1900, // Increased to allow for longer responses
|
||||
}
|
||||
=======
|
||||
userMessage: string,
|
||||
history: ChatHistory,
|
||||
settings: ChatSetting
|
||||
): Promise<string> {
|
||||
const model = genAI.getGenerativeModel({
|
||||
model: settings.model || "gemini-2.5-flash",
|
||||
systemInstruction: settings.sysTemInstructions || "you are going to create a project idea, explain it in summery first before going to detail",
|
||||
});
|
||||
>>>>>>> ce9e6f34ed31b7bff736cc9ba9a1b8dcdec85f3a
|
||||
|
||||
const generationConfig: GenerateConfig = {
|
||||
temperature: settings.temperature || 1,
|
||||
topP: 0.9,
|
||||
responseMimeType: "text/plain",
|
||||
maxOutputTokens: 1900, // Increased to allow for longer responses
|
||||
}
|
||||
|
||||
const chatSession = model.startChat({
|
||||
generationConfig,
|
||||
@@ -53,8 +35,12 @@ export async function chatToGemini(
|
||||
const result = await chatSession.sendMessage(userMessage);
|
||||
return result.response.text();
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error)
|
||||
throw error
|
||||
catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
console.error("Error in chatToGemini:", error.name, error.message, error);
|
||||
} else {
|
||||
console.error("Unknown error in chatToGemini:", error);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user