-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: chat and messaging with openai 4o llm implementation #27
Conversation
bdabd97
to
751634d
Compare
Going to secure the code real quick, we need protected routes to avoid exposing resources to non-OSU students |
@Nyumat out of curiosity, are we storing the document chunks and the embeddings in a SQL database as well as in pinecone? |
Good question. I initially was thinking that if we store our chunks, and embeddings as vectors alongside our core data model, we'd have a tighter integration for more complex use cases, like those outlined in the planning doc from week 2: Some of the stuff in the doc:
But after thinking about the work you did, along with just how complex it'd be to hack prisma into supporting vectors — I think it's best centering our RAG approach around Pinecone. I'll update the data model to go back to what is was before. Thanks for asking that question and providing me some retrospective. |
Yeah no problem, Im not against storing the documents in a second db. it would allow us to easily upload the document to pinecone if they are already broken into chunks, and it would be a backup incase something happened to the vector db or we wanted to switch platforms. Ill try to take a look over the weekend at the updated UI you built and look into integrating the embeddings into sending messages. I looked at the UI from the last push and it looks great! |
new tables and extensions to the database, updating dependencies, and implementing new chat-related features in the backend and frontend. lfg. 🗣️
Database Schema Updates:
chats
,messages
,document_chunks
, andembeddings
along with necessary foreign key constraints inprisma/migrations/20241106184235_chats_messages/migration.sql
.prisma/schema.prisma
to include new models and extensions forvector
.Dependencies Updates:
package.json
to add new dependencies like@ai-sdk/openai
,@langchain/core
,pgvector
, and others.Configuration Changes:
docker-compose.yml
to useankane/pgvector:latest
image and added a new volume for initialization scripts.next.config.ts
to includeapi.dicebear.com
in theimages.domains
list.Backend Features:
src/app/api/chat/route.ts
for handling chat messages, including user authentication, message processing, and interaction with OpenAI's 4o model.Note
This is just the first step in implementation. We still need to integrate the pinecone vector db work done in (#19) into the system.
It will take some query, compare the embedding to all course material documents, and return the K=1 most relevant document to the LLM, which will stream the response to the Next.js client.
Frontend Features:
ChatArea
component insrc/app/chat/(render)/chat-area.tsx
to handle chat UI, message input, and image attachments.