Skip to content

Commit

Permalink
[docs]: add subgraph streaming how-to (and some small cleanups) (#1606)
Browse files Browse the repository at this point in the history
* wip

* spelling

* edit format_namespace
  • Loading branch information
isahers1 committed Sep 6, 2024
1 parent 6134b0e commit 8fc0eec
Show file tree
Hide file tree
Showing 6 changed files with 376 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/_scripts/copy_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"streaming-events-from-within-tools.ipynb",
"streaming-events-from-within-tools-without-langchain.ipynb",
"streaming-from-final-node.ipynb",
"streaming-subgraphs.ipynb",
"persistence.ipynb",
"input_output_schema.ipynb",
"pass_private_state.ipynb",
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/cloud/faq/studio.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The first way to solve this is to add path maps to your conditional edges. A pat
=== "Javascript"

```ts
graph.addConditionalEdges("node_a", routingFunction, ["node_b", "node_c"]);
graph.addConditionalEdges("node_a", routingFunction, { true: "node_b", false: "node_c" });
```

In this case, the routing function returns either True or False, which map to `node_b` and `node_c` respectively.
Expand All @@ -66,8 +66,8 @@ Instead of passing a path map, you can also be explicit about the typing of your
```python
def routing_function(state: GraphState) -> Literal["node_b","node_c"]:
if state['some_condition'] == True:
return "node_a"
else:
return "node_b"
else:
return "node_c"
```

1 change: 1 addition & 0 deletions docs/docs/how-tos/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ These guides show how to use different streaming modes.
- [How to stream events from within a tool](streaming-events-from-within-tools.ipynb)
- [How to stream events from within a tool without LangChain models](streaming-events-from-within-tools-without-langchain.ipynb)
- [How to stream events from the final node](streaming-from-final-node.ipynb)
- [How to stream from subgraphs](streaming-subgraphs.ipynb)

## Tool calling

Expand Down
1 change: 1 addition & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ nav:
- Stream events from within tools: how-tos/streaming-events-from-within-tools.ipynb
- Stream events from within tools without LangChain models: how-tos/streaming-events-from-within-tools-without-langchain.ipynb
- Stream events from the final node: how-tos/streaming-from-final-node.ipynb
- Stream from subgraphs: how-tos/streaming-subgraphs.ipynb
- Tool calling:
- Call tools using ToolNode: how-tos/tool-calling.ipynb
- Handle tool calling errors: how-tos/tool-calling-errors.ipynb
Expand Down
8 changes: 6 additions & 2 deletions examples/streaming-from-final-node.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
"id": "964686a6-8fed-4360-84d2-958c48186008",
"metadata": {},
"source": [
"A common use case is streaming from an agent is to stream LLM tokens from inside the final node. This guide demonstrates how you can do this."
"A common use case is streaming from an agent is to stream LLM tokens from inside the final node. This guide demonstrates how you can do this.\n",
"\n",
"## Setup\n",
"\n",
"First let's install our required packages and set our environment variables."
]
},
{
Expand All @@ -34,7 +38,7 @@
"metadata": {},
"outputs": [
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"OPENAI_API_KEY: ········\n"
Expand Down
364 changes: 364 additions & 0 deletions examples/streaming-subgraphs.ipynb

Large diffs are not rendered by default.

0 comments on commit 8fc0eec

Please sign in to comment.