Skip to content
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(Firestore): Add support for FirestoreChatMessageHistory (#60) #171

Open
wants to merge 252 commits into
base: main
Choose a base branch
from

Conversation

KennethKnudsen97
Copy link

@KennethKnudsen97 KennethKnudsen97 commented Oct 6, 2023

  • Description: This adds support for Firestore chat message history. With this feature, you can use firestore as the memory for your AI agent.

  • Issue: Resolves Add support for FirestoreChatMessageHistory #60 .

  • Create example on how to use Firestore chat message history

  • Fill out TODO in Readme.md

@davidmigloz
Copy link
Owner

Hey @KennethKnudsen97, thank you very much for the PR!
I'll review it this weekend.

@davidmigloz
Copy link
Owner

Hey @KennethKnudsen97,

I reviewed the PR and added some comments, take a look at them and let me know if they make sense to you.
Thanks for your work again!

@mdshihabuddinroky
Copy link

did you add a retrieval parameter to add retrieval?

@davidmigloz
Copy link
Owner

hey @mdshihabuddinroky,

Can you explain more about what you mean?

@KennethKnudsen97
Copy link
Author

Made a huge mess syncing my branch, so i had to do some clean up..
Its my first time forking a project, so i will learn :D

@davidmigloz
Copy link
Owner

No worries! Let me know if you need help 🙂

@KennethKnudsen97
Copy link
Author

I finally got some time to change the arguments for FirestoreChatMessageHistory.
Now they take in a collection string which can be a nested collection as well.
I use it in my program like this.

var user = Auth().currentUser!.uid;
   history = FirestoreChatMessageHistory(
     collections: "Users/$user/Langchain",
     options: widget.firebaseOptions,
     userId: user,
   );

Because we pass in firebaseoptions we now have to initialize firebase.
by calling:
history.ensureFirestore();

I also added a userId field in the argument, so that every message created has a userId.

What do you think about that @davidmigloz

@davidmigloz
Copy link
Owner

Hey @KennethKnudsen97!

Sorry for the late response.. and thanks again for your work 🙂

The new arguments look good. I would remove the Firebase App initialization to the user (similar to how ChatFirebaseVertexAI does), in that way we don't need the ensureFirestore method.

As you may have seen, we now have a specific langchain_firebase package, so we should move this code to that package.

I have on my list to rework how memory integrates with LCEL, so it'd great to finally release this together with that.

davidmigloz and others added 29 commits October 1, 2024 20:24
 - langchain@0.7.5
 - langchain_community@0.3.1
 - langchain_core@0.3.5
 - langchain_google@0.6.2
 - langchain_mistralai@0.2.3
 - langchain_ollama@0.3.1
 - langchain_openai@0.7.1
 - ollama_dart@0.2.1
 - openai_dart@0.4.1
 - langchain_firebase@0.2.1+1
 - langchain_supabase@0.1.1+2
 - langchain_pinecone@0.1.0+8
 - langchain_anthropic@0.1.1+1
 - langchain_chroma@0.2.1+2
Bumps [bluefireteam/melos-action](https://github.com/bluefireteam/melos-action) from 6085791af7036f6366c9a4b9d55105c0ef9c6388 to 7e70fbe34bbd91a75eb505eeb4174b0ac9a1df52.
- [Release notes](https://github.com/bluefireteam/melos-action/releases)
- [Commits](bluefireteam/melos-action@6085791...7e70fbe)

---
updated-dependencies:
- dependency-name: bluefireteam/melos-action
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Miguel <me@davidmiguel.com>
Co-authored-by: Douglas Bett <bettdalpha@gmail.com>
…dates (davidmigloz#547)

Bumps the npm_and_yarn group with 4 updates in the /docs_v2 directory: [body-parser](https://github.com/expressjs/body-parser), [express](https://github.com/expressjs/express), [micromatch](https://github.com/micromatch/micromatch) and [webpack](https://github.com/webpack/webpack).


Updates `body-parser` from 1.20.2 to 1.20.3
- [Release notes](https://github.com/expressjs/body-parser/releases)
- [Changelog](https://github.com/expressjs/body-parser/blob/master/HISTORY.md)
- [Commits](expressjs/body-parser@1.20.2...1.20.3)

Updates `express` from 4.19.2 to 4.21.0
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/4.21.0/History.md)
- [Commits](expressjs/express@4.19.2...4.21.0)

Updates `express` from 4.19.2 to 4.21.0
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/4.21.0/History.md)
- [Commits](expressjs/express@4.19.2...4.21.0)

Updates `path-to-regexp` from 0.1.7 to 0.1.10
- [Release notes](https://github.com/pillarjs/path-to-regexp/releases)
- [Changelog](https://github.com/pillarjs/path-to-regexp/blob/master/History.md)
- [Commits](pillarjs/path-to-regexp@v0.1.7...v0.1.10)

Updates `micromatch` from 4.0.7 to 4.0.8
- [Release notes](https://github.com/micromatch/micromatch/releases)
- [Changelog](https://github.com/micromatch/micromatch/blob/master/CHANGELOG.md)
- [Commits](micromatch/micromatch@4.0.7...4.0.8)

Updates `send` from 0.18.0 to 0.19.0
- [Release notes](https://github.com/pillarjs/send/releases)
- [Changelog](https://github.com/pillarjs/send/blob/master/HISTORY.md)
- [Commits](pillarjs/send@0.18.0...0.19.0)

Updates `serve-static` from 1.15.0 to 1.16.2
- [Release notes](https://github.com/expressjs/serve-static/releases)
- [Changelog](https://github.com/expressjs/serve-static/blob/v1.16.2/HISTORY.md)
- [Commits](expressjs/serve-static@v1.15.0...v1.16.2)

Updates `webpack` from 5.92.1 to 5.94.0
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](webpack/webpack@v5.92.1...v5.94.0)

---
updated-dependencies:
- dependency-name: body-parser
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: express
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: express
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: path-to-regexp
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: micromatch
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: send
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: serve-static
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: webpack
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [bluefireteam/melos-action](https://github.com/bluefireteam/melos-action) from 7e70fbe34bbd91a75eb505eeb4174b0ac9a1df52 to c7dcb921b23cc520cace360b95d02b37bf09cdaa.
- [Release notes](https://github.com/bluefireteam/melos-action/releases)
- [Commits](bluefireteam/melos-action@7e70fbe...c7dcb92)

---
updated-dependencies:
- dependency-name: bluefireteam/melos-action
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
 - langchain@0.7.6
 - langchain_community@0.3.2
 - langchain_core@0.3.6
 - langchain_firebase@0.2.1+2
 - langchain_google@0.6.3
 - langchain_ollama@0.3.2
 - langchain_openai@0.7.2
 - ollama_dart@0.2.2
 - openai_dart@0.4.2
 - langchain_supabase@0.1.1+3
 - langchain_pinecone@0.1.0+9
 - langchain_anthropic@0.1.1+2
 - langchain_chroma@0.2.1+3
 - langchain_mistralai@0.2.3+1
 - vertex_ai@0.1.0+2
 - langchain_google@0.6.3+1
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.7 to 4.2.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@692973e...d632683)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📆 Planned
Development

Successfully merging this pull request may close these issues.

Add support for FirestoreChatMessageHistory
7 participants