Merge pull request #2310 from langchain-ai/dqbd/sdk-js-types

feat(sdk-js): improve types for drawable graph, interrupts and metadata
This commit is contained in:
David Duong
2024-11-04 13:26:58 +01:00
committed by GitHub
3 changed files with 31 additions and 6 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@langchain/langgraph-sdk",
"version": "0.0.20",
"version": "0.0.21",
"description": "Client library for interacting with the LangGraph API",
"type": "module",
"packageManager": "yarn@1.22.19",
+28 -3
View File
@@ -79,7 +79,17 @@ export interface GraphSchema {
export type Subgraphs = Record<string, GraphSchema>;
export type Metadata = Optional<Record<string, unknown>>;
export type Metadata = Optional<{
source?: "input" | "loop" | "update" | (string & {});
step?: number;
writes?: Record<string, unknown> | null;
parents?: Record<string, string>;
[key: string]: unknown;
}>;
export interface AssistantBase {
/** The ID of the assistant. */
@@ -110,7 +120,22 @@ export interface Assistant extends AssistantBase {
/** The name of the assistant */
name: string;
}
export type AssistantGraph = Record<string, Array<Record<string, unknown>>>;
export interface AssistantGraph {
nodes: Array<{
id: string | number;
name?: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data?: Record<string, any> | string;
metadata?: unknown;
}>;
edges: Array<{
source: string;
target: string;
data?: string;
conditional?: boolean;
}>;
}
export interface Thread<ValuesType = DefaultValues> {
/** The ID of the thread. */
@@ -184,7 +209,7 @@ export interface ThreadTask {
id: string;
name: string;
error: Optional<string>;
interrupts: Array<Record<string, unknown>>;
interrupts: Array<{ value: unknown; when: "during" }>;
checkpoint: Optional<Checkpoint>;
state: Optional<ThreadState>;
}
+2 -2
View File
@@ -45,12 +45,12 @@ interface RunsInvokePayload {
/**
* Interrupt execution before entering these nodes.
*/
interruptBefore?: string[];
interruptBefore?: "*" | string[];
/**
* Interrupt execution after leaving these nodes.
*/
interruptAfter?: string[];
interruptAfter?: "*" | string[];
/**
* Strategy to handle concurrent runs on the same thread. Only relevant if