Skip to content

Commit

Permalink
Support if_not_exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 committed Oct 30, 2024
1 parent 74c8589 commit 69c8d21
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libs/sdk-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{

Check notice on line 1 in libs/sdk-js/package.json

View workflow job for this annotation

GitHub Actions / benchmark

Benchmark results

......................................... fanout_to_subgraph_10x: Mean +- std dev: 48.2 ms +- 0.7 ms ......................................... fanout_to_subgraph_10x_sync: Mean +- std dev: 46.2 ms +- 3.4 ms ......................................... fanout_to_subgraph_10x_checkpoint: Mean +- std dev: 75.8 ms +- 1.4 ms ......................................... fanout_to_subgraph_10x_checkpoint_sync: Mean +- std dev: 84.5 ms +- 1.3 ms ......................................... fanout_to_subgraph_100x: Mean +- std dev: 479 ms +- 18 ms ......................................... fanout_to_subgraph_100x_sync: Mean +- std dev: 429 ms +- 6 ms ......................................... fanout_to_subgraph_100x_checkpoint: Mean +- std dev: 845 ms +- 55 ms ......................................... fanout_to_subgraph_100x_checkpoint_sync: Mean +- std dev: 836 ms +- 18 ms ......................................... react_agent_10x: Mean +- std dev: 28.9 ms +- 0.6 ms ......................................... react_agent_10x_sync: Mean +- std dev: 22.4 ms +- 1.7 ms ......................................... react_agent_10x_checkpoint: Mean +- std dev: 47.3 ms +- 3.2 ms ......................................... react_agent_10x_checkpoint_sync: Mean +- std dev: 37.7 ms +- 3.4 ms ......................................... react_agent_100x: Mean +- std dev: 328 ms +- 14 ms ......................................... react_agent_100x_sync: Mean +- std dev: 261 ms +- 14 ms ......................................... react_agent_100x_checkpoint: Mean +- std dev: 928 ms +- 24 ms ......................................... react_agent_100x_checkpoint_sync: Mean +- std dev: 842 ms +- 25 ms ......................................... wide_state_25x300: Mean +- std dev: 18.3 ms +- 0.3 ms ......................................... wide_state_25x300_sync: Mean +- std dev: 11.0 ms +- 0.2 ms ......................................... wide_state_25x300_checkpoint: Mean +- std dev: 274 ms +- 4 ms ......................................... wide_state_25x300_checkpoint_sync: Mean +- std dev: 261 ms +- 2 ms ......................................... wide_state_15x600: Mean +- std dev: 21.2 ms +- 0.4 ms ......................................... wide_state_15x600_sync: Mean +- std dev: 12.6 ms +- 0.2 ms ......................................... wide_state_15x600_checkpoint: Mean +- std dev: 472 ms +- 6 ms ......................................... wide_state_15x600_checkpoint_sync: Mean +- std dev: 469 ms +- 15 ms ......................................... wide_state_9x1200: Mean +- std dev: 21.3 ms +- 0.4 ms ......................................... wide_state_9x1200_sync: Mean +- std dev: 12.6 ms +- 0.1 ms ......................................... wide_state_9x1200_checkpoint: Mean +- std dev: 307 ms +- 5 ms ......................................... wide_state_9x1200_checkpoint_sync: Mean +- std dev: 304 ms +- 15 ms

Check notice on line 1 in libs/sdk-js/package.json

View workflow job for this annotation

GitHub Actions / benchmark

Comparison against main

+-----------------------------------------+---------+-----------------------+ | Benchmark | main | changes | +=========================================+=========+=======================+ | fanout_to_subgraph_10x | 54.9 ms | 48.2 ms: 1.14x faster | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_checkpoint | 77.6 ms | 75.8 ms: 1.02x faster | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_checkpoint_sync | 85.9 ms | 84.5 ms: 1.02x faster | +-----------------------------------------+---------+-----------------------+ | react_agent_10x | 29.3 ms | 28.9 ms: 1.01x faster | +-----------------------------------------+---------+-----------------------+ | wide_state_15x600 | 21.4 ms | 21.2 ms: 1.01x faster | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_checkpoint_sync | 844 ms | 836 ms: 1.01x faster | +-----------------------------------------+---------+-----------------------+ | wide_state_15x600_sync | 12.7 ms | 12.6 ms: 1.01x faster | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_sync | 431 ms | 429 ms: 1.01x faster | +-----------------------------------------+---------+-----------------------+ | wide_state_25x300_sync | 11.0 ms | 11.0 ms: 1.00x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_25x300_checkpoint | 272 ms | 274 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_25x300_checkpoint_sync | 259 ms | 261 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_9x1200_checkpoint | 305 ms | 307 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_15x600_checkpoint_sync | 465 ms | 469 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x | 473 ms | 479 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_100x_checkpoint | 907 ms | 928 ms: 1.02x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_100x_checkpoint_sync | 809 ms | 842 ms: 1.04x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_checkpoint | 799 ms | 845 ms: 1.06x slower | +-----------------------------------------+---------+-----------------------+ | Geometric mean | (ref) | 1.00x faster | +-----------------------------------------+---------+-----------------------+ Benchmark hidden because not significant (11): fanout_to_subgraph_10x_sync, react_agent_100x, react_agent_10x_checkpoint, wide_state_9x1200, react_agent_100x_sync, wide_state_25x300, react_agent_10x_sync, wide_state_9x1200_sync, wide_state_15x600_checkpoint, react_agent_10x_checkpoint_sync, wide_state_9x1200_checkpoint_sync
"name": "@langchain/langgraph-sdk",
"version": "0.0.19",
"version": "0.0.20",
"description": "Client library for interacting with the LangGraph API",
"type": "module",
"packageManager": "[email protected]",
Expand Down
5 changes: 5 additions & 0 deletions libs/sdk-js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export class CronsClient extends BaseClient {
interrupt_after: payload?.interruptAfter,
webhook: payload?.webhook,
multitask_strategy: payload?.multitaskStrategy,
if_not_exists: payload?.ifNotExists,
};
return this.fetch<Run>(`/threads/${threadId}/runs/crons`, {
method: "POST",
Expand Down Expand Up @@ -187,6 +188,7 @@ export class CronsClient extends BaseClient {
interrupt_after: payload?.interruptAfter,
webhook: payload?.webhook,
multitask_strategy: payload?.multitaskStrategy,
if_not_exists: payload?.ifNotExists,
};
return this.fetch<Run>(`/runs/crons`, {
method: "POST",
Expand Down Expand Up @@ -698,6 +700,7 @@ export class RunsClient extends BaseClient {
on_completion: payload?.onCompletion,
on_disconnect: payload?.onDisconnect,
after_seconds: payload?.afterSeconds,
if_not_exists: payload?.ifNotExists,
};

const endpoint =
Expand Down Expand Up @@ -779,6 +782,7 @@ export class RunsClient extends BaseClient {
checkpoint_id: payload?.checkpointId,
multitask_strategy: payload?.multitaskStrategy,
after_seconds: payload?.afterSeconds,
if_not_exists: payload?.ifNotExists,
};
return this.fetch<Run>(`/threads/${threadId}/runs`, {
method: "POST",
Expand Down Expand Up @@ -849,6 +853,7 @@ export class RunsClient extends BaseClient {
on_completion: payload?.onCompletion,
on_disconnect: payload?.onDisconnect,
after_seconds: payload?.afterSeconds,
if_not_exists: payload?.ifNotExists,
};
const endpoint =
threadId == null ? `/runs/wait` : `/threads/${threadId}/runs/wait`;
Expand Down
5 changes: 5 additions & 0 deletions libs/sdk-js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ interface RunsInvokePayload {
* Use to schedule future runs.
*/
afterSeconds?: number;

/**
* Behavior if the specified run doesn't exist. Defaults to "reject".
*/
ifNotExists?: "create" | "reject";
}

export interface RunsStreamPayload extends RunsInvokePayload {
Expand Down

0 comments on commit 69c8d21

Please sign in to comment.