seansullivan/Langchain-Docs huggingface dataset:
## neo4j-generation

This template pairs LLM-based knowledge graph extraction with Neo4j AuraDB, a fully managed cloud graph database.

You can create a free instance on [Neo4j Aura](https://neo4j.com/cloud/platform/aura-graph-database?utm_source=langchain&utm_content=langserve).

When you initiate a free database instance, you'll receive credentials to access the database.

This template is flexible and allows users to guide the extraction process by specifying a list of node labels and relationship types.

For more details on the functionality and capabilities of this package, please refer to [this blog post](https://blog.langchain.dev/constructing-knowledge-graphs-from-text-using-openai-functions/).

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

You need to set the following environment variables:

```
OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>NEO4J_URI=<YOUR_NEO4J_URI>NEO4J_USERNAME=<YOUR_NEO4J_USERNAME>NEO4J_PASSWORD=<YOUR_NEO4J_PASSWORD>
```

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package neo4j-generation
```

If you want to add this to an existing project, you can just run:

```
langchain app add neo4j-generation
```

And add the following code to your `server.py` file:

```
from neo4j_generation.chain import chain as neo4j_generation_chainadd_routes(app, neo4j_generation_chain, path="/neo4j-generation")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/neo4j-generation/playground](http://127.0.0.1:8000/neo4j-generation/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/neo4j-generation")
```
## neo4j-parent

This template allows you to balance precise embeddings and context retention by splitting documents into smaller chunks and retrieving their original or larger text information.

Using a Neo4j vector index, the package queries child nodes using vector similarity search and retrieves the corresponding parent's text by defining an appropriate `retrieval_query` parameter.

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

You need to define the following environment variables

```
OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>NEO4J_URI=<YOUR_NEO4J_URI>NEO4J_USERNAME=<YOUR_NEO4J_USERNAME>NEO4J_PASSWORD=<YOUR_NEO4J_PASSWORD>
```

## Populating with data[​](#populating-with-data "Direct link to Populating with data")

If you want to populate the DB with some example data, you can run `python ingest.py`. The script process and stores sections of the text from the file `dune.txt` into a Neo4j graph database. First, the text is divided into larger chunks ("parents") and then further subdivided into smaller chunks ("children"), where both parent and child chunks overlap slightly to maintain context. After storing these chunks in the database, embeddings for the child nodes are computed using OpenAI's embeddings and stored back in the graph for future retrieval or analysis. Additionally, a vector index named `retrieval` is created for efficient querying of these embeddings.

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package neo4j-parent
```

If you want to add this to an existing project, you can just run:

```
langchain app add neo4j-parent
```

And add the following code to your `server.py` file:

```
from neo4j_parent import chain as neo4j_parent_chainadd_routes(app, neo4j_parent_chain, path="/neo4j-parent")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/neo4j-parent/playground](http://127.0.0.1:8000/neo4j-parent/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/neo4j-parent")
```
## neo4j-vector-memory

This template allows you to integrate an LLM with a vector-based retrieval system using Neo4j as the vector store. Additionally, it uses the graph capabilities of the Neo4j database to store and retrieve the dialogue history of a specific user's session. Having the dialogue history stored as a graph allows for seamless conversational flows but also gives you the ability to analyze user behavior and text chunk retrieval through graph analytics.

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

You need to define the following environment variables

```
OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>NEO4J_URI=<YOUR_NEO4J_URI>NEO4J_USERNAME=<YOUR_NEO4J_USERNAME>NEO4J_PASSWORD=<YOUR_NEO4J_PASSWORD>
```

## Populating with data[​](#populating-with-data "Direct link to Populating with data")

If you want to populate the DB with some example data, you can run `python ingest.py`. The script process and stores sections of the text from the file `dune.txt` into a Neo4j graph database. Additionally, a vector index named `dune` is created for efficient querying of these embeddings.

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package neo4j-vector-memory
```

If you want to add this to an existing project, you can just run:

```
langchain app add neo4j-vector-memory
```

And add the following code to your `server.py` file:

```
from neo4j_vector_memory import chain as neo4j_vector_memory_chainadd_routes(app, neo4j_vector_memory_chain, path="/neo4j-vector-memory")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/neo4j-vector-memory/playground](http://127.0.0.1:8000/neo4j-parent/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/neo4j-vector-memory")
```
## rag-chroma

This template performs RAG using Chroma and OpenAI.

The vectorstore is created in `chain.py` and by default indexes a [popular blog posts on Agents](https://lilianweng.github.io/posts/2023-06-23-agent/) for question-answering.

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

Set the `OPENAI_API_KEY` environment variable to access the OpenAI models.

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package rag-chroma
```

If you want to add this to an existing project, you can just run:

```
langchain app add rag-chroma
```

And add the following code to your `server.py` file:

```
from rag_chroma import chain as rag_chroma_chainadd_routes(app, rag_chroma_chain, path="/rag-chroma")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/rag-chroma/playground](http://127.0.0.1:8000/rag-chroma/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/rag-chroma")
```

* * *

#### Help us out by providing feedback on this documentation page:
## rag-codellama-fireworks

This template performs RAG on a codebase.

It uses codellama-34b hosted by Fireworks' [LLM inference API](https://blog.fireworks.ai/accelerating-code-completion-with-fireworks-fast-llm-inference-f4e8b5ec534a).

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

Set the `FIREWORKS_API_KEY` environment variable to access the Fireworks models.

You can obtain it from [here](https://app.fireworks.ai/login?callbackURL=https://app.fireworks.ai).

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package rag-codellama-fireworks
```

If you want to add this to an existing project, you can just run:

```
langchain app add rag-codellama-fireworks
```

And add the following code to your `server.py` file:

```
from rag_codellama_fireworks import chain as rag_codellama_fireworks_chainadd_routes(app, rag_codellama_fireworks_chain, path="/rag-codellama-fireworks")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/rag-codellama-fireworks/playground](http://127.0.0.1:8000/rag-codellama-fireworks/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/rag-codellama-fireworks")
```

* * *

#### Help us out by providing feedback on this documentation page:
## rag-chroma-private

This template performs RAG with no reliance on external APIs.

It utilizes Ollama the LLM, GPT4All for embeddings, and Chroma for the vectorstore.

The vectorstore is created in `chain.py` and by default indexes a [popular blog posts on Agents](https://lilianweng.github.io/posts/2023-06-23-agent/) for question-answering.

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

To set up the environment, you need to download Ollama.

Follow the instructions [here](https://python.langchain.com/docs/integrations/chat/ollama).

You can choose the desired LLM with Ollama.

This template uses `llama2:7b-chat`, which can be accessed using `ollama pull llama2:7b-chat`.

There are many other options available [here](https://ollama.ai/library).

This package also uses [GPT4All](https://python.langchain.com/docs/integrations/text_embedding/gpt4all) embeddings.

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package rag-chroma-private
```

If you want to add this to an existing project, you can just run:

```
langchain app add rag-chroma-private
```

And add the following code to your `server.py` file:

```
from rag_chroma_private import chain as rag_chroma_private_chainadd_routes(app, rag_chroma_private_chain, path="/rag-chroma-private")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/rag-chroma-private/playground](http://127.0.0.1:8000/rag-chroma-private/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/rag-chroma-private")
```

The package will create and add documents to the vector database in `chain.py`. By default, it will load a popular blog post on agents. However, you can choose from a large number of document loaders [here](https://python.langchain.com/docs/integrations/document_loaders).
## rag-vectara-multiquery

This template performs multiquery RAG with vectara.

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

Set the `OPENAI_API_KEY` environment variable to access the OpenAI models.

Also, ensure the following environment variables are set:

*   `VECTARA_CUSTOMER_ID`
*   `VECTARA_CORPUS_ID`
*   `VECTARA_API_KEY`

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package rag-vectara-multiquery
```

If you want to add this to an existing project, you can just run:

```
langchain app add rag-vectara-multiquery
```

And add the following code to your `server.py` file:

```
from rag_vectara import chain as rag_vectara_chainadd_routes(app, rag_vectara_chain, path="/rag-vectara-multiquery")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

```
export LANGCHAIN_TRACING_V2=trueexport LANGCHAIN_API_KEY=<your-api-key>export LANGCHAIN_PROJECT=<your-project>  # if not specified, defaults to "vectara-demo"
```

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/rag-vectara-multiquery/playground](http://127.0.0.1:8000/rag-vectara-multiquery/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/rag-vectara-multiquery")
```

* * *

#### Help us out by providing feedback on this documentation page:
## rag-elasticsearch

This template performs RAG using [Elasticsearch](https://python.langchain.com/docs/integrations/vectorstores/elasticsearch).

It relies on sentence transformer `MiniLM-L6-v2` for embedding passages and questions.

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

Set the `OPENAI_API_KEY` environment variable to access the OpenAI models.

To connect to your Elasticsearch instance, use the following environment variables:

```
export ELASTIC_CLOUD_ID = <ClOUD_ID>export ELASTIC_USERNAME = <ClOUD_USERNAME>export ELASTIC_PASSWORD = <ClOUD_PASSWORD>
```

For local development with Docker, use:

```
export ES_URL="http://localhost:9200"
```

And run an Elasticsearch instance in Docker with

```
docker run -p 9200:9200 -e "discovery.type=single-node" -e "xpack.security.enabled=false" -e "xpack.security.http.ssl.enabled=false" docker.elastic.co/elasticsearch/elasticsearch:8.9.0
```

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package rag-elasticsearch
```

If you want to add this to an existing project, you can just run:

```
langchain app add rag-elasticsearch
```

And add the following code to your `server.py` file:

```
from rag_elasticsearch import chain as rag_elasticsearch_chainadd_routes(app, rag_elasticsearch_chain, path="/rag-elasticsearch")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/rag-elasticsearch/playground](http://127.0.0.1:8000/rag-elasticsearch/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/rag-elasticsearch")
```

For loading the fictional workplace documents, run the following command from the root of this repository:

However, you can choose from a large number of document loaders [here](https://python.langchain.com/docs/integrations/document_loaders).
## rag-fusion

This template enables RAG fusion using a re-implementation of the project found [here](https://github.com/Raudaschl/rag-fusion).

It performs multiple query generation and Reciprocal Rank Fusion to re-rank search results.

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

Set the `OPENAI_API_KEY` environment variable to access the OpenAI models.

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package rag-fusion
```

If you want to add this to an existing project, you can just run:

```
langchain app add rag-fusion
```

And add the following code to your `server.py` file:

```
from rag_fusion.chain import chain as rag_fusion_chainadd_routes(app, rag_fusion_chain, path="/rag-fusion")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/rag-fusion/playground](http://127.0.0.1:8000/rag-fusion/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/rag-fusion")
```

* * *

#### Help us out by providing feedback on this documentation page:
## rag-conversation

This template is used for [conversational](https://python.langchain.com/docs/expression_language/cookbook/retrieval#conversational-retrieval-chain) [retrieval](https://python.langchain.com/docs/use_cases/question_answering/), which is one of the most popular LLM use-cases.

It passes both a conversation history and retrieved documents into an LLM for synthesis.

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

This template uses Pinecone as a vectorstore and requires that `PINECONE_API_KEY`, `PINECONE_ENVIRONMENT`, and `PINECONE_INDEX` are set.

Set the `OPENAI_API_KEY` environment variable to access the OpenAI models.

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package rag-conversation
```

If you want to add this to an existing project, you can just run:

```
langchain app add rag-conversation
```

And add the following code to your `server.py` file:

```
from rag_conversation import chain as rag_conversation_chainadd_routes(app, rag_conversation_chain, path="/rag-conversation")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/rag-conversation/playground](http://127.0.0.1:8000/rag-conversation/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/rag-conversation")
```

* * *

#### Help us out by providing feedback on this documentation page:
## research-assistant

This template implements a version of  
[GPT Researcher](https://github.com/assafelovic/gpt-researcher) that you can use as a starting point for a research agent.

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

The default template relies on ChatOpenAI and DuckDuckGo, so you will need the following environment variable:

*   `OPENAI_API_KEY`

And to use the Tavily LLM-optimized search engine, you will need:

*   `TAVILY_API_KEY`

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package research-assistant
```

If you want to add this to an existing project, you can just run:

```
langchain app add research-assistant
```

And add the following code to your `server.py` file:

```
from research_assistant import chain as research_assistant_chainadd_routes(app, research_assistant_chain, path="/research-assistant")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/research-assistant/playground](http://127.0.0.1:8000/research-assistant/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/research-assistant")
```

* * *

#### Help us out by providing feedback on this documentation page:
## retrieval-agent

This package uses Azure OpenAI to do retrieval using an agent architecture. By default, this does retrieval over Arxiv.

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

Since we are using Azure OpenAI, we will need to set the following environment variables:

```
export AZURE_OPENAI_ENDPOINT=...export AZURE_OPENAI_API_VERSION=...export AZURE_OPENAI_API_KEY=...
```

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package retrieval-agent
```

If you want to add this to an existing project, you can just run:

```
langchain app add retrieval-agent
```

And add the following code to your `server.py` file:

```
from retrieval_agent import chain as retrieval_agent_chainadd_routes(app, retrieval_agent_chain, path="/retrieval-agent")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/retrieval-agent/playground](http://127.0.0.1:8000/retrieval-agent/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/retrieval-agent")
```

* * *

#### Help us out by providing feedback on this documentation page:
## rag-vectara

This template performs RAG with vectara.

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

Set the `OPENAI_API_KEY` environment variable to access the OpenAI models.

Also, ensure the following environment variables are set:

*   `VECTARA_CUSTOMER_ID`
*   `VECTARA_CORPUS_ID`
*   `VECTARA_API_KEY`

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package rag-vectara
```

If you want to add this to an existing project, you can just run:

```
langchain app add rag-vectara
```

And add the following code to your `server.py` file:

```
from rag_vectara import chain as rag_vectara_chainadd_routes(app, rag_vectara_chain, path="/rag-vectara")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

```
export LANGCHAIN_TRACING_V2=trueexport LANGCHAIN_API_KEY=<your-api-key>export LANGCHAIN_PROJECT=<your-project>  # if not specified, defaults to "vectara-demo"
```

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/rag-vectara/playground](http://127.0.0.1:8000/rag-vectara/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/rag-vectara")
```

* * *

#### Help us out by providing feedback on this documentation page:
## rag-weaviate

This template performs RAG with Weaviate.

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

Set the `OPENAI_API_KEY` environment variable to access the OpenAI models.

Also, ensure the following environment variables are set:

*   `WEAVIATE_ENVIRONMENT`
*   `WEAVIATE_API_KEY`

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package rag-weaviate
```

If you want to add this to an existing project, you can just run:

```
langchain app add rag-weaviate
```

And add the following code to your `server.py` file:

```
from rag_weaviate import chain as rag_weaviate_chainadd_routes(app, rag_weaviate_chain, path="/rag-weaviate")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/rag-weaviate/playground](http://127.0.0.1:8000/rag-weaviate/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/rag-weaviate")
```

* * *

#### Help us out by providing feedback on this documentation page:
## retrieval-agent-fireworks

This package uses open source models hosted on FireworksAI to do retrieval using an agent architecture. By default, this does retrieval over Arxiv.

We will use `Mixtral8x7b-instruct-v0.1`, which is shown in this blog to yield reasonable results with function calling even though it is not fine tuned for this task: [https://huggingface.co/blog/open-source-llms-as-agents](https://huggingface.co/blog/open-source-llms-as-agents)

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

There are various great ways to run OSS models. We will use FireworksAI as an easy way to run the models. See [here](https://python.langchain.com/docs/integrations/providers/fireworks) for more information.

Set the `FIREWORKS_API_KEY` environment variable to access Fireworks.

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package retrieval-agent-fireworks
```

If you want to add this to an existing project, you can just run:

```
langchain app add retrieval-agent-fireworks
```

And add the following code to your `server.py` file:

```
from retrieval_agent_fireworks import chain as retrieval_agent_fireworks_chainadd_routes(app, retrieval_agent_fireworks_chain, path="/retrieval-agent-fireworks")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/retrieval-agent-fireworks/playground](http://127.0.0.1:8000/retrieval-agent-fireworks/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/retrieval-agent-fireworks")
```
## rewrite\_retrieve\_read

This template implemenets a method for query transformation (re-writing) in the paper [Query Rewriting for Retrieval-Augmented Large Language Models](https://arxiv.org/pdf/2305.14283.pdf) to optimize for RAG.

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

Set the `OPENAI_API_KEY` environment variable to access the OpenAI models.

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package rewrite_retrieve_read
```

If you want to add this to an existing project, you can just run:

```
langchain app add rewrite_retrieve_read
```

And add the following code to your `server.py` file:

```
from rewrite_retrieve_read.chain import chain as rewrite_retrieve_read_chainadd_routes(app, rewrite_retrieve_read_chain, path="/rewrite-retrieve-read")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/rewrite\_retrieve\_read/playground](http://127.0.0.1:8000/rewrite_retrieve_read/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/rewrite_retrieve_read")
```

* * *

#### Help us out by providing feedback on this documentation page:
This template enables using [Robocorp Action Server](https://github.com/robocorp/robocorp) served actions as tools for an Agent.

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package robocorp-action-server
```

If you want to add this to an existing project, you can just run:

```
langchain app add robocorp-action-server
```

And add the following code to your `server.py` file:

```
from robocorp_action_server import agent_executor as action_server_chainadd_routes(app, action_server_chain, path="/robocorp-action-server")
```

### Running the Action Server[​](#running-the-action-server "Direct link to Running the Action Server")

To run the Action Server, you need to have the Robocorp Action Server installed

```
pip install -U robocorp-action-server
```

Then you can run the Action Server with:

```
action-server newcd ./your-project-nameaction-server start
```

### Configure LangSmith (Optional)[​](#configure-langsmith-optional "Direct link to Configure LangSmith (Optional)")

LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

### Start LangServe instance[​](#start-langserve-instance "Direct link to Start LangServe instance")

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/robocorp-action-server/playground](http://127.0.0.1:8000/robocorp-action-server/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/robocorp-action-server")
```
## shopping-assistant

This template creates a shopping assistant that helps users find products that they are looking for.

This template will use `Ionic` to search for products.

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

This template will use `OpenAI` by default. Be sure that `OPENAI_API_KEY` is set in your environment.

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package shopping-assistant
```

If you want to add this to an existing project, you can just run:

```
langchain app add shopping-assistant
```

And add the following code to your `server.py` file:

```
from shopping_assistant.agent import agent_executor as shopping_assistant_chainadd_routes(app, shopping_assistant_chain, path="/shopping-assistant")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/shopping-assistant/playground](http://127.0.0.1:8000/shopping-assistant/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/shopping-assistant")
```

* * *

#### Help us out by providing feedback on this documentation page:
## skeleton-of-thought

Implements "Skeleton of Thought" from [this](https://sites.google.com/view/sot-llm) paper.

This technique makes it possible to generate longer generations more quickly by first generating a skeleton, then generating each point of the outline.

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

Set the `OPENAI_API_KEY` environment variable to access the OpenAI models.

To get your `OPENAI_API_KEY`, navigate to [API keys](https://platform.openai.com/account/api-keys) on your OpenAI account and create a new secret key.

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package skeleton-of-thought
```

If you want to add this to an existing project, you can just run:

```
langchain app add skeleton-of-thought
```

And add the following code to your `server.py` file:

```
from skeleton_of_thought import chain as skeleton_of_thought_chainadd_routes(app, skeleton_of_thought_chain, path="/skeleton-of-thought")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/skeleton-of-thought/playground](http://127.0.0.1:8000/skeleton-of-thought/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/skeleton-of-thought")
```

* * *

#### Help us out by providing feedback on this documentation page:
## solo-performance-prompting-agent

This template creates an agent that transforms a single LLM into a cognitive synergist by engaging in multi-turn self-collaboration with multiple personas. A cognitive synergist refers to an intelligent agent that collaborates with multiple minds, combining their individual strengths and knowledge, to enhance problem-solving and overall performance in complex tasks. By dynamically identifying and simulating different personas based on task inputs, SPP unleashes the potential of cognitive synergy in LLMs.

This template will use the `DuckDuckGo` search API.

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

This template will use `OpenAI` by default. Be sure that `OPENAI_API_KEY` is set in your environment.

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package solo-performance-prompting-agent
```

If you want to add this to an existing project, you can just run:

```
langchain app add solo-performance-prompting-agent
```

And add the following code to your `server.py` file:

```
from solo_performance_prompting_agent.agent import agent_executor as solo_performance_prompting_agent_chainadd_routes(app, solo_performance_prompting_agent_chain, path="/solo-performance-prompting-agent")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/solo-performance-prompting-agent/playground](http://127.0.0.1:8000/solo-performance-prompting-agent/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/solo-performance-prompting-agent")
```
## sql-llama2

This template enables a user to interact with a SQL database using natural language.

It uses LLamA2-13b hosted by [Replicate](https://python.langchain.com/docs/integrations/llms/replicate), but can be adapted to any API that supports LLaMA2 including [Fireworks](https://python.langchain.com/docs/integrations/chat/fireworks).

The template includes an example database of 2023 NBA rosters.

For more information on how to build this database, see [here](https://github.com/facebookresearch/llama-recipes/blob/main/demo_apps/StructuredLlama.ipynb).

## Environment Setup[​](#environment-setup "Direct link to Environment Setup")

Ensure the `REPLICATE_API_TOKEN` is set in your environment.

## Usage[​](#usage "Direct link to Usage")

To use this package, you should first have the LangChain CLI installed:

```
pip install -U langchain-cli
```

To create a new LangChain project and install this as the only package, you can do:

```
langchain app new my-app --package sql-llama2
```

If you want to add this to an existing project, you can just run:

```
langchain app add sql-llama2
```

And add the following code to your `server.py` file:

```
from sql_llama2 import chain as sql_llama2_chainadd_routes(app, sql_llama2_chain, path="/sql-llama2")
```

(Optional) Let's now configure LangSmith. LangSmith will help us trace, monitor and debug LangChain applications. You can sign up for LangSmith [here](https://smith.langchain.com/). If you don't have access, you can skip this section

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

If you are inside this directory, then you can spin up a LangServe instance directly by:

This will start the FastAPI app with a server is running locally at [http://localhost:8000](http://localhost:8000/)

We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) We can access the playground at [http://127.0.0.1:8000/sql-llama2/playground](http://127.0.0.1:8000/sql-llama2/playground)

We can access the template from code with:

```
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/sql-llama2")
```