You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
langchain/templates
Bagatur 480626dc99
docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412)
…tch]: import models from community

ran
```bash
git grep -l 'from langchain\.chat_models' | xargs -L 1 sed -i '' "s/from\ langchain\.chat_models/from\ langchain_community.chat_models/g"
git grep -l 'from langchain\.llms' | xargs -L 1 sed -i '' "s/from\ langchain\.llms/from\ langchain_community.llms/g"
git grep -l 'from langchain\.embeddings' | xargs -L 1 sed -i '' "s/from\ langchain\.embeddings/from\ langchain_community.embeddings/g"
git checkout master libs/langchain/tests/unit_tests/llms
git checkout master libs/langchain/tests/unit_tests/chat_models
git checkout master libs/langchain/tests/unit_tests/embeddings/test_imports.py
make format
cd libs/langchain; make format
cd ../experimental; make format
cd ../core; make format
```
6 months ago
..
anthropic-iterative-search docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
basic-critique-revise docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
bedrock-jcvd docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
cassandra-entomology-rag docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
cassandra-synonym-caching docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
chain-of-note-wiki docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
chat-bot-feedback docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
cohere-librarian docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
csv-agent docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
docs Fix typo (#15202) 6 months ago
elastic-query-generator docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
extraction-anthropic-functions docs[patch], templates[patch]: Import from core (#14575) 7 months ago
extraction-openai-functions docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
guardrails-output-parser docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
hybrid-search-weaviate docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
hyde docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
llama2-functions docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
mongo-parent-document-retrieval docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
neo4j-advanced-rag docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
neo4j-cypher docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
neo4j-cypher-ft docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
neo4j-cypher-memory docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
neo4j-generation docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
neo4j-parent docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
neo4j-vector-memory docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
openai-functions-agent docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
openai-functions-agent-gmail Add image (#14611) 7 months ago
openai-functions-tool-retrieval-agent docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
pii-protected-chatbot docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
pirate-speak docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
pirate-speak-configurable docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
plate-chain docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
propositional-retrieval docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
python-lint docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-astradb docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-aws-bedrock docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-aws-kendra docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-chroma docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-chroma-multi-modal docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-chroma-multi-modal-multi-vector docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-chroma-private docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-codellama-fireworks docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-conversation docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-conversation-zep docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-elasticsearch docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-fusion docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-gemini-multi-modal Update Gemini template README.md (#14993) 7 months ago
rag-google-cloud-sensitive-data-protection docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-google-cloud-vertexai-search docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-gpt-crawler docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-matching-engine docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-momento-vector-index docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-mongo docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-multi-index-fusion docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-multi-index-router docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-multi-modal-local docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-multi-modal-mv-local docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-ollama-multi-query docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-opensearch docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-pinecone docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-pinecone-multi-query docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-pinecone-rerank docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-redis docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-self-query docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-semi-structured docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-singlestoredb docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-supabase docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-timescale-conversation docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-timescale-hybrid-search-time docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-vectara community: Vectara summarization (#14970) 7 months ago
rag-vectara-multiquery docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rag-weaviate docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
research-assistant docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
retrieval-agent docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
rewrite-retrieve-read docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
self-query-qdrant docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
self-query-supabase docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
skeleton-of-thought docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
solo-performance-prompting-agent docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
sql-llama2 docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
sql-llamacpp docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
sql-ollama docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
sql-pgvector docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
sql-research-assistant docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
stepback-qa-prompting docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
summarize-anthropic docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
vertexai-chuck-norris docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
xml-agent docs, community[patch], experimental[patch], langchain[patch], cli[pa… (#15412) 6 months ago
.gitignore Adds linter in templates (#12321) 8 months ago
Makefile core[patch], langchain[patch]: fix required deps (#14373) 7 months ago
README.md docs: Typo in Templates README.md (#14812) 7 months ago
poetry.lock core[patch], langchain[patch]: fix required deps (#14373) 7 months ago
pyproject.toml core[patch], langchain[patch]: fix required deps (#14373) 7 months ago

README.md

LangChain Templates

LangChain Templates are the easiest and fastest way to build a production-ready LLM application. These templates serve as a set of reference architectures for a wide variety of popular LLM use cases. They are all in a standard format which make it easy to deploy them with LangServe.

🚩 We will be releasing a hosted version of LangServe for one-click deployments of LangChain applications. Sign up here to get on the waitlist.

Quick Start

To use, first install the LangChain CLI.

pip install -U langchain-cli

Next, create a new LangChain project:

langchain app 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. In this getting started guide, we will add a simple pirate-speak project. All this project does is convert user input into pirate speak.

langchain app add pirate-speak

This will pull in the specified template into packages/pirate-speak

You will then be prompted if you want to install it. This is the equivalent of running pip install -e packages/pirate-speak. You should generally accept this (or run that same command afterwards). We install it with -e so that if you modify the template at all (which you likely will) the changes are updated.

After that, it will ask you if you want to generate route code for this project. This is code you need to add to your app to start using this chain. If we accept, we will see the following code generated:

from pirate_speak.chain import chain as pirate_speak_chain

add_routes(app, pirate_speak_chain, path="/pirate-speak")

You can now edit the template you pulled down. You can change the code files in packages/pirate-speak to use a different model, different prompt, different logic. Note that the above code snippet always expects the final chain to be importable as from pirate_speak.chain import chain, so you should either keep the structure of the package similar enough to respect that or be prepared to update that code snippet.

Once you have done as much of that as you want, it is In order to have LangServe use this project, you then need to modify app/server.py. Specifically, you should add the above code snippet to app/server.py so that file looks like:

from fastapi import FastAPI
from langserve import add_routes
from pirate_speak.chain import chain as pirate_speak_chain

app = FastAPI()

add_routes(app, pirate_speak_chain, path="/pirate-speak")

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. LangSmith is currently in private beta, you can sign up here. If you don't have access, you can skip this section

export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY=<your-api-key>
export LANGCHAIN_PROJECT=<your-project>  # if not specified, defaults to "default"

For this particular application, we will use OpenAI as the LLM, so we need to export our OpenAI API key:

export OPENAI_API_KEY=sk-...

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

langchain serve

This now gives a fully deployed LangServe application. For example, you get a playground out-of-the-box at http://127.0.0.1:8000/pirate-speak/playground/:

playground.png

Access API documentation at http://127.0.0.1:8000/docs

docs.png

Use the LangServe python or js SDK to interact with the API as if it were a regular Runnable.

from langserve import RemoteRunnable

api = RemoteRunnable("http://127.0.0.1:8000/pirate-speak")
api.invoke({"text": "hi"})

That's it for the quick start! You have successfully downloaded your first template and deployed it with LangServe.

Additional Resources

Index of Templates

Explore the many templates available to use - from advanced RAG to agents.

Contributing

Want to contribute your own template? It's pretty easy! These instructions walk through how to do that.

Launching LangServe from a Package

You can also launch LangServe from a package directly (without having to create a new project). These instructions cover how to do that.