pinecone-io / pinecone-vercel-starter

Pinecone + Vercel AI SDK Starter
https://pinecone-vercel-example.vercel.app
418 stars 127 forks source link

Support for Chat History? #8

Open JacobGoldenArt opened 1 year ago

JacobGoldenArt commented 1 year ago

Is this your first time submitting a feature request?

Describe the feature

Thanks for the really nice tutorial. I was just wondering how we might add a chat history feature. I'm not sure if this would be stored in Pinecone or maybe a vercel database?

Describe alternatives you've considered

No response

Who will this benefit?

No response

Are you interested in contributing this feature?

No response

Anything else?

No response

zackproser commented 1 year ago

Hi Jacob,

Thanks for the feedback and great idea - I think this would be helpful for others as well, certainly. There's also a number of ways to implement chat history via tools like LangChain and others - I'll discuss this with the team :+1:

athrael-soju commented 1 year ago

@JacobGoldenArt as @zackproser suggests Langchain has a pretty good toolkit to do this and it can also be done in a more 'raw' fashion too.

If we retrieve the vector id for each upsert of our chat and insert a new chat record with that id in something like mongoDB atlas (or any db really), then we can use the returning matching topN rows from the db to further reinforce RAG precision and provide chat history.

An alternative is to use combined memory classes with Langchain: https://js.langchain.com/docs/modules/memory/how_to/multiple_memory

The only setbacks are response times and cost for each call to the openAI, which can be bigger if you include a large historical data set from your db.