Spaces:
Runtime error
Runtime error
File size: 1,658 Bytes
0971cc4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
import React from "react";
import { ChatRequestOptions } from "ai";
import { Message } from "ai/react";
import ChatBottombar from "./chat-bottombar";
import ChatList from "./chat-list";
import { ChatOptions } from "./chat-options";
import ChatTopbar from "./chat-topbar";
export interface ChatProps {
chatId?: string;
setChatId: React.Dispatch<React.SetStateAction<string>>;
messages: Message[];
input: string;
handleInputChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
handleSubmit: (
e: React.FormEvent<HTMLFormElement>,
chatRequestOptions?: ChatRequestOptions
) => void;
isLoading: boolean;
error: undefined | Error;
stop: () => void;
}
export interface ChatTopbarProps {
chatOptions: ChatOptions;
setChatOptions: React.Dispatch<React.SetStateAction<ChatOptions>>;
}
export default function Chat({
messages,
input,
handleInputChange,
handleSubmit,
isLoading,
error,
stop,
chatOptions,
setChatOptions,
chatId,
setChatId,
}: ChatProps & ChatTopbarProps) {
return (
<div className="flex flex-col justify-between w-full h-full ">
<ChatTopbar
chatOptions={chatOptions}
setChatOptions={setChatOptions}
isLoading={isLoading}
chatId={chatId}
setChatId={setChatId}
messages={messages}
/>
<ChatList
messages={messages}
isLoading={isLoading}
/>
<ChatBottombar
selectedModel={chatOptions.selectedModel}
input={input}
handleInputChange={handleInputChange}
handleSubmit={handleSubmit}
isLoading={isLoading}
stop={stop}
/>
</div>
);
}
|