feature: chatgpt
This commit is contained in:
parent
ded3e57e29
commit
eb48d61dcf
2 changed files with 57 additions and 4 deletions
|
|
@ -11,6 +11,11 @@ export default function ChatLayout() {
|
|||
},
|
||||
]);
|
||||
|
||||
function addMessage(role, content) {
|
||||
const msg = { role, content };
|
||||
setMessages((s) => [...s, msg]);
|
||||
}
|
||||
|
||||
function handleSend(text) {
|
||||
const userMsg = { role: "user", content: text };
|
||||
setMessages((s) => [...s, userMsg]);
|
||||
|
|
@ -31,9 +36,13 @@ export default function ChatLayout() {
|
|||
|
||||
return (
|
||||
<div className="flex flex-col flex-start w-full max-w-3xl gap-4 p-4">
|
||||
<ChatHeader />
|
||||
<ChatHeader />
|
||||
<ChatWindow messages={messages} />
|
||||
<MessageInput onSend={handleSend} onDeleteAll={handleDeleteAll}/>
|
||||
<MessageInput
|
||||
onSend={handleSend}
|
||||
onMessage={addMessage}
|
||||
onDeleteAll={handleDeleteAll}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue