Skip to content

Commit

Permalink
Adds callback backgrounding env var in more places (#6196)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 authored Jul 24, 2024
1 parent 63305a0 commit f1ae405
Show file tree
Hide file tree
Showing 33 changed files with 103 additions and 11 deletions.
3 changes: 3 additions & 0 deletions docs/core_docs/docs/concepts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ After that, you can enable it by setting environment variables:
```shell
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY=ls__...

# Reduce tracing latency if you are not in a serverless environment
# export LANGCHAIN_CALLBACKS_BACKGROUND=true
```

## LangChain Expression Language
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/agent_executor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
"```shell\n",
"export LANGCHAIN_TRACING_V2=\"true\"\n",
"export LANGCHAIN_API_KEY=\"...\"\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```\n"
]
},
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/debugging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ After you sign up at the link above, make sure to set your environment variables
```shell
export LANGCHAIN_TRACING_V2="true"
export LANGCHAIN_API_KEY="..."

# Reduce tracing latency if you are not in a serverless environment
# export LANGCHAIN_CALLBACKS_BACKGROUND=true
```

Let's suppose we have an agent, and want to visualize the actions it takes and tool outputs it receives. Without any debugging, here's what we see:
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/graph_constructing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"# Optional, use LangSmith for best-in-class observability\n",
"LANGSMITH_API_KEY=your-api-key\n",
"LANGCHAIN_TRACING_V2=true\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```\n",
"\n",
"Next, we need to define Neo4j credentials.\n",
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/graph_mapping.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"# Optional, use LangSmith for best-in-class observability\n",
"LANGSMITH_API_KEY=your-api-key\n",
"LANGCHAIN_TRACING_V2=true\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```\n",
"\n",
"Next, we need to define Neo4j credentials.\n",
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/graph_prompting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
"# Optional, use LangSmith for best-in-class observability\n",
"LANGSMITH_API_KEY=your-api-key\n",
"LANGCHAIN_TRACING_V2=true\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```\n",
"\n",
"Next, we need to define Neo4j credentials.\n",
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/graph_semantic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"# Optional, use LangSmith for best-in-class observability\n",
"LANGSMITH_API_KEY=your-api-key\n",
"LANGCHAIN_TRACING_V2=true\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```\n",
"\n",
"Next, we need to define Neo4j credentials.\n",
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/message_history.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ If you do want to use LangSmith, after you sign up at the link above, make sure
```bash
export LANGCHAIN_TRACING_V2="true"
export LANGCHAIN_API_KEY="<your-api-key>"

# Reduce tracing latency if you are not in a serverless environment
# export LANGCHAIN_CALLBACKS_BACKGROUND=true
```

Let's create a simple runnable that takes a dict as input and returns a `BaseMessage`.
Expand Down
5 changes: 4 additions & 1 deletion docs/core_docs/docs/how_to/migrate_agent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@
"// process.env.LANGCHAIN_API_KEY = \"ls...\";\n",
"// process.env.LANGCHAIN_CALLBACKS_BACKGROUND = \"true\";\n",
"// process.env.LANGCHAIN_TRACING_V2 = \"true\";\n",
"// process.env.LANGCHAIN_PROJECT = \"How to migrate: LangGraphJS\";"
"// process.env.LANGCHAIN_PROJECT = \"How to migrate: LangGraphJS\";\n",
"\n",
"// Reduce tracing latency if you are not in a serverless environment\n",
"// process.env.LANGCHAIN_CALLBACKS_BACKGROUND = \"true\";"
]
},
{
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/qa_chat_history_how_to.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
"```bash\n",
"export LANGCHAIN_TRACING_V2=true\n",
"export LANGCHAIN_API_KEY=YOUR_KEY\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```"
]
},
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/qa_citations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
"```bash\n",
"export LANGCHAIN_TRACING_V2=true\n",
"export LANGCHAIN_API_KEY=YOUR_KEY\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```"
]
},
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/qa_per_user.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
"# Optional, use LangSmith for best-in-class observability\n",
"LANGSMITH_API_KEY=your-api-key\n",
"LANGCHAIN_TRACING_V2=true\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```"
]
},
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/qa_sources.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
"```bash\n",
"export LANGCHAIN_TRACING_V2=true\n",
"export LANGCHAIN_API_KEY=YOUR_KEY\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```"
]
},
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/qa_streaming.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
"```bash\n",
"export LANGCHAIN_TRACING_V2=true\n",
"export LANGCHAIN_API_KEY=YOUR_KEY\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```"
]
},
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/query_few_shot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
"# Optional, use LangSmith for best-in-class observability\n",
"LANGSMITH_API_KEY=your-api-key\n",
"LANGCHAIN_TRACING_V2=true\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```"
]
},
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/query_high_cardinality.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
"# Optional, use LangSmith for best-in-class observability\n",
"LANGSMITH_API_KEY=your-api-key\n",
"LANGCHAIN_TRACING_V2=true\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```"
]
},
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/query_multiple_queries.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
"# Optional, use LangSmith for best-in-class observability\n",
"LANGSMITH_API_KEY=your-api-key\n",
"LANGCHAIN_TRACING_V2=true\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```"
]
},
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/query_multiple_retrievers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
"# Optional, use LangSmith for best-in-class observability\n",
"LANGSMITH_API_KEY=your-api-key\n",
"LANGCHAIN_TRACING_V2=true\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```"
]
},
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/query_no_queries.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
"# Optional, use LangSmith for best-in-class observability\n",
"LANGSMITH_API_KEY=your-api-key\n",
"LANGCHAIN_TRACING_V2=true\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```"
]
},
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/sql_large_db.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export OPENAI_API_KEY="your api key"
# Uncomment the below to use LangSmith. Not required.
# export LANGCHAIN_API_KEY="your api key"
# export LANGCHAIN_TRACING_V2=true

# Reduce tracing latency if you are not in a serverless environment
# export LANGCHAIN_CALLBACKS_BACKGROUND=true
```

The below example will use a SQLite connection with Chinook database. Follow these [installation steps](https://database.guide/2-sample-databases-sqlite/) to create `Chinook.db` in the same directory as this notebook:
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/sql_prompting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export OPENAI_API_KEY="your api key"
# Uncomment the below to use LangSmith. Not required.
# export LANGCHAIN_API_KEY="your api key"
# export LANGCHAIN_TRACING_V2=true

# Reduce tracing latency if you are not in a serverless environment
# export LANGCHAIN_CALLBACKS_BACKGROUND=true
```

The below example will use a SQLite connection with Chinook database. Follow these [installation steps](https://database.guide/2-sample-databases-sqlite/) to create `Chinook.db` in the same directory as this notebook:
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/sql_query_checking.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export OPENAI_API_KEY="your api key"
# Uncomment the below to use LangSmith. Not required.
# export LANGCHAIN_API_KEY="your api key"
# export LANGCHAIN_TRACING_V2=true

# Reduce tracing latency if you are not in a serverless environment
# export LANGCHAIN_CALLBACKS_BACKGROUND=true
```

The below example will use a SQLite connection with Chinook database. Follow these [installation steps](https://database.guide/2-sample-databases-sqlite/) to create `Chinook.db` in the same directory as this notebook:
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/how_to/tools_prompting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"# Optional, use LangSmith for best-in-class observability\n",
"LANGSMITH_API_KEY=your-api-key\n",
"LANGCHAIN_TRACING_V2=true\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```"
]
},
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/tutorials/agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ When building with LangChain, all steps will automatically be traced in LangSmit
```bash
export LANGCHAIN_TRACING_V2="true"
export LANGCHAIN_API_KEY="<your-api-key>"

# Reduce tracing latency if you are not in a serverless environment
# export LANGCHAIN_CALLBACKS_BACKGROUND=true
```

## Define tools
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/tutorials/chatbot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
"```shell\n",
"export LANGCHAIN_TRACING_V2=\"true\"\n",
"export LANGCHAIN_API_KEY=\"...\"\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```\n",
"\n",
"## Quickstart\n",
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/tutorials/extraction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
"```shell\n",
"export LANGCHAIN_TRACING_V2=\"true\"\n",
"export LANGCHAIN_API_KEY=\"...\"\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```"
]
},
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/tutorials/graph.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
"# Optional, use LangSmith for best-in-class observability\n",
"LANGSMITH_API_KEY=your-api-key\n",
"LANGCHAIN_TRACING_V2=true\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```\n",
"\n",
"Next, we need to define Neo4j credentials.\n",
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/tutorials/llm_chain.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
"```shell\n",
"export LANGCHAIN_TRACING_V2=\"true\"\n",
"export LANGCHAIN_API_KEY=\"...\"\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```"
]
},
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/tutorials/local_rag.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"```bash\n",
"export LANGCHAIN_TRACING_V2=true\n",
"export LANGCHAIN_API_KEY=YOUR_KEY\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```"
]
},
Expand Down
16 changes: 6 additions & 10 deletions docs/core_docs/docs/tutorials/qa_chat_history.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
"```bash\n",
"export LANGCHAIN_TRACING_V2=true\n",
"export LANGCHAIN_API_KEY=YOUR_KEY\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```"
]
},
Expand All @@ -80,7 +83,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -92,15 +95,8 @@
"import { pull } from \"langchain/hub\";\n",
"import { ChatPromptTemplate } from \"@langchain/core/prompts\";\n",
"import { RunnableSequence, RunnablePassthrough } from \"@langchain/core/runnables\";\n",
"import { StringOutputParser } from \"@langchain/core/output_parsers\";"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"import { StringOutputParser } from \"@langchain/core/output_parsers\";\n",
"\n",
"import { createStuffDocumentsChain } from \"langchain/chains/combine_documents\";\n",
"\n",
"const loader = new CheerioWebBaseLoader(\n",
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/tutorials/query_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
"# Optional, use LangSmith for best-in-class observability\n",
"LANGSMITH_API_KEY=your-api-key\n",
"LANGCHAIN_TRACING_V2=true\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```"
]
},
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/tutorials/rag.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
"```shell\n",
"export LANGCHAIN_TRACING_V2=\"true\"\n",
"export LANGCHAIN_API_KEY=\"...\"\n",
"\n",
"# Reduce tracing latency if you are not in a serverless environment\n",
"# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n",
"```\n",
"\n",
"```{=mdx}\n",
Expand Down
3 changes: 3 additions & 0 deletions docs/core_docs/docs/tutorials/sql_qa.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export OPENAI_API_KEY=<your key>
# Uncomment the below to use LangSmith. Not required, but recommended for debugging and observability.
# export LANGCHAIN_API_KEY=<your key>
# export LANGCHAIN_TRACING_V2=true

# Reduce tracing latency if you are not in a serverless environment
# export LANGCHAIN_CALLBACKS_BACKGROUND=true
```

import CodeBlock from "@theme/CodeBlock";
Expand Down

0 comments on commit f1ae405

Please sign in to comment.