langchain/templates
juan-calvo-datatonic 6137894008
templates[minor]: Add rag google sensitive data protection template (#13921)
This is a template demonstrating how to utilize Google Sensitive Data
Protection in conjunction with ChatVertexAI(). Tagging you @efriis as
you reviewed my last template. :) Thanks!

Proof of successful execution: 

![image](https://github.com/langchain-ai/langchain/assets/82172964/e4d678aa-85c8-482b-b09d-81fe7e912dd4)

---------

Co-authored-by: Erick Friis <erick@langchain.dev>
2023-11-28 15:15:58 -08:00
..
anthropic-iterative-search TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
basic-critique-revise TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
cassandra-entomology-rag TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
cassandra-synonym-caching TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
chain-of-note-wiki TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
chat-bot-feedback DOCS: Fix typo/line break in python code (#13708) 2023-11-22 09:10:07 -08:00
csv-agent TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
docs Add mongo parent template to index (#13222) 2023-11-10 11:56:44 -08:00
elastic-query-generator TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
extraction-anthropic-functions TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
extraction-openai-functions TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
guardrails-output-parser TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
hybrid-search-weaviate TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
hyde TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
llama2-functions TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
mongo-parent-document-retrieval TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
neo4j-advanced-rag TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
neo4j-cypher Add Cypher template diagrams (#13913) 2023-11-27 10:18:51 -05:00
neo4j-cypher-ft Add Cypher template diagrams (#13913) 2023-11-27 10:18:51 -05:00
neo4j-cypher-memory Add Cypher template diagrams (#13913) 2023-11-27 10:18:51 -05:00
neo4j-generation TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
neo4j-parent TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
neo4j-vector-memory TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
openai-functions-agent TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
openai-functions-tool-retrieval-agent TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
pii-protected-chatbot TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
pirate-speak TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
pirate-speak-configurable TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
plate-chain TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-astradb TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-aws-bedrock TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-aws-kendra TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-chroma TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-chroma-private TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-codellama-fireworks TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-conversation TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-conversation-zep TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-elasticsearch TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-fusion TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-google-cloud-sensitive-data-protection templates[minor]: Add rag google sensitive data protection template (#13921) 2023-11-28 15:15:58 -08:00
rag-google-cloud-vertexai-search templates[minor]: Add rag google sensitive data protection template (#13921) 2023-11-28 15:15:58 -08:00
rag-gpt-crawler TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-matching-engine TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-momento-vector-index TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-mongo TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-multi-index-fusion TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-multi-index-router TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-opensearch TEMPLATES Add rag-opensearch template (#13501) 2023-11-27 16:21:39 -05:00
rag-pinecone TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-pinecone-multi-query TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-pinecone-rerank TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-redis TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-self-query TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-semi-structured TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-singlestoredb TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-supabase TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-timescale-conversation TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-timescale-hybrid-search-time TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-vectara TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-vectara-multiquery TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rag-weaviate TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
research-assistant TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
retrieval-agent TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
rewrite-retrieve-read TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
self-query-qdrant IMPROVEMENT Allow openai v1 in all templates that require it (#13489) 2023-11-16 17:10:08 -08:00
self-query-supabase TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
skeleton-of-thought add skeleton of thought (#13883) 2023-11-26 19:31:41 -05:00
solo-performance-prompting-agent TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
sql-llama2 TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
sql-llamacpp TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
sql-ollama TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
sql-pgvector TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
stepback-qa-prompting TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
summarize-anthropic TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
vertexai-chuck-norris TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
xml-agent TEMPLATES Metadata (#13691) 2023-11-22 01:41:12 -05:00
.gitignore Adds linter in templates (#12321) 2023-10-26 13:55:07 -07:00
Makefile Format Templates (#12396) 2023-10-26 19:44:30 -07:00
poetry.lock Relock Templates (#13028) 2023-11-07 15:01:49 -08:00
pyproject.toml Both lint and format templates with ruff v0.1.3. (#12676) 2023-10-31 14:52:00 -07:00
README.md Update readmes with new cli install (#12847) 2023-11-03 12:10:32 -07:00

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 package/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.