feat(file input): adding feature to add and remove files

Next up is to create a seperate menu that will show all the files.
Probably as a seperate frame. Needs to be scrollable and can use similar
ui as before
This commit is contained in:
JK-le-dev 2025-10-19 04:32:32 -05:00
commit 7785047976
11 changed files with 182 additions and 48 deletions

View file

@ -3,20 +3,6 @@ import ChatHeader from "src/components/ui/chat/chat-header";
import ChatWindow from "src/components/ui/chat/chat-window";
import MessageInput from "src/components/ui/chat/message-input";
import { GoogleGenAI } from "@google/genai"
const ai = new GoogleGenAI({ apiKey: import.meta.env.GEMINI_API_KEY })
async function AIRepsponse(userInputArray) {
const response = await ai.models.generateContent({
model: "gemini-2.5-flash",
contents: userInputArray
})
return response.text
}
let userInput = []
export default function ChatLayout() {
const [messages, setMessages] = useState([
{
@ -25,23 +11,21 @@ export default function ChatLayout() {
},
]);
async function handleSend(text) {
userInput.push(text)
const res = await AIRepsponse(userInput)
function handleSend(text) {
const userMsg = { role: "user", content: text };
setMessages((s) => [...s, userMsg]);
// fake assistant reply after short delay
setTimeout(() => {
setMessages((s) => [
...s,
{ role: "assistant", content: res },
{ role: "assistant", content: `You said: ${text}` },
]);
}, 600);
}
return (
<div className="w-full max-w-4xl gap-4 p-4">
<div className="flex flex-col flex-start w-full max-w-3xl gap-4 p-4">
<ChatHeader />
<ChatWindow messages={messages} />
<MessageInput onSend={handleSend} />