Skip to content

philliphoff/langchain-dapr-bindings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

langchain-dapr-bindings

A sample integrating Dapr AI bindings with langchain.

Background

langchain already has integrations for many different language models, so why is this needed? Each of those integrations requires very specific choices being made at application implementation time--which models to support and how to configure them--as well as imposes a set of dependencies on the application for each supported model.

With Dapr, the application can use langchain but in a way that allows those decisions to be made at deployment time, through configuration, without any changes to application code and does not impose model-specific dependencies on the application (aside from the Dapr langchain binding and Dapr Client SDK itself).

Architecture

This sample creates several custom implementations of the langchain language model and memory classes, which redirect their calls to one of the Dapr output bindings in the dapr-ai-bindings sample, or to a standard Dapr state store in the case of the memory implementation.

Architecture Diagram

Prerequisites

Using the bindings

This bindings package has not yet been published.

  1. Install the Dapr AI bindings

    pip3 install daprai
  2. In your Python module, import the types as needed

    from daprai.langchain import (
       # A chat-based LLM that uses Dapr AI bindings
       ChatDaprAI
    
       # A completion-based LLM that uses Dapr AI bindings
       DaprAI
    
       # A memory component that uses Dapr state stores
       DaprMemory
    )

Examples

This repo contains several examples of integrating Dapr with langchain.

Example Description
DaprAI LLM An example of using the Dapr AI bindings as language models in langchain.
DaprAI Chat LLM An example of using the Dapr AI bindings as chat language models in langchain.
DaprAI Memory An example of using Dapr state stores as chat history memory in langchain.

Developing

  1. Install the project in an editable mode

    pip3 install -e .
  2. Install required packages

    pip3 install -r requirements.txt
  3. Run one of the examples

About

A sample integrating Dapr AI bindings with langchain.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages