langchain/templates
Tyler Hutcherson 4209457bdc
Redis langserve template (#12443)
Add Redis langserve template! Eventually will add semantic caching to
this too. But I was struggling to get that to work for some reason with
the LCEL implementation here.

- **Description:** Introduces the Redis LangServe template. A simple RAG
based app built on top of Redis that allows you to chat with company's
public financial data (Edgar 10k filings)
  - **Issue:** None
- **Dependencies:** The template contains the poetry project
requirements to run this template
  - **Tag maintainer:** @baskaryan @Spartee 
  - **Twitter handle:** @tchutch94

**Note**: this requires the commit here that deletes the
`_aget_relevant_documents()` method from the Redis retriever class that
wasn't implemented. That was breaking the langserve app.

---------

Co-authored-by: Sam Partee <sam.partee@redis.com>
2023-10-28 08:31:12 -07:00
..
anthropic-functions Templates (#12294) 2023-10-25 18:47:42 -07:00
anthropic-iterative-search Format Templates (#12396) 2023-10-26 19:44:30 -07:00
cassandra-entomology-rag Format Templates (#12396) 2023-10-26 19:44:30 -07:00
cassandra-synonym-caching Format Templates (#12396) 2023-10-26 19:44:30 -07:00
csv-agent Format Templates (#12396) 2023-10-26 19:44:30 -07:00
elastic-query-generator Format Templates (#12396) 2023-10-26 19:44:30 -07:00
extraction-openai-functions Fix templates typos (#12428) 2023-10-27 09:32:57 -07:00
hyde Format Templates (#12396) 2023-10-26 19:44:30 -07:00
llama2-functions Add invoke example to LLaMA2 function template notebook (#12437) 2023-10-27 10:58:24 -07:00
neo4j-cypher Format Templates (#12396) 2023-10-26 19:44:30 -07:00
neo4j-cypher-ft Format Templates (#12396) 2023-10-26 19:44:30 -07:00
neo4j-generation Format Templates (#12396) 2023-10-26 19:44:30 -07:00
neo4j-parent Format Templates (#12396) 2023-10-26 19:44:30 -07:00
openai-functions-agent Format Templates (#12396) 2023-10-26 19:44:30 -07:00
rag-aws-bedrock Updated the Bedrock rag template (#12462) 2023-10-27 17:02:28 -07:00
rag-chroma Clean-up template READMEs (#12403) 2023-10-26 22:23:03 -07:00
rag-chroma-private AWS Bedrock RAG template (#12450) 2023-10-27 13:15:54 -07:00
rag-conversation Clean-up template READMEs (#12403) 2023-10-26 22:23:03 -07:00
rag-elasticsearch Format Templates (#12396) 2023-10-26 19:44:30 -07:00
rag-fusion Format Templates (#12396) 2023-10-26 19:44:30 -07:00
rag-pinecone AWS Bedrock RAG template (#12450) 2023-10-27 13:15:54 -07:00
rag-pinecone-multi-query AWS Bedrock RAG template (#12450) 2023-10-27 13:15:54 -07:00
rag-pinecone-rerank Format Templates (#12396) 2023-10-26 19:44:30 -07:00
rag-redis Redis langserve template (#12443) 2023-10-28 08:31:12 -07:00
rag-semi-structured Format Templates (#12396) 2023-10-26 19:44:30 -07:00
rag-supabase Format Templates (#12396) 2023-10-26 19:44:30 -07:00
rag-weaviate Add Weaviate RAG template (#12460) 2023-10-27 15:19:34 -07:00
rewrite-retrieve-read Format Templates (#12396) 2023-10-26 19:44:30 -07:00
self-query-supabase Format Templates (#12396) 2023-10-26 19:44:30 -07:00
sql-llama2 Update SQL templates (#12464) 2023-10-27 16:34:37 -07:00
sql-llamacpp Update llama.cpp and Ollama templates (#12466) 2023-10-27 16:54:54 -07:00
sql-ollama Update llama.cpp and Ollama templates (#12466) 2023-10-27 16:54:54 -07:00
stepback-qa-prompting Format Templates (#12396) 2023-10-26 19:44:30 -07:00
summarize-anthropic Clean-up template READMEs (#12403) 2023-10-26 22:23:03 -07:00
xml-agent Format Templates (#12396) 2023-10-26 19:44:30 -07:00
.gitignore Adds linter in templates (#12321) 2023-10-26 13:55:07 -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
Makefile Format Templates (#12396) 2023-10-26 19:44:30 -07:00
poetry.lock Format Templates (#12396) 2023-10-26 19:44:30 -07:00
pyproject.toml Format Templates (#12396) 2023-10-26 19:44:30 -07:00
README.md cli updates 2 (#12447) 2023-10-27 13:37:03 -07:00

LangServe Templates

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

Some other helpful docs:

  • [Templates]

Usage

To use, first install the LangChain CLI.

pip install -U "langchain-cli[serve]"

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 you modify the template at all (which you 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:

langchain start

Adding a template

See here