Firestore is a serverless document-oriented database that scales to meet any demand. Extend your database application to build AI-powered experiences leveraging Firestoreβs Langchain integrations.This notebook goes over how to use Firestore to save, load and delete langchain documents with
FirestoreLoader
and FirestoreSaver
.
Learn more about the package on GitHub.
langchain-google-firestore
package, so we need to install it.
gcloud config list
.gcloud projects list
.FirestoreSaver
can store Documents into Firestore. By default it will try to extract the Document reference from the metadata
Save langchain documents with FirestoreSaver.upsert_documents(<documents>)
.
FirestoreLoader.load()
or Firestore.lazy_load()
. lazy_load
returns a generator that only queries database during the iteration. To initialize FirestoreLoader
class you need to provide:
source
- An instance of a Query, CollectionGroup, DocumentReference or the single \
-delimited path to a Firestore collection.FirestoreSaver.delete_documents(<documents>)
.
If document ids is provided, the Documents will be ignored.
page_content_fields
and metadata_fields
will specify the Firestore Document fields to be written into LangChain Document page_content
and metadata
.
page_content
contains only one field the information will be the field value only. Otherwise the page_content
will be in JSON format.