langchain/templates
2023-10-26 10:12:23 -07:00
..
anthropic-functions Templates (#12294) 2023-10-25 18:47:42 -07:00
anthropic-iterative-search Templates (#12294) 2023-10-25 18:47:42 -07:00
cassandra-entomology-rag Templates (#12294) 2023-10-25 18:47:42 -07:00
cassandra-synonym-caching Templates (#12294) 2023-10-25 18:47:42 -07:00
csv-agent Templates (#12294) 2023-10-25 18:47:42 -07:00
elastic-query-generator Templates (#12294) 2023-10-25 18:47:42 -07:00
extraction-openai-functions Templates (#12294) 2023-10-25 18:47:42 -07:00
neo4j-cypher Templates (#12294) 2023-10-25 18:47:42 -07:00
neo4j-cypher-ft Templates (#12294) 2023-10-25 18:47:42 -07:00
neo4j-generation Templates (#12294) 2023-10-25 18:47:42 -07:00
neo4j-parent Templates (#12294) 2023-10-25 18:47:42 -07:00
openai-functions-agent Templates (#12294) 2023-10-25 18:47:42 -07:00
rag-chroma Templates (#12294) 2023-10-25 18:47:42 -07:00
rag-chroma-private Templates (#12294) 2023-10-25 18:47:42 -07:00
rag-conversation Add template for Pinecone + Multi-Query (#12353) 2023-10-26 10:12:23 -07:00
rag-elasticsearch Templates (#12294) 2023-10-25 18:47:42 -07:00
rag-fusion Templates (#12294) 2023-10-25 18:47:42 -07:00
rag-pinecone Add template for Pinecone + Multi-Query (#12353) 2023-10-26 10:12:23 -07:00
rag-pinecone-multi-query Add template for Pinecone + Multi-Query (#12353) 2023-10-26 10:12:23 -07:00
rag-semi-structured Templates (#12294) 2023-10-25 18:47:42 -07:00
rag-supabase Templates (#12294) 2023-10-25 18:47:42 -07:00
rewrite-retrieve-read Templates (#12294) 2023-10-25 18:47:42 -07:00
self-query-supabase Templates (#12294) 2023-10-25 18:47:42 -07:00
sql-llama2 Templates (#12294) 2023-10-25 18:47:42 -07:00
sql-llamacpp Templates (#12294) 2023-10-25 18:47:42 -07:00
sql-ollama Templates (#12294) 2023-10-25 18:47:42 -07:00
stepback-qa-prompting Templates (#12294) 2023-10-25 18:47:42 -07:00
summarize-anthropic Templates (#12294) 2023-10-25 18:47:42 -07:00
xml-agent Templates (#12294) 2023-10-25 18:47:42 -07:00
.gitignore Templates (#12294) 2023-10-25 18:47:42 -07:00
CONTRIBUTING.md add docs for templates (#12346) 2023-10-26 08:28:01 -07:00
INDEX.md add docs for templates (#12346) 2023-10-26 08:28:01 -07:00
README.md add docs for templates (#12346) 2023-10-26 08:28:01 -07:00

LangServe Templates

Templates for a fully functioning app that can be hosted by LangServe.

Usage

To use, first install the LangChain CLI.

pip install -U langchain-cli

Then, install langserve:

pip install "langserve[all]"

Next, create a new LangChain project:

langchain serve new my-app

This will create a new directory called my-app with two folders:

  • app: This is where LangServe code will live
  • packages: This is where your chains or agents will live

To pull in an existing template as a package, you first need to go into your new project:

cd my-app

And you can the add a template as a project

langchain serve add $PROJECT_NAME

This will pull in the specified template into packages/$PROJECT_NAME

You then need to install this package so you can use it in the langserve app:

pip install -e packages/$PROJECT_NAME

We install it with -e so that if we modify the template at all (which we likely will) the changes are updated.

In order to have LangServe use this project, you then need to modify app/server.py. Specifically, you should add something like:

from fastapi import FastAPI
from langserve import add_routes
# This depends on the structure of the package you install
from my_project import chain

app = FastAPI()

add_routes(app, chain)

You can then spin up production-ready endpoints, along with a playground, by running:

python app/server.py

Adding a template

See here