From 960bab2b3296cd00ee005911bde8534c37c491cd Mon Sep 17 00:00:00 2001 From: William Fu-Hinthorn <13333726+hinthornw@users.noreply.github.com> Date: Thu, 19 Sep 2024 14:20:07 -0700 Subject: [PATCH 1/2] [TS] type as string --- js/src/schemas.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/js/src/schemas.ts b/js/src/schemas.ts index 274a76bb6..ae72df101 100644 --- a/js/src/schemas.ts +++ b/js/src/schemas.ts @@ -4,9 +4,9 @@ export interface TracerSession { // The ID of the project (alias for session) id: string; // The start time of the project - start_time: number; + start_time: string; // The end time of the project - end_time?: number; + end_time?: string; // A description of the project description?: string; // The name of the project @@ -33,7 +33,7 @@ export interface TracerSessionResult extends TracerSession { // The total number of completion tokens consumed in the session. completion_tokens?: number; // The start time of the last run in the session. - last_run_start_time?: number; + last_run_start_time?: string; // Feedback stats for the session. feedback_stats?: Record; // Facets for the runs in the session. @@ -75,13 +75,13 @@ export interface BaseRun { name: string; /** The epoch time at which the run started, if available. */ - start_time?: number; + start_time?: string; /** Specifies the type of run (tool, chain, llm, etc.). */ run_type: string; /** The epoch time at which the run ended, if applicable. */ - end_time?: number; + end_time?: string; /** Any additional metadata or settings for the run. */ extra?: KVMap; @@ -199,7 +199,7 @@ export interface RunCreate extends BaseRun { export interface RunUpdate { id?: string; - end_time?: number; + end_time?: string; extra?: KVMap; tags?: string[]; error?: string; @@ -272,7 +272,7 @@ export interface Dataset extends BaseDataset { modified_at: string; example_count?: number; session_count?: number; - last_session_start_time?: number; + last_session_start_time?: string; } export interface DatasetShareSchema { dataset_id: string; From 2266c892feae4f455ad57073ecca8bad4ab05a6c Mon Sep 17 00:00:00 2001 From: William Fu-Hinthorn <13333726+hinthornw@users.noreply.github.com> Date: Thu, 19 Sep 2024 14:28:51 -0700 Subject: [PATCH 2/2] uUuuUunion --- js/src/client.ts | 4 ++-- js/src/langchain.ts | 2 +- js/src/run_trees.ts | 6 +++--- js/src/schemas.ts | 24 +++++++++++++++++------- js/src/tests/client.int.test.ts | 1 + 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/js/src/client.ts b/js/src/client.ts index b7ef0beef..95d0216b3 100644 --- a/js/src/client.ts +++ b/js/src/client.ts @@ -224,8 +224,8 @@ interface CreateRunParams { inputs: KVMap; run_type: string; id?: string; - start_time?: number; - end_time?: number; + start_time?: number | string; + end_time?: number | string; extra?: KVMap; error?: string; serialized?: object; diff --git a/js/src/langchain.ts b/js/src/langchain.ts index ce815de9c..3cf20b01c 100644 --- a/js/src/langchain.ts +++ b/js/src/langchain.ts @@ -71,7 +71,7 @@ export async function getLangchainCallbacks( if (!current || visited.has(current.id)) continue; visited.add(current.id); - runMap.set(current.id, current); + runMap.set(current.id, current as Run); if (current.child_runs) { queue.push(...current.child_runs); } diff --git a/js/src/run_trees.ts b/js/src/run_trees.ts index 64cc7fb2b..ba0cc866d 100644 --- a/js/src/run_trees.ts +++ b/js/src/run_trees.ts @@ -14,7 +14,7 @@ function stripNonAlphanumeric(input: string) { } export function convertToDottedOrderFormat( - epoch: number, + epoch: number | string, runId: string, executionOrder = 1 ) { @@ -154,8 +154,8 @@ export class RunTree implements BaseRun { project_name: string; parent_run?: RunTree; child_runs: RunTree[]; - start_time: number; - end_time?: number; + start_time: number | string; + end_time?: number | string; extra: KVMap; tags?: string[]; error?: string; diff --git a/js/src/schemas.ts b/js/src/schemas.ts index ae72df101..641f0be9a 100644 --- a/js/src/schemas.ts +++ b/js/src/schemas.ts @@ -4,9 +4,9 @@ export interface TracerSession { // The ID of the project (alias for session) id: string; // The start time of the project - start_time: string; + start_time: number; // The end time of the project - end_time?: string; + end_time?: number; // A description of the project description?: string; // The name of the project @@ -33,7 +33,7 @@ export interface TracerSessionResult extends TracerSession { // The total number of completion tokens consumed in the session. completion_tokens?: number; // The start time of the last run in the session. - last_run_start_time?: string; + last_run_start_time?: number; // Feedback stats for the session. feedback_stats?: Record; // Facets for the runs in the session. @@ -75,13 +75,13 @@ export interface BaseRun { name: string; /** The epoch time at which the run started, if available. */ - start_time?: string; + start_time?: number | string; /** Specifies the type of run (tool, chain, llm, etc.). */ run_type: string; /** The epoch time at which the run ended, if applicable. */ - end_time?: string; + end_time?: number | string; /** Any additional metadata or settings for the run. */ extra?: KVMap; @@ -148,6 +148,10 @@ export interface Run extends BaseRun { /** The ID of the project that owns this run. */ session_id?: string; + start_time: string; + + end_time?: string; + /** IDs of any child runs spawned by this run. */ child_run_ids?: string[]; @@ -199,7 +203,7 @@ export interface RunCreate extends BaseRun { export interface RunUpdate { id?: string; - end_time?: string; + end_time?: number | string; extra?: KVMap; tags?: string[]; error?: string; @@ -272,7 +276,7 @@ export interface Dataset extends BaseDataset { modified_at: string; example_count?: number; session_count?: number; - last_session_start_time?: string; + last_session_start_time?: number; } export interface DatasetShareSchema { dataset_id: string; @@ -501,4 +505,10 @@ export interface RunWithAnnotationQueueInfo extends BaseRun { /** The time this run was added to the queue. */ added_at?: string; + + /** The ISO 8601 formatted string representing the start time of the run. */ + start_time: string; + + /** The ISO 8601 formatted string representing the end time of the run, if available. */ + end_time?: string; } diff --git a/js/src/tests/client.int.test.ts b/js/src/tests/client.int.test.ts index ddf160fa3..4ce6952ee 100644 --- a/js/src/tests/client.int.test.ts +++ b/js/src/tests/client.int.test.ts @@ -490,6 +490,7 @@ test.concurrent( id: runId, name: "foo", run_type: "llm", + start_time: new Date().toISOString(), inputs: { input: "hello world" }, outputs: { output: "hi there" }, };