Skip to content

Commit

Permalink
Merge pull request #2237 from langchain-ai/jacob/sdk
Browse files Browse the repository at this point in the history
feat(sdk-js): Support if_not_exists in SDK runs
  • Loading branch information
dqbd authored Oct 30, 2024
2 parents 74c8589 + 69c8d21 commit ae412bb
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 @@
{
"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 ae412bb

Please sign in to comment.