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): add ability to search runs via status #2592

Merged
merged 1 commit into from
Dec 3, 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
7 changes: 7 additions & 0 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: 61.9 ms +- 1.5 ms ......................................... fanout_to_subgraph_10x_sync: Mean +- std dev: 51.9 ms +- 1.1 ms ......................................... fanout_to_subgraph_10x_checkpoint: Mean +- std dev: 92.7 ms +- 8.1 ms ......................................... fanout_to_subgraph_10x_checkpoint_sync: Mean +- std dev: 94.3 ms +- 1.0 ms ......................................... fanout_to_subgraph_100x: Mean +- std dev: 608 ms +- 23 ms ......................................... fanout_to_subgraph_100x_sync: Mean +- std dev: 504 ms +- 5 ms ......................................... fanout_to_subgraph_100x_checkpoint: Mean +- std dev: 940 ms +- 39 ms ......................................... fanout_to_subgraph_100x_checkpoint_sync: Mean +- std dev: 928 ms +- 17 ms ......................................... react_agent_10x: Mean +- std dev: 31.1 ms +- 0.6 ms ......................................... react_agent_10x_sync: Mean +- std dev: 22.5 ms +- 0.2 ms ......................................... react_agent_10x_checkpoint: Mean +- std dev: 47.0 ms +- 0.9 ms ......................................... react_agent_10x_checkpoint_sync: Mean +- std dev: 36.7 ms +- 0.5 ms ......................................... react_agent_100x: Mean +- std dev: 344 ms +- 6 ms ......................................... react_agent_100x_sync: Mean +- std dev: 273 ms +- 4 ms ......................................... react_agent_100x_checkpoint: Mean +- std dev: 944 ms +- 9 ms ......................................... react_agent_100x_checkpoint_sync: Mean +- std dev: 844 ms +- 9 ms ......................................... wide_state_25x300: Mean +- std dev: 24.3 ms +- 0.5 ms ......................................... wide_state_25x300_sync: Mean +- std dev: 15.5 ms +- 0.2 ms ......................................... wide_state_25x300_checkpoint: Mean +- std dev: 278 ms +- 3 ms ......................................... wide_state_25x300_checkpoint_sync: Mean +- std dev: 265 ms +- 4 ms ......................................... wide_state_15x600: Mean +- std dev: 28.2 ms +- 0.5 ms ......................................... wide_state_15x600_sync: Mean +- std dev: 17.9 ms +- 0.1 ms ......................................... wide_state_15x600_checkpoint: Mean +- std dev: 480 ms +- 6 ms ......................................... wide_state_15x600_checkpoint_sync: Mean +- std dev: 463 ms +- 8 ms ......................................... wide_state_9x1200: Mean +- std dev: 28.3 ms +- 0.5 ms ......................................... wide_state_9x1200_sync: Mean +- std dev: 17.8 ms +- 0.1 ms ......................................... wide_state_9x1200_checkpoint: Mean +- std dev: 312 ms +- 2 ms ......................................... wide_state_9x1200_checkpoint_sync: Mean +- std dev: 297 ms +- 4 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_sync | 17.7 ms | 17.8 ms: 1.00x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_10x_checkpoint_sync | 36.6 ms | 36.7 ms: 1.00x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_15x600_checkpoint | 476 ms | 480 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_sync | 499 ms | 504 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_15x600 | 28.0 ms | 28.2 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_checkpoint_sync | 93.3 ms | 94.3 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_25x300_sync | 15.3 ms | 15.5 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_10x_sync | 22.3 ms | 22.5 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_15x600_sync | 17.7 ms | 17.9 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_10x_checkpoint | 46.4 ms | 47.0 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_10x | 30.7 ms | 31.1 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_100x_sync | 270 ms | 273 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_100x | 340 ms | 344 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_checkpoint | 927 ms | 940 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_checkpoint_sync | 914 ms | 928 ms: 1.02x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_9x1200 | 27.8 ms | 28.3 ms: 1.02x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_25x300 | 23.9 ms | 24.3 ms: 1.02x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_100x_checkpoint | 924 ms | 944 ms: 1.02x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_100x_checkpoint_sync | 823 ms | 844 ms: 1.03x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x | 593 ms | 608 ms: 1.03x slower | +-----------------------------------------+---------+-----------------------+ | Geometric mean | (ref) | 1.01x slower | +-----------------------------------------+---------+-----------------------+ Benchmark hidden because not significant (8): fanout_to_subgraph_10x_checkpoint, wide_state_25x300_checkpoint_sync, fanout_to_subgraph_10x_sync, fanout_to_subgraph_10x, wide_state_9x1200_checkpoint_sync, wide_state_9x1200_checkpoint, wide_state_15x600_checkpoint_sync, wide_state_25x300_checkpoint
Assistant,
AssistantGraph,
CancelAction,
Expand All @@ -7,6 +7,7 @@
GraphSchema,
Metadata,
Run,
RunStatus,
Thread,
ThreadState,
Cron,
Expand Down Expand Up @@ -944,12 +945,18 @@
* Defaults to 0.
*/
offset?: number;

/**
* Status of the run to filter by.
*/
status?: RunStatus;
},
): Promise<Run[]> {
return this.fetch<Run[]>(`/threads/${threadId}/runs`, {
params: {
limit: options?.limit ?? 10,
offset: options?.offset ?? 0,
status: options?.status ?? undefined,
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion libs/sdk-js/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { JSONSchema7 } from "json-schema";

type Optional<T> = T | null | undefined;

type RunStatus =
export type RunStatus =
| "pending"
| "running"
| "error"
Expand Down
19 changes: 15 additions & 4 deletions libs/sdk-py/langgraph_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
OnConflictBehavior,
Run,
RunCreate,
RunStatus,
SearchItemsResponse,
StreamMode,
StreamPart,
Expand Down Expand Up @@ -1684,14 +1685,20 @@ async def wait(
return response

async def list(
self, thread_id: str, *, limit: int = 10, offset: int = 0
self,
thread_id: str,
*,
limit: int = 10,
offset: int = 0,
status: Optional[RunStatus] = None,
) -> List[Run]:
"""List runs.

Args:
thread_id: The thread ID to list runs for.
limit: The maximum number of results to return.
offset: The number of results to skip.
status: The status of the run to filter by.

Returns:
List[Run]: The runs for the thread.
Expand All @@ -1705,9 +1712,13 @@ async def list(
)

""" # noqa: E501
return await self.http.get(
f"/threads/{thread_id}/runs?limit={limit}&offset={offset}"
)
params = {
"limit": limit,
"offset": offset,
}
if status is not None:
params["status"] = status
return await self.http.get(f"/threads/{thread_id}/runs", params=params)

async def get(self, thread_id: str, run_id: str) -> Run:
"""Get a run.
Expand Down
Loading