GitXplorerGitXplorer
p

langchain-dapr-bindings

public
5 stars
1 forks
0 issues

Commits

List of commits on branch main.
Verified
b0e3269d7caae59e780c5e09377d1a7d0b047647

Initial sketch of implementation, samples, and docs (#1)

pphilliphoff committed 2 years ago
Verified
3ccd73ea5df90d90562b2f6963a645802c8fa807

Initial commit

pphilliphoff committed 2 years ago

README

The README file for this repository.

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