Skip to content

Commit b68c802

Browse files
samecrowderkatmayb
andauthored
better document what the first argument to a RemoteGraph can be (#116)
when using RemoteGraph for a couple weeks, I noticed unexpected behavior that I could give either an assistant ID or a graph name as the first argument when instantiating a RemoteGraph. Turns out this is by design, but it was not documented. --------- Co-authored-by: Kathryn May <[email protected]>
1 parent ac6d3a9 commit b68c802

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/langgraph-platform/use-remote-graph.mdx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ sidebarTitle: Interact with the deployment using RemoteGraph
1414

1515
When initializing a `RemoteGraph`, you must always specify:
1616

17-
* `name`: the name of the graph you want to interact with. This is the same graph name you use in `langgraph.json` configuration file for your deployment.
17+
* `name`: the name of the graph you want to interact with **or** an assistant ID. If you specify a graph name, the default assistant will be used. If you specify an assistant ID, that specific assistant will be used. The graph name is the same name you use in `langgraph.json` configuration file for your deployment.
1818
* `api_key`: a valid LangSmith API key. Can be set as an environment variable (`LANGSMITH_API_KEY`) or passed directly via the `api_key` argument. The API key could also be provided via the `client` / `sync_client` arguments, if `LangGraphClient` / `SyncLangGraphClient` were initialized with `api_key` argument.
1919

2020
Additionally, you have to provide one of the following:
@@ -35,17 +35,29 @@ Additionally, you have to provide one of the following:
3535
from langgraph.pregel.remote import RemoteGraph
3636

3737
url = <DEPLOYMENT_URL>
38+
39+
# Using graph name (uses default assistant)
3840
graph_name = "agent"
3941
remote-graph = RemoteGraph(graph_name, url=url)
42+
43+
# Using assistant ID
44+
assistant_id = <ASSISTANT_ID>
45+
remote-graph = RemoteGraph(assistant_id, url=url)
4046
```
4147
</Tab>
4248
<Tab title="JavaScript">
4349
```ts
4450
import { RemoteGraph } from "@langchain/langgraph/remote";
4551

4652
const url = `<DEPLOYMENT_URL>`;
53+
54+
// Using graph name (uses default assistant)
4755
const graphName = "agent";
4856
const remoteGraph = new RemoteGraph({ graphId: graphName, url });
57+
58+
// Using assistant ID
59+
const assistantId = `<ASSISTANT_ID>`;
60+
const remoteGraph = new RemoteGraph({ graphId: assistantId, url });
4961
```
5062
</Tab>
5163
</Tabs>
@@ -59,10 +71,16 @@ Additionally, you have to provide one of the following:
5971
from langgraph.pregel.remote import RemoteGraph
6072

6173
url = <DEPLOYMENT_URL>
62-
graph_name = "agent"
6374
client = get_client(url=url)
6475
sync_client = get_sync_client(url=url)
76+
77+
# Using graph name (uses default assistant)
78+
graph_name = "agent"
6579
remote-graph = RemoteGraph(graph_name, client=client, sync_client=sync_client)
80+
81+
# Using assistant ID
82+
assistant_id = <ASSISTANT_ID>
83+
remote-graph = RemoteGraph(assistant_id, client=client, sync_client=sync_client)
6684
```
6785
</Tab>
6886
<Tab title="JavaScript">
@@ -71,8 +89,14 @@ Additionally, you have to provide one of the following:
7189
import { RemoteGraph } from "@langchain/langgraph/remote";
7290

7391
const client = new Client({ apiUrl: `<DEPLOYMENT_URL>` });
92+
93+
// Using graph name (uses default assistant)
7494
const graphName = "agent";
7595
const remoteGraph = new RemoteGraph({ graphId: graphName, client });
96+
97+
// Using assistant ID
98+
const assistantId = `<ASSISTANT_ID>`;
99+
const remoteGraph = new RemoteGraph({ graphId: assistantId, client });
76100
```
77101
</Tab>
78102
</Tabs>

0 commit comments

Comments
 (0)