Build LLM-powered applications using LangChain

This page introduces how to build LLM-powered applications using LangChain. The overviews on this page link to procedure guides in GitHub.

What is LangChain?

LangChain is an LLM orchestration framework that helps developers build generative AI applications or retrieval-augmented generation (RAG) workflows. It provides the structure, tools, and components to streamline complex LLM workflows.

For more information about LangChain, see the Google LangChain page. For more information about the LangChain framework, see the LangChain product documentation.

LangChain components for Datastore mode

Datastore mode offers the following LangChain interfaces:

Learn how to use LangChain with the LangChain Quickstart for Datastore mode.

Document loader for Datastore mode

The document loader saves, loads, and deletes a LangChain Document objects. For example, you can load data for processing into embeddings and either store it in vector store or use it as a tool to provide specific context to chains.

To load documents from document loader in Datastore mode, use the DatastoreLoader class. FirestoreLoader methods return one or more documents from a table. Use the DatastoreSaver class to save and delete documents.

For more information, see the LangChain Document loaders topic.

Document loader procedure guide

The Datastore mode guide for document loader shows you how to do the following:

  • Install the integration package and LangChain
  • Load documents from a table
  • Add a filter to the loader
  • Customize the connection and authentication
  • Customize Document construction by specifying customer content and metadata
  • How to use and customize a DatastoreSaver to store and delete documents

Chat message history for Datastore mode

Question and answer applications require a history of the things said in the conversation to give the application context for answering further questions from the user. The LangChain ChatMessageHistory class lets the application save messages to a database and retrieve them when needed to formulate further answers. A message can be a question, an answer, a statement, a greeting or any other piece of text that the user or application gives during the conversation. ChatMessageHistory stores each message and chains messages together for each conversation.

Datastore mode extends this class with DatastoreChatMessageHistory.

Chat message history procedure guide

The Datastore mode guide for chat message history shows you how to do the following:

  • Install LangChain and authenticate to Google Cloud
  • Create a DatastoreChatMessageHistory object and add messages
  • Use a client to customize the connection and authentication