feat(sdk-js): improve types for drawable graph, interrupts and metadata

This commit is contained in:
Tat Dat Duong
2024-11-02 02:48:47 +01:00
parent 18cea39090
commit 39dcafcdea
2 changed files with 30 additions and 5 deletions
+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