langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
93.05k stars 14.95k forks source link

Cloud Firestore Chat Message History #8906

Closed marcoberlot1 closed 10 months ago

marcoberlot1 commented 1 year ago

Feature request

Implement a Chat Message History class backed up by Google Cloud Firestore.

Motivation

It's a common No-SQL database, used by a lot of people to build MVPs, due to its friendly pricing.

Your contribution

I'd submit a PR to implement this, if you guys think that it could be a helpful feature

dosubot[bot] commented 1 year ago

Answer generated by a 🤖

Answer

That's a great idea! Implementing a Chat Message History class backed up by Google Cloud Firestore would definitely be a valuable addition to LangChain. It's a popular database choice and would provide users with more flexibility in building their applications.

I encourage you to go ahead and submit a pull request to implement this feature. The maintainers will review your contribution and determine if it aligns with the project's goals and requirements. Thank you for your willingness to contribute to LangChain!


This response is meant to be useful, save you time, and share context. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

wnmurphy commented 1 year ago

This exists already, try:

# Instantiate, passing your own FS client instance if you like
chat_history_obj = FirestoreChatMessageHistory(
    firestore_client=firestore_client,
    collection_name="FirestoreCollectionName",
    user_id=some_user_id,
)

# Add Firestore history to memory
main_memory = ConversationBufferMemory(
    memory_key="chat_history",
    chat_memory=chat_history_obj,
    return_messages=True,
)

# Use in your chain
default_chain = ConversationChain(
    llm=chat_model,
    prompt=default_chat_prompt,
    memory=main_memory,
    verbose=settings.CHAIN_VERBOSITY,
    output_key="text",
)
dosubot[bot] commented 11 months ago

Hi, @marcoberlot1! I'm Dosu, and I'm helping the LangChain team manage our backlog. I wanted to let you know that we are marking this issue as stale.

Based on my understanding, you requested the implementation of a Chat Message History class backed up by Google Cloud Firestore. I responded, stating that it would be a valuable addition to the project and encouraged you to submit a pull request. wnmurphy then commented that a similar feature already exists and provided code examples, which received positive reactions from josseed, jashshah, and olegdater.

Before we close this issue, we wanted to check if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself or it will be automatically closed in 7 days.

Thank you for your contribution and I look forward to hearing from you soon!