Skip to content

Commit

Permalink
Merge pull request #1844 from langchain-ai:dqbd/js-sdk-0.0.12-types
Browse files Browse the repository at this point in the history
fix(sdk-js): match schema types, bump to 0.0.12
  • Loading branch information
dqbd authored Sep 25, 2024
2 parents f05b546 + 68fb04b commit f337d5d
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 6 deletions.
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.11",
"version": "0.0.12",
"description": "Client library for interacting with the LangGraph API",
"type": "module",
"packageManager": "[email protected]",
Expand Down
94 changes: 89 additions & 5 deletions libs/sdk-js/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type RunStatus =

type ThreadStatus = "idle" | "busy" | "interrupted";

type MultitaskStrategy = "reject" | "interrupt" | "rollback" | "enqueue";

export interface Config {
/**
* Tags for this call and any sub-calls (eg. a Chain calling an LLM).
Expand Down Expand Up @@ -76,60 +78,142 @@ export interface GraphSchema {
export type Metadata = Optional<Record<string, unknown>>;

export interface AssistantBase {
/** The ID of the assistant. */
assistant_id: string;

/** The ID of the graph. */
graph_id: string;

/** The assistant config. */
config: Config;

/** The time the assistant was created. */
created_at: string;

/** The assistant metadata. */
metadata: Metadata;

/** The version of the assistant. */
version: number;
}

export interface AssistantVersion extends AssistantBase {}

export interface Assistant extends AssistantBase {
/** The last time the assistant was updated. */
updated_at: string;

/** The name of the assistant */
name: string;
}
export type AssistantGraph = Record<string, Array<Record<string, unknown>>>;

export interface Thread {
export interface Thread<ValuesType = DefaultValues> {
/** The ID of the thread. */
thread_id: string;

/** The time the thread was created. */
created_at: string;

/** The last time the thread was updated. */
updated_at: string;

/** The thread metadata. */
metadata: Metadata;

/** The status of the thread */
status: ThreadStatus;

/** The current state of the thread. */
values: ValuesType;
}

export interface Cron {
/** The ID of the cron */
cron_id: string;

/** The ID of the thread */
thread_id: Optional<string>;

/** The end date to stop running the cron. */
end_time: Optional<string>;

/** The schedule to run, cron format. */
schedule: string;

/** The time the cron was created. */
created_at: string;

/** The last time the cron was updated. */
updated_at: string;

/** The run payload to use for creating new run. */
payload: Record<string, unknown>;
}

export type DefaultValues = Record<string, unknown>[] | Record<string, unknown>;

export interface ThreadState<ValuesType = DefaultValues> {
/** The state values */
values: ValuesType;

/** The next nodes to execute. If empty, the thread is done until new input is received */
next: string[];
checkpoint_id: string;

/** Checkpoint of the thread state */
checkpoint: Checkpoint;

/** Metadata for this state */
metadata: Metadata;

/** Time of state creation */
created_at: Optional<string>;
parent_checkpoint_id: Optional<string>;

config: Config;
parent_config?: Config;
/** The parent checkpoint. If missing, this is the root checkpoint */
parent_checkpoint: Optional<Checkpoint>;

/** Tasks to execute in this step. If already attempted, may contain an error */
tasks: Array<ThreadTask>;
}

export interface ThreadTask {
id: string;
name: string;
error: Optional<string>;
interrupts: Array<Record<string, unknown>>;
checkpoint: Optional<Checkpoint>;
state: Optional<ThreadState>;
}

export interface Run {
/** The ID of the run */
run_id: string;

/** The ID of the thread */
thread_id: string;

/** The assistant that wwas used for this run */
assistant_id: string;

/** The time the run was created */
created_at: string;

/** The last time the run was updated */
updated_at: string;

/** The status of the run. */
status: RunStatus;

/** Run metadata */
metadata: Metadata;

/** Strategy to handle concurrent runs on the same thread */
multitask_strategy: Optional<MultitaskStrategy>;
}

export interface Checkpoint {
thread_id: string;
checkpoint_ns: string;
checkpoint_id: Optional<string>;
checkpoint_map: Optional<Record<string, unknown>>;
}

0 comments on commit f337d5d

Please sign in to comment.