mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-19 08:42:08 +03:00
4112699db5
* ♻️ refactor backend main routes * 🗃️ new user_id uuid column in users table * 🗃️ new chats table * ✨ new chat endpoints * ✨ change chat routes post to handle undef chat_id * ♻️ extract components from chat page * ✨ add chatId to useQuestion * ✨ new ChatsList * ✨ new optional dynamic route chat/{chat_id} * 🩹 add setQuestion to speach utils * feat: self supplied key (#286) * feat(brain): increased size if api key and more * fix(key): not displayed * feat(apikey): now password input * fix(twitter): handle wrong * feat(chat): basic source documents support (#289) * ♻️ refactor backend main routes * 🗃️ new user_id uuid column in users table * 🗃️ new chats table * ✨ new chat endpoints * ✨ change chat routes post to handle undef chat_id * ♻️ extract components from chat page * ✨ add chatId to useQuestion * ✨ new ChatsList * ✨ new optional dynamic route chat/{chat_id} * 🩹 add setQuestion to speach utils * 🎨 separate creation and update endpoints for chat * 🩹 add feat(chat): basic source documents support * ✨ add chatName upon creation and for chats list * 💄 improve chatsList style * User chat history and multiple chats (#290) * ♻️ refactor backend main routes * 🗃️ new user_id uuid column in users table * 🗃️ new chats table * ✨ new chat endpoints * ✨ change chat routes post to handle undef chat_id * ♻️ extract components from chat page * ✨ add chatId to useQuestion * ✨ new ChatsList * ✨ new optional dynamic route chat/{chat_id} * refactor(chat): use layout to avoid refetching all chats on every chat * refactor(chat): useChats hook instead of useQuestion * fix(chat): fix errors * refactor(chat): better folder structure * feat: self supplied key (#286) * feat(brain): increased size if api key and more * fix(key): not displayed * feat(apikey): now password input * fix(twitter): handle wrong * feat(chat): basic source documents support (#289) * style(chat): better looking sidebar * resume merge * fix(backend): add os and logger imports * small fixes * chore(chat): remove empty interface * chore(chat): use const * fix(chat): merge errors * fix(chat): remove useSpeech args * chore(chat): remove unused args * fix(chat): remove duplicate components --------- Co-authored-by: gozineb <zinebe@theodo.fr> Co-authored-by: Matt <77928207+mattzcarey@users.noreply.github.com> Co-authored-by: Stan Girard <girard.stanislas@gmail.com> Co-authored-by: xleven <xleven@outlook.com> * fix and refactor errors * fix(fresh): installation issues * chore(conflict): merged old code * fix(multi-chat): use update endpoint * feat(embeddings): now using users api key --------- Co-authored-by: Matt <77928207+mattzcarey@users.noreply.github.com> Co-authored-by: Stan Girard <girard.stanislas@gmail.com> Co-authored-by: xleven <xleven@outlook.com> Co-authored-by: Aditya Nandan <61308761+iMADi-ARCH@users.noreply.github.com> Co-authored-by: iMADi-ARCH <nandanaditya985@gmail.com> Co-authored-by: Mamadou DICKO <mamadoudicko100@gmail.com>
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
"use client";
|
|
import Card from "@/app/components/ui/Card";
|
|
import { AnimatePresence } from "framer-motion";
|
|
import { useEffect, useRef } from "react";
|
|
import { Chat } from "../../types";
|
|
import ChatMessage from "./ChatMessage";
|
|
|
|
interface ChatMessagesProps {
|
|
chat: Chat;
|
|
}
|
|
|
|
export const ChatMessages = ({ chat }: ChatMessagesProps): JSX.Element => {
|
|
const lastChatRef = useRef<HTMLDivElement | null>(null);
|
|
|
|
useEffect(() => {
|
|
lastChatRef.current?.scrollIntoView({ behavior: "auto", block: "start" });
|
|
}, [chat]);
|
|
|
|
return (
|
|
<Card className="p-5 max-w-3xl w-full flex-1 flex flex-col mb-8">
|
|
<div className="">
|
|
{chat.history.length === 0 ? (
|
|
<div className="text-center opacity-50">
|
|
Ask a question, or describe a task.
|
|
</div>
|
|
) : (
|
|
<AnimatePresence initial={false}>
|
|
{chat.history.map(([speaker, text], idx) => {
|
|
return (
|
|
<ChatMessage
|
|
ref={idx === chat.history.length - 1 ? lastChatRef : null}
|
|
key={idx}
|
|
speaker={speaker}
|
|
text={text}
|
|
/>
|
|
);
|
|
})}
|
|
</AnimatePresence>
|
|
)}
|
|
</div>
|
|
</Card>
|
|
);
|
|
};
|
|
export default ChatMessages;
|