Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sdk): expose xray kwarg to get_graph/getGraph #1880

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions libs/sdk-js/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {

Check notice on line 1 in libs/sdk-js/src/client.ts

View workflow job for this annotation

GitHub Actions / benchmark

Benchmark results

......................................... fanout_to_subgraph_10x: Mean +- std dev: 59.8 ms +- 1.3 ms ......................................... WARNING: the benchmark result may be unstable * the standard deviation (7.49 ms) is 13% of the mean (57.7 ms) Try to rerun the benchmark with more runs, values and/or loops. Run 'python -m pyperf system tune' command to reduce the system jitter. Use pyperf stats, pyperf dump and pyperf hist to analyze results. Use --quiet option to hide these warnings. fanout_to_subgraph_10x_sync: Mean +- std dev: 57.7 ms +- 7.5 ms ......................................... fanout_to_subgraph_10x_checkpoint: Mean +- std dev: 77.3 ms +- 1.7 ms ......................................... fanout_to_subgraph_10x_checkpoint_sync: Mean +- std dev: 82.5 ms +- 0.7 ms ......................................... fanout_to_subgraph_100x: Mean +- std dev: 582 ms +- 13 ms ......................................... fanout_to_subgraph_100x_sync: Mean +- std dev: 508 ms +- 5 ms ......................................... fanout_to_subgraph_100x_checkpoint: Mean +- std dev: 819 ms +- 34 ms ......................................... fanout_to_subgraph_100x_checkpoint_sync: Mean +- std dev: 799 ms +- 6 ms ......................................... react_agent_10x: Mean +- std dev: 42.4 ms +- 4.0 ms ......................................... react_agent_10x_sync: Mean +- std dev: 30.2 ms +- 0.3 ms ......................................... WARNING: the benchmark result may be unstable * the standard deviation (10.5 ms) is 18% of the mean (57.8 ms) * the maximum (122 ms) is 111% greater than the mean (57.8 ms) Try to rerun the benchmark with more runs, values and/or loops. Run 'python -m pyperf system tune' command to reduce the system jitter. Use pyperf stats, pyperf dump and pyperf hist to analyze results. Use --quiet option to hide these warnings. react_agent_10x_checkpoint: Mean +- std dev: 57.8 ms +- 10.5 ms ......................................... react_agent_10x_checkpoint_sync: Mean +- std dev: 44.1 ms +- 4.0 ms ......................................... react_agent_100x: Mean +- std dev: 418 ms +- 7 ms ......................................... react_agent_100x_sync: Mean +- std dev: 334 ms +- 4 ms ......................................... react_agent_100x_checkpoint: Mean +- std dev: 983 ms +- 52 ms ......................................... react_agent_100x_checkpoint_sync: Mean +- std dev: 877 ms +- 39 ms ......................................... WARNING: the benchmark result may be unstable * the maximum (32.3 ms) is 52% greater than the mean (21.2 ms) Try to rerun the benchmark with more runs, values and/or loops. Run 'python -m pyperf system tune' command to reduce the system jitter. Use pyperf stats, pyperf dump and pyperf hist to analyze results. Use --quiet option to hide these warnings. wide_state_25x300: Mean +- std dev: 21.2 ms +- 1.8 ms ......................................... wide_state_25x300_sync: Mean +- std dev: 13.2 ms +- 0.3 ms ......................................... wide_state_25x300_checkpoint: Mean +- std dev: 243 ms +- 8 ms ......................................... wide_state_25x300_checkpoint_sync: Mean +- std dev: 243 ms +- 19 ms ......................................... wide_state_15x600: Mean +- std dev: 24.4 ms +- 0.5 ms ......................................... wide_state_15x600_sync: Mean +- std dev: 15.3 ms +- 0.4 ms ......................................... wide_state_15x600_checkpoint: Mean +- std dev: 423 ms +- 12 ms ......................................... wide_state_15x600_checkpoint_sync: Mean +- std dev: 420 ms +- 22 ms ......................................... wide_state_9x1200: Mean +- std dev: 24.6 ms +- 0.6 ms ......................................... wide_state_9x1200_sync: Mean +- std dev: 15.2 ms +- 0.2 ms ......................................... wide_state_9x1200_checkpoint: Mean +- std dev: 271 ms +- 8 ms ......................................... wide_state_9x1200_checkpoint_sync: Mean +- std dev: 272 ms +- 17 ms

Check notice on line 1 in libs/sdk-js/src/client.ts

View workflow job for this annotation

GitHub Actions / benchmark

Comparison against main

+-----------------------------------------+---------+-----------------------+ | Benchmark | main | changes | +=========================================+=========+=======================+ | wide_state_9x1200_checkpoint | 269 ms | 271 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_checkpoint | 76.4 ms | 77.3 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_15x600_checkpoint | 418 ms | 423 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_sync | 502 ms | 508 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_checkpoint_sync | 788 ms | 799 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_100x_sync | 329 ms | 334 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_25x300_checkpoint | 239 ms | 243 ms: 1.02x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_checkpoint_sync | 81.1 ms | 82.5 ms: 1.02x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_100x | 411 ms | 418 ms: 1.02x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_10x_sync | 29.6 ms | 30.2 ms: 1.02x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_25x300_checkpoint_sync | 237 ms | 243 ms: 1.02x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_9x1200_checkpoint_sync | 265 ms | 272 ms: 1.02x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_10x_checkpoint_sync | 43.0 ms | 44.1 ms: 1.03x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_10x | 41.2 ms | 42.4 ms: 1.03x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_9x1200_sync | 14.7 ms | 15.2 ms: 1.03x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_sync | 55.9 ms | 57.7 ms: 1.03x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_25x300_sync | 12.7 ms | 13.2 ms: 1.04x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_15x600_sync | 14.7 ms | 15.3 ms: 1.04x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_15x600 | 23.5 ms | 24.4 ms: 1.04x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_25x300 | 20.4 ms | 21.2 ms: 1.04x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_9x1200 | 23.5 ms | 24.6 ms: 1.04x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x | 549 ms | 582 ms: 1.06x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_100x_checkpoint | 922 ms | 983 ms: 1.07x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_100x_checkpoint_sync | 822 ms | 877 ms: 1.07x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_10x_checkpoint | 53.0 ms | 57.8 ms: 1.09x slower | +---------------------------------------
Assistant,
AssistantGraph,
Config,
Expand Down Expand Up @@ -223,8 +223,13 @@
* @param assistantId The ID of the assistant.
* @returns Serialized graph
*/
async getGraph(assistantId: string): Promise<AssistantGraph> {
return this.fetch<AssistantGraph>(`/assistants/${assistantId}/graph`);
async getGraph(
assistantId: string,
options?: { xray?: boolean },
): Promise<AssistantGraph> {
return this.fetch<AssistantGraph>(`/assistants/${assistantId}/graph`, {
params: { xray: options?.xray },
});
}

/**
Expand Down
16 changes: 12 additions & 4 deletions libs/sdk-py/langgraph_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,14 @@ async def get(self, assistant_id: str) -> Assistant:
""" # noqa: E501
return await self.http.get(f"/assistants/{assistant_id}")

async def get_graph(self, assistant_id: str) -> dict[str, list[dict[str, Any]]]:
async def get_graph(
dqbd marked this conversation as resolved.
Show resolved Hide resolved
self, assistant_id: str, *, xray: bool = False
) -> dict[str, list[dict[str, Any]]]:
"""Get the graph of an assistant by ID.

Args:
assistant_id: The ID of the assistant to get the graph of.
xray: Include graph representation of subgraphs.

Returns:
Graph: The graph information for the assistant in JSON format.
Expand Down Expand Up @@ -338,7 +341,9 @@ async def get_graph(self, assistant_id: str) -> dict[str, list[dict[str, Any]]]:


""" # noqa: E501
return await self.http.get(f"/assistants/{assistant_id}/graph")
return await self.http.get(
f"/assistants/{assistant_id}/graph", params={"xray": xray}
)

async def get_schemas(self, assistant_id: str) -> GraphSchema:
"""Get the schemas of an assistant by ID.
Expand Down Expand Up @@ -2068,11 +2073,14 @@ def get(self, assistant_id: str) -> Assistant:
""" # noqa: E501
return self.http.get(f"/assistants/{assistant_id}")

def get_graph(self, assistant_id: str) -> dict[str, list[dict[str, Any]]]:
def get_graph(
self, assistant_id: str, *, xray: bool = False
) -> dict[str, list[dict[str, Any]]]:
"""Get the graph of an assistant by ID.

Args:
assistant_id: The ID of the assistant to get the graph of.
xray: Include graph representation of subgraphs.

Returns:
Graph: The graph information for the assistant in JSON format.
Expand Down Expand Up @@ -2102,7 +2110,7 @@ def get_graph(self, assistant_id: str) -> dict[str, list[dict[str, Any]]]:


""" # noqa: E501
return self.http.get(f"/assistants/{assistant_id}/graph")
return self.http.get(f"/assistants/{assistant_id}/graph", params={"xray": xray})

def get_schemas(self, assistant_id: str) -> GraphSchema:
"""Get the schemas of an assistant by ID.
Expand Down
Loading