UNPKG

parea-ai

Version:

Client SDK library to connect to Parea AI.

68 lines (67 loc) 2.38 kB
import { EvalFunction, TraceLog, TraceOptions } from '../../types'; /** * Represents a trace for logging and tracking execution of operations. */ export declare class Trace { readonly id: string; readonly name: string; readonly startTime: Date; depth: number; executionOrder: number; private parentId?; private rootId; private endTime?; private children; private log; private evalFuncs; private isRunningEval; /** * Creates a new Trace instance. * @param name - The name of the trace. * @param options - Optional configuration options for the trace. * @param parentId - The ID of the parent trace, if any. * @param rootId - The ID of the root trace, if any. * @param depth - The depth of the trace in the execution tree. * @param executionOrder - The order of execution for this trace. */ constructor(name: string, options?: TraceOptions, parentId?: string, rootId?: string, depth?: number, executionOrder?: number); /** * Adds a child trace ID to this trace. * @param childId - The ID of the child trace to add. */ addChild(childId: string): void; /** * Finalizes the trace by setting the end time, calculating latency, and sending the log. */ finalize(): void; /** * Returns the current log data for this trace. * @returns The partial TraceLog object. */ getLog(): Partial<TraceLog>; /** * Sets the trace as currently running an evaluation function. * @param state - Whether the trace is running */ setIsRunningEval(state: boolean): void; /** * Returns whether the trace is currently running an evaluation function. * @returns Boolean indicating if the trace is running eval. */ getIsRunningEval(): boolean; /** * Returns the evaluation functions associated with this trace. * @returns An array of EvalFunction objects. */ getEvalFuncs(): EvalFunction[]; /** * Updates the log data with new information. * @param data - Partial TraceLog object containing the data to update. */ updateLog(data: Partial<TraceLog>): void; /** * Sends the log data to the pareaLogger for recording. * @throws Will log an error to the console if there's an issue recording or initiating the log. */ sendLog(): void; }