mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-19 08:42:08 +03:00
315411facd
* style(chat and brains dropdown): remove blank scrollbars and use predefined components * style(chat): use custom scrollbar style by using scrollbar class
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import React from "react";
|
|
|
|
import Card from "@/lib/components/ui/Card";
|
|
|
|
import { ChatMessage } from "./components/ChatMessage";
|
|
import { useChatMessages } from "./hooks/useChatMessages";
|
|
import { useChatContext } from "../../[chatId]/context/ChatContext";
|
|
|
|
export const ChatMessages = (): JSX.Element => {
|
|
const { chatListRef } = useChatMessages();
|
|
const { history } = useChatContext();
|
|
|
|
return (
|
|
<Card
|
|
className="p-5 max-w-3xl w-full flex flex-col mb-8 overflow-y-auto scrollbar"
|
|
ref={chatListRef}
|
|
>
|
|
<div className="flex-1">
|
|
{history.length === 0 ? (
|
|
<div className="text-center opacity-50">
|
|
Ask a question, or describe a task.
|
|
</div>
|
|
) : (
|
|
history.map(({ assistant, message_id, user_message }) => (
|
|
<React.Fragment key={message_id}>
|
|
<ChatMessage
|
|
key={`user-${message_id}`}
|
|
speaker={"user"}
|
|
text={user_message}
|
|
/>
|
|
<ChatMessage
|
|
key={`assistant-${message_id}`}
|
|
speaker={"assistant"}
|
|
text={assistant}
|
|
/>
|
|
</React.Fragment>
|
|
))
|
|
)}
|
|
</div>
|
|
</Card>
|
|
);
|
|
};
|