@gentrace/core
Version:
Core Gentrace Node.JS library
2,126 lines (2,016 loc) • 163 kB
TypeScript
/// <reference types="node" />
import type { AxiosInstance } from "axios";
import type { AxiosPromise } from "axios";
import type { AxiosRequestConfig } from "axios";
import { AxiosResponse } from "axios";
import type { ZodType } from "zod";
declare type AnyFn = (...args: any[]) => any;
/**
*
* @export
* @class BaseAPI
*/
declare class BaseAPI {
protected basePath: string;
protected axios: AxiosInstance;
protected configuration: Configuration | undefined;
constructor(
configuration?: Configuration,
basePath?: string,
axios?: AxiosInstance,
);
}
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface BooleanType
*/
declare interface BooleanType {
/**
*
* @type {string}
* @memberof BooleanType
*/
type: BooleanTypeTypeEnum;
/**
*
* @type {boolean}
* @memberof BooleanType
*/
value: boolean;
}
declare const BooleanTypeTypeEnum: {
readonly Boolean: "boolean";
};
declare type BooleanTypeTypeEnum =
(typeof BooleanTypeTypeEnum)[keyof typeof BooleanTypeTypeEnum];
export declare function bulkCreateEvaluations(
evaluations: Array<CreateEvaluationV2>,
): Promise<V2EvaluationsBulkPost200Response>;
export declare class Configuration {
/**
* parameter for apiKey security
* @param name security name
* @memberof Configuration
*/
apiKey?:
| string
| Promise<string>
| ((name: string) => string)
| ((name: string) => Promise<string>);
/**
* parameter for basic security
*
* @type {string}
* @memberof Configuration
*/
username?: string;
/**
* parameter for basic security
*
* @type {string}
* @memberof Configuration
*/
password?: string;
/**
* parameter for oauth2 security
* @param name security name
* @param scopes oauth2 scope
* @memberof Configuration
*/
accessToken?:
| string
| Promise<string>
| ((name?: string, scopes?: string[]) => string)
| ((name?: string, scopes?: string[]) => Promise<string>);
/**
* override base path
*
* @type {string}
* @memberof Configuration
*/
basePath?: string;
/**
* base options for axios calls
*
* @type {any}
* @memberof Configuration
*/
baseOptions?: any;
/**
* The FormData constructor that will be used to create multipart form data
* requests. You can inject this here so that execution environments that
* do not support the FormData class can still run the generated client.
*
* @type {new () => FormData}
*/
formDataCtor?: new () => any;
/**
* Custom logger that clients can provide to capture logs/warnings/errors from the SDK.
*/
logger?: {
info: (message: string, context?: any) => void;
warn: (message: string | Error, context?: any) => void;
};
constructor(param?: ConfigurationParameters);
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime: string): boolean;
}
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export declare interface ConfigurationParameters {
apiKey?:
| string
| Promise<string>
| ((name: string) => string)
| ((name: string) => Promise<string>);
username?: string;
password?: string;
accessToken?:
| string
| Promise<string>
| ((name?: string, scopes?: string[]) => string)
| ((name?: string, scopes?: string[]) => Promise<string>);
basePath?: string;
baseOptions?: any;
formDataCtor?: new () => any;
logger?: {
info: (message: string, context?: any) => void;
warn: (message: string | Error, context?: any) => void;
};
}
export declare const constructSubmissionPayloadAdvanced: (
pipelineIdentifier: string,
testRuns: TestRun[],
context?: ResultContext,
triggerRemoteEvals?: boolean,
) => TestResultPostRequest;
export declare const constructSubmissionPayloadSimple: (
pipelineSlug: string,
testRuns: V1TestResultSimplePostRequestTestRunsInner[],
context?: ResultContext,
) => V1TestResultSimplePostRequest;
export declare type Context = PipelineRunContext & CoreStepRunContext;
export declare type CoreStepRunContext = {
render?: {
type: "html";
key: string;
};
metadata?: Metadata;
};
/**
* Creates a new dataset in the Gentrace API.
* @async
* @param {CreateDatasetV2} payload - The dataset creation payload.
* @returns {Promise<DatasetV2>} - A promise that resolves to the created dataset.
* @throws {Error} - Throws an error if the Gentrace API key is not initialized.
*/
export declare const createDataset: (
payload: CreateDatasetV2,
) => Promise<DatasetV2>;
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface CreateDatasetV2
*/
declare interface CreateDatasetV2 {
/**
*
* @type {string}
* @memberof CreateDatasetV2
*/
name: string;
/**
*
* @type {string}
* @memberof CreateDatasetV2
*/
description?: string | null;
/**
*
* @type {string}
* @memberof CreateDatasetV2
*/
pipelineId?: string;
/**
*
* @type {string}
* @memberof CreateDatasetV2
*/
pipelineSlug?: string;
/**
*
* @type {boolean}
* @memberof CreateDatasetV2
*/
isGolden?: boolean;
}
export declare type CreateEvaluationType = CreateEvaluationV2;
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface CreateEvaluationV2
*/
declare interface CreateEvaluationV2 {
/**
* Optionally add a note to the evaluation
* @type {string}
* @memberof CreateEvaluationV2
*/
note?: string;
/**
* The ID of the evaluator. The evaluator and run must be in the same pipeline.
* @type {string}
* @memberof CreateEvaluationV2
*/
evaluatorId: string;
/**
* The ID of the run. The evaluator and run must be in the same pipeline.
* @type {string}
* @memberof CreateEvaluationV2
*/
runId: string;
/**
* If the evaluator output type is an enum, the label of the enum value.
* @type {string}
* @memberof CreateEvaluationV2
*/
evalLabel?: string;
/**
* If the evaluator output type is a percentage, a number between 0 and 1 representing the percentage.
* @type {number}
* @memberof CreateEvaluationV2
*/
evalValue?: number;
}
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface CreateFeedbackV2
*/
declare interface CreateFeedbackV2 {
/**
* The unique identifier for the pipeline run
* @type {string}
* @memberof CreateFeedbackV2
*/
pipelineRunId: string;
/**
* Timestamp in seconds since the UNIX epoch. Can be transformed into a Date object.
* @type {number}
* @memberof CreateFeedbackV2
*/
recordedTime: number;
/**
* The score of the feedback, ranging from 0 to 1
* @type {number}
* @memberof CreateFeedbackV2
*/
score: number;
/**
* Optional details about the feedback
* @type {string}
* @memberof CreateFeedbackV2
*/
details?: string | null;
}
/**
*
* @export
* @interface CreateMultipleTestCases
*/
declare interface CreateMultipleTestCases {
/**
* Slug for the pipeline
* @type {string}
* @memberof CreateMultipleTestCases
*/
pipelineSlug?: string;
/**
* ID of the dataset
* @type {string}
* @memberof CreateMultipleTestCases
*/
datasetId?: string;
/**
*
* @type {Array<CreateMultipleTestCasesTestCasesInner>}
* @memberof CreateMultipleTestCases
*/
testCases: Array<CreateMultipleTestCasesTestCasesInner>;
}
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface CreateMultipleTestCasesTestCasesInner
*/
declare interface CreateMultipleTestCasesTestCasesInner {
/**
* Name of the test case.
* @type {string}
* @memberof CreateMultipleTestCasesTestCasesInner
*/
name: string;
/**
* Input for the test case. Must be a valid JSON object and not an array.
* @type {{ [key: string]: any; }}
* @memberof CreateMultipleTestCasesTestCasesInner
*/
inputs: {
[key: string]: any;
};
/**
* Expected outputs for the test case
* @type {object}
* @memberof CreateMultipleTestCasesTestCasesInner
*/
expectedOutputs?: object;
}
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface CreateSingleTestCase
*/
declare interface CreateSingleTestCase {
/**
* Slug for the pipeline
* @type {string}
* @memberof CreateSingleTestCase
*/
pipelineSlug?: string;
/**
* ID of the dataset
* @type {string}
* @memberof CreateSingleTestCase
*/
datasetId?: string;
/**
* The name of the test case
* @type {string}
* @memberof CreateSingleTestCase
*/
name: string;
/**
* The input data for the test case as a JSON object
* @type {{ [key: string]: any; }}
* @memberof CreateSingleTestCase
*/
inputs: {
[key: string]: any;
};
/**
* The expected outputs for the test case as a JSON object
* @type {object}
* @memberof CreateSingleTestCase
*/
expectedOutputs?: object | null;
}
/**
* Creates a single test case for a given pipeline ID from the Gentrace API
*
* @async
* @param {CreateSingleTestCase} payload - New test case payload
* @throws {Error} Throws an error if the SDK is not initialized. Call init() first.
* @returns {Promise<string>} A Promise that resolves to the created case ID
* @remarks If a pipeline slug is specified, the golden dataset will be used.
* If a datasetId is provided, it will be used instead.
*/
export declare const createTestCase: (
payload: CreateSingleTestCase,
) => Promise<string>;
/**
* Creates multiple test cases for a given pipeline ID from the Gentrace API
*
* @async
* @param {CreateMultipleTestCases} payload - New test case payloads
* @throws {Error} Throws an error if the SDK is not initialized. Call init() first.
* @returns {Promise<string>} A Promise that resolves to the number of test cases successfully created
* @remarks If a pipeline slug is specified, the golden dataset will be used.
* If a datasetId is provided, it will be used instead.
*/
export declare const createTestCases: (
payload: CreateMultipleTestCases,
) => Promise<number>;
/**
* Creates test runners for a given pipeline using locally provided test data
* @param {Pipeline<{ [key: string]: GentracePlugin<any, any> }>} pipeline - The pipeline instance
* @param {LocalTestData[]} localData - Array of local test data objects
* @returns {Array<PipelineRunLocalDataTuple>} An array of PipelineRunTestCaseTuple
*/
export declare function createTestRunners(
pipeline: Pipeline<{
[key: string]: GentracePlugin<any, any>;
}>,
localData: LocalTestData[],
): Array<PipelineRunDataTuple>;
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface DatasetV2
*/
declare interface DatasetV2 {
/**
*
* @type {string}
* @memberof DatasetV2
*/
id: string;
/**
* Timestamp in seconds since the UNIX epoch. Can be transformed into a Date object.
* @type {number}
* @memberof DatasetV2
*/
createdAt: number;
/**
* Timestamp in seconds since the UNIX epoch. Can be transformed into a Date object.
* @type {number}
* @memberof DatasetV2
*/
updatedAt: number;
/**
* Timestamp in seconds since the UNIX epoch. Can be transformed into a Date object.
* @type {number}
* @memberof DatasetV2
*/
archivedAt?: number | null;
/**
*
* @type {string}
* @memberof DatasetV2
*/
name: string;
/**
*
* @type {string}
* @memberof DatasetV2
*/
description?: string | null;
/**
*
* @type {string}
* @memberof DatasetV2
*/
pipelineId: string;
}
export declare function defineInteraction<
T = any,
Fn extends InteractionFn<T> = InteractionFn<T>,
>(interaction: InteractionDefinition<T, Fn>): Fn;
export declare function defineTestSuite<Fn extends AnyFn>(testSuite: {
name: string;
fn: Fn;
}): Fn;
export declare function deinit(): void;
/**
* Deletes a single test case from the Gentrace API
*
* @async
* @param {string} id - The ID of the test case to delete
* @throws {Error} Throws an error if the SDK is not initialized or if the test case ID is invalid
* @returns {Promise<boolean>} A Promise that resolves to true if the test case was successfully deleted
* @remarks This function deletes an existing test case with the provided ID.
*/
export declare const deleteTestCase: (id: string) => Promise<boolean>;
export declare const enumParameter: ({
name,
options,
defaultValue,
}: {
name: string;
options: string[];
defaultValue: string;
}) => {
name: string;
getValue: () => string;
};
export declare type EvaluationType = EvaluationV2;
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface EvaluationV2
*/
declare interface EvaluationV2 {
/**
* The ID of the evaluation
* @type {string}
* @memberof EvaluationV2
*/
id: string;
/**
* Timestamp in seconds since the UNIX epoch. Can be transformed into a Date object.
* @type {number}
* @memberof EvaluationV2
*/
createdAt: number;
/**
* Timestamp in seconds since the UNIX epoch. Can be transformed into a Date object.
* @type {number}
* @memberof EvaluationV2
*/
updatedAt: number;
/**
* Indicates if the evaluation is pending
* @type {boolean}
* @memberof EvaluationV2
*/
isPending: boolean;
/**
* Indicates if the evaluation is filtered
* @type {boolean}
* @memberof EvaluationV2
*/
isFiltered: boolean;
/**
* Debug information for the evaluation
* @type {{ [key: string]: any; }}
* @memberof EvaluationV2
*/
debug?: {
[key: string]: any;
} | null;
/**
* The ID of the evaluator
* @type {string}
* @memberof EvaluationV2
*/
evaluatorId: string;
/**
* The ID of the run
* @type {string}
* @memberof EvaluationV2
*/
runId: string;
/**
* The ID of the comparison run, if applicable
* @type {string}
* @memberof EvaluationV2
*/
comparisonRunId?: string | null;
/**
* The name of the evaluation
* @type {string}
* @memberof EvaluationV2
*/
name: string | null;
/**
* The label of the evaluation
* @type {string}
* @memberof EvaluationV2
*/
evalLabel: string | null;
/**
* The value of the evaluation
* @type {number}
* @memberof EvaluationV2
*/
evalValue: number | null;
/**
* The email of the user who manually created the evaluation, if applicable
* @type {string}
* @memberof EvaluationV2
*/
manualCreatedByEmail?: string | null;
/**
* Additional notes for the evaluation
* @type {string}
* @memberof EvaluationV2
*/
note: string;
}
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface EvaluationV3
*/
declare interface EvaluationV3 {
/**
* The ID of the evaluation
* @type {string}
* @memberof EvaluationV3
*/
id: string;
/**
* Timestamp in seconds since the UNIX epoch. Can be transformed into a Date object.
* @type {number}
* @memberof EvaluationV3
*/
createdAt: number;
/**
* Timestamp in seconds since the UNIX epoch. Can be transformed into a Date object.
* @type {number}
* @memberof EvaluationV3
*/
updatedAt: number;
/**
* Indicates if the evaluation is pending
* @type {boolean}
* @memberof EvaluationV3
*/
isPending: boolean;
/**
* Indicates if the evaluation is filtered
* @type {boolean}
* @memberof EvaluationV3
*/
isFiltered: boolean;
/**
* Debug information for the evaluation
* @type {{ [key: string]: any; }}
* @memberof EvaluationV3
*/
debug?: {
[key: string]: any;
} | null;
/**
* The ID of the evaluator
* @type {string}
* @memberof EvaluationV3
*/
evaluatorId: string | null;
/**
* The ID of the run
* @type {string}
* @memberof EvaluationV3
*/
runId: string;
/**
* The ID of the comparison run, if applicable
* @type {string}
* @memberof EvaluationV3
*/
comparisonRunId?: string | null;
/**
* The name of the evaluation
* @type {string}
* @memberof EvaluationV3
*/
name: string | null;
/**
* The label of the evaluation
* @type {string}
* @memberof EvaluationV3
*/
evalLabel: string | null;
/**
* The value of the evaluation
* @type {number}
* @memberof EvaluationV3
*/
evalValue: number | null;
/**
* The email of the user who manually created the evaluation, if applicable
* @type {string}
* @memberof EvaluationV3
*/
manualCreatedByEmail?: string | null;
/**
* Additional notes for the evaluation
* @type {string}
* @memberof EvaluationV3
*/
note: string;
}
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface EvaluatorV2
*/
declare interface EvaluatorV2 {
/**
* The ID of the evaluator
* @type {string}
* @memberof EvaluatorV2
*/
id: string;
/**
* Timestamp in seconds since the UNIX epoch. Can be transformed into a Date object.
* @type {number}
* @memberof EvaluatorV2
*/
createdAt: number;
/**
* Timestamp in seconds since the UNIX epoch. Can be transformed into a Date object.
* @type {number}
* @memberof EvaluatorV2
*/
updatedAt: number;
/**
* Timestamp in seconds since the UNIX epoch. Can be transformed into a Date object.
* @type {number}
* @memberof EvaluatorV2
*/
archivedAt?: number | null;
/**
*
* @type {string}
* @memberof EvaluatorV2
*/
icon?: string | null;
/**
* The name of the evaluator
* @type {string}
* @memberof EvaluatorV2
*/
name: string;
/**
* For evaluators with options scoring, the available options to choose from
* @type {Array<any>}
* @memberof EvaluatorV2
*/
options?: Array<any> | null;
/**
* For AI evaluators, the AI model to use
* @type {string}
* @memberof EvaluatorV2
*/
aiModel?: string;
/**
* The ID of the pipeline that the evaluator belongs to
* @type {string}
* @memberof EvaluatorV2
*/
pipelineId?: string | null;
/**
* The ID of the processor associated with the evaluator
* @type {string}
* @memberof EvaluatorV2
*/
processorId?: string | null;
/**
* The ID of the organization that the evaluator belongs to
* @type {string}
* @memberof EvaluatorV2
*/
organizationId?: string;
/**
* For evaluator templates, the description of the template
* @type {string}
* @memberof EvaluatorV2
*/
templateDescription?: string;
/**
* For heuristic evaluators, the heuristic function to use
* @type {string}
* @memberof EvaluatorV2
*/
heuristicFn?: string | null;
/**
* For heuristic evaluators, the coding language of the heuristic function (such as \"JAVASCRIPT\", \"PYTHON\")
* @type {string}
* @memberof EvaluatorV2
*/
heuristicFnLanguage?: string;
/**
* For AI evaluators, the prompt template that should be sent to the AI model
* @type {string}
* @memberof EvaluatorV2
*/
aiPromptFormat?: string | null;
/**
* For AI image evaluators, the paths to the image URLs
* @type {Array<string>}
* @memberof EvaluatorV2
*/
aiImageUrls?: Array<string>;
/**
* For human evaluators, the instructions for the human to follow
* @type {string}
* @memberof EvaluatorV2
*/
humanPrompt?: string | null;
/**
* For classification evaluators, the path to the predicted classification
* @type {string}
* @memberof EvaluatorV2
*/
classifierValuePath?: string | null;
/**
* For classification evaluators, the path to the expected classification
* @type {string}
* @memberof EvaluatorV2
*/
classifierExpectedValuePath?: string | null;
/**
* For classification evaluators using multi-class evaluation, the available options to match with
* @type {Array<string>}
* @memberof EvaluatorV2
*/
multiClassOptions?: Array<string>;
/**
* The type of evaluator (such as \"AI\", \"HEURISTIC\", \"HUMAN\", \"CLASSIFIER\")
* @type {string}
* @memberof EvaluatorV2
*/
who: string;
/**
* The scoring method used by the evaluator (such as \"ENUM\", \"PERCENTAGE\")
* @type {string}
* @memberof EvaluatorV2
*/
valueType: string;
/**
* The run condition of the evaluator (such as \"TEST_PROD\", \"TEST\", \"PROD\", \"COMPARISON_2\")
* @type {string}
* @memberof EvaluatorV2
*/
runCondition: string;
/**
* Use \"samplingProbability\" instead
* @type {boolean}
* @memberof EvaluatorV2
* @deprecated
*/
prodEvalActive?: boolean;
/**
* When optionally running on production data, the associated sampling probability of this evaluator (from 0 to 100)
* @type {number}
* @memberof EvaluatorV2
*/
samplingProbability?: number | null;
}
/**
* @type ExpandedPipeline
* @export
*/
declare type ExpandedPipeline = ExpandedPipelineAllOf & Pipeline_2;
/**
*
* @export
* @interface ExpandedPipelineAllOf
*/
declare interface ExpandedPipelineAllOf {
/**
*
* @type {Array<TestEvaluator>}
* @memberof ExpandedPipelineAllOf
*/
evaluators?: Array<TestEvaluator>;
}
/**
* @type ExpandedTestResult
* @export
*/
declare type ExpandedTestResult = ExpandedTestResultAllOf & TestResult;
/**
*
* @export
* @interface ExpandedTestResultAllOf
*/
declare interface ExpandedTestResultAllOf {
/**
*
* @type {ExpandedPipeline}
* @memberof ExpandedTestResultAllOf
*/
pipeline?: ExpandedPipeline;
/**
*
* @type {Array<ExpandedTestRun>}
* @memberof ExpandedTestResultAllOf
*/
runs?: Array<ExpandedTestRun>;
}
/**
* @type ExpandedTestRun
* @export
*/
declare type ExpandedTestRun = ExpandedTestRunAllOf & TestRun_2;
/**
*
* @export
* @interface ExpandedTestRunAllOf
*/
declare interface ExpandedTestRunAllOf {
/**
*
* @type {FullRun}
* @memberof ExpandedTestRunAllOf
*/
full?: FullRun;
/**
*
* @type {Array<ResolvedStepRun>}
* @memberof ExpandedTestRunAllOf
*/
steps?: Array<ResolvedStepRun>;
/**
*
* @type {TestCase}
* @memberof ExpandedTestRunAllOf
*/
case?: TestCase;
/**
*
* @type {Array<TestEvaluation>}
* @memberof ExpandedTestRunAllOf
*/
evaluations?: Array<TestEvaluation>;
/**
* Error message if the test run failed
* @type {string}
* @memberof ExpandedTestRunAllOf
*/
error?: string | null;
}
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface FeedbackRequest
*/
export declare interface FeedbackRequest {
/**
*
* @type {string}
* @memberof FeedbackRequest
*/
pipelineRunId: string;
/**
*
* @type {number}
* @memberof FeedbackRequest
*/
score: number;
/**
*
* @type {string}
* @memberof FeedbackRequest
*/
recordedTime: string;
/**
*
* @type {string}
* @memberof FeedbackRequest
*/
details?: string | null;
}
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface FeedbackResponse
*/
export declare interface FeedbackResponse {
/**
*
* @type {string}
* @memberof FeedbackResponse
*/
message: string;
}
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface FeedbackV2
*/
declare interface FeedbackV2 {
/**
* The unique identifier for the feedback
* @type {string}
* @memberof FeedbackV2
*/
id: string;
/**
* The unique identifier for the pipeline run
* @type {string}
* @memberof FeedbackV2
*/
pipelineRunId: string;
/**
* The score of the feedback, ranging from 0 to 1
* @type {number}
* @memberof FeedbackV2
*/
score: number;
/**
* Optional details about the feedback
* @type {string}
* @memberof FeedbackV2
*/
details?: string | null;
/**
* Timestamp in seconds since the UNIX epoch. Can be transformed into a Date object.
* @type {number}
* @memberof FeedbackV2
*/
recordedTime: number;
}
/**
*
* @export
* @interface FilterableMetadataInputValue
*/
declare interface FilterableMetadataInputValue {
/**
* Specifies if the metadata key exists.
* @type {boolean}
* @memberof FilterableMetadataInputValue
*/
exists?: boolean;
/**
* The metadata value contains this string.
* @type {string}
* @memberof FilterableMetadataInputValue
*/
contains?: string;
/**
*
* @type {FilterableMetadataInputValueEquals}
* @memberof FilterableMetadataInputValue
*/
equals?: FilterableMetadataInputValueEquals;
/**
*
* @type {FilterableMetadataInputValueGt}
* @memberof FilterableMetadataInputValue
*/
gt?: FilterableMetadataInputValueGt;
/**
*
* @type {FilterableMetadataInputValueGte}
* @memberof FilterableMetadataInputValue
*/
gte?: FilterableMetadataInputValueGte;
/**
*
* @type {FilterableMetadataInputValueLt}
* @memberof FilterableMetadataInputValue
*/
lt?: FilterableMetadataInputValueLt;
/**
*
* @type {FilterableMetadataInputValueLte}
* @memberof FilterableMetadataInputValue
*/
lte?: FilterableMetadataInputValueLte;
}
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
* @type FilterableMetadataInputValueEquals
* The metadata value is equal to this value.
* @export
*/
declare type FilterableMetadataInputValueEquals = number | string;
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
* @type FilterableMetadataInputValueGt
* The metadata value is greater than this value.
* @export
*/
declare type FilterableMetadataInputValueGt = number | string;
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
* @type FilterableMetadataInputValueGte
* The metadata value is greater than or equal to this value.
* @export
*/
declare type FilterableMetadataInputValueGte = number | string;
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
* @type FilterableMetadataInputValueLt
* The metadata value is less than this value.
* @export
*/
declare type FilterableMetadataInputValueLt = number | string;
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
* @type FilterableMetadataInputValueLte
* The metadata value is less than or equal to this value.
* @export
*/
declare type FilterableMetadataInputValueLte = number | string;
export declare function flush(): Promise<boolean>;
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface FolderV2
*/
declare interface FolderV2 {
/**
* The ID of the folder
* @type {string}
* @memberof FolderV2
*/
id: string;
/**
* Timestamp in seconds since the UNIX epoch. Can be transformed into a Date object.
* @type {number}
* @memberof FolderV2
*/
createdAt: number;
/**
* Timestamp in seconds since the UNIX epoch. Can be transformed into a Date object.
* @type {number}
* @memberof FolderV2
*/
updatedAt: number;
/**
* The name of the folder
* @type {string}
* @memberof FolderV2
*/
name: string;
/**
* The ID of the organization that owns the folder
* @type {string}
* @memberof FolderV2
*/
organizationId: string;
/**
* The ID of the parent folder
* @type {string}
* @memberof FolderV2
*/
parentFolderId: string | null;
}
/**
*
* @export
* @interface FullRun
*/
declare interface FullRun {
/**
*
* @type {string}
* @memberof FullRun
*/
pipelineRunId: string;
/**
*
* @type {string}
* @memberof FullRun
*/
pipelineId: string;
/**
*
* @type {string}
* @memberof FullRun
*/
organizationId: string;
/**
*
* @type {string}
* @memberof FullRun
*/
startTime: string;
/**
*
* @type {string}
* @memberof FullRun
*/
endTime: string;
/**
*
* @type {number}
* @memberof FullRun
*/
cost?: number | null;
/**
*
* @type {number}
* @memberof FullRun
*/
elapsed?: number | null;
/**
*
* @type {number}
* @memberof FullRun
*/
feedback?: number | null;
/**
*
* @type {string}
* @memberof FullRun
*/
lastInvocation?: string | null;
/**
*
* @type {{ [key: string]: any; }}
* @memberof FullRun
*/
inputs?: {
[key: string]: any;
} | null;
/**
*
* @type {{ [key: string]: any; }}
* @memberof FullRun
*/
outputs?: {
[key: string]: any;
} | null;
/**
*
* @type {string}
* @memberof FullRun
*/
renderHTMLKey?: string | null;
/**
*
* @type {{ [key: string]: MetadataValueObject; }}
* @memberof FullRun
*/
metadata?: {
[key: string]: MetadataValueObject;
} | null;
/**
*
* @type {Array<RunPathSection>}
* @memberof FullRun
*/
path?: Array<RunPathSection> | null;
/**
*
* @type {string}
* @memberof FullRun
*/
error?: string | null;
}
export declare let GENTRACE_API_KEY:
| string
| Promise<string>
| ((name: string) => string)
| ((name: string) => Promise<string>);
export declare let GENTRACE_BASE_PATH: string;
export declare let GENTRACE_BRANCH: string;
export declare let GENTRACE_COMMIT: string;
export declare let GENTRACE_ENVIRONMENT_NAME: string;
export declare let GENTRACE_RESULT_NAME: string;
export declare let GENTRACE_RUN_NAME: string;
export declare let GENTRACE_SHOW_CONNECTION_ERRORS: string;
export declare abstract class GentracePlugin<C, A> {
abstract config: C;
abstract getConfig(): C;
abstract advanced<
T extends {
[key: string]: GentracePlugin<any, any>;
},
>(params: {
pipeline: Pipeline<T>;
pipelineRun: PipelineRun;
gentraceConfig: Configuration;
}): A;
}
/**
* Retrieves a single dataset from the Gentrace API.
* @async
* @param {string} id - The ID of the dataset to retrieve.
* @returns {Promise<DatasetV2>} - A promise that resolves to the retrieved dataset.
* @throws {Error} - Throws an error if the Gentrace API key is not initialized.
*/
export declare const getDataset: (id: string) => Promise<DatasetV2>;
/**
* Retrieves datasets from the Gentrace API.
* @async
* @param {Object} [params] - Optional parameters to filter the datasets.
* @param {string} [params.pipelineSlug] - The slug of the pipeline to filter datasets by.
* @param {string} [params.pipelineId] - The ID of the pipeline to filter datasets by.
* @param {boolean} [params.archived] - Filter datasets by archived status.
* @returns {Promise<Array<DatasetV2>>} - A promise that resolves to an array of datasets.
* @throws {Error} - Throws an error if the Gentrace API key is not initialized.
*/
export declare const getDatasets: (params?: {
pipelineSlug?: string;
pipelineId?: string;
archived?: boolean;
}) => Promise<DatasetV2[]>;
/**
* Retrieves evaluations for a specific result from the Gentrace API.
* @async
* @param {Object} params - The parameters for the function.
* @param {string} params.resultId - The ID of the result to get evaluations for.
* @returns {Promise<Array<EvaluationV2>>} - A promise that resolves to an array of evaluations.
* @throws {Error} - Throws an error if the Gentrace API key is not initialized.
*/
export declare const getEvaluations: ({
resultId,
}: {
resultId: string;
}) => Promise<EvaluationV3[]>;
/**
* Retrieves evaluators for a given pipeline from the Gentrace API
* @async
* @param {string} pipelineIdentifier - The pipeline slug, pipeline ID, or null (for evaluator templates)
* @throws {Error} Throws an error if the SDK is not initialized. Call init() first.
* @returns {Promise<Array<EvaluatorV2>>} A Promise that resolves with an array of evaluators.
*/
export declare const getEvaluators: (
pipelineIdentifier: string | null,
) => Promise<EvaluatorV2[]>;
export declare function getGentraceApiKey():
| string
| Promise<string>
| ((name: string) => string)
| ((name: string) => Promise<string>);
export declare function getGentraceBasePath(): string;
/**
* Retrieves pipelines from the Gentrace API.
* @async
* @param {PipelineParams} [params] - Optional parameters to filter the pipelines.
* @returns {Promise<Array<Pipeline>>} - A promise that resolves to an array of pipelines.
* @throws {Error} - Throws an error if the Gentrace API key is not initialized.
*/
export declare const getPipelines: (
params?: PipelineParams,
) => Promise<V1PipelinesGet200ResponsePipelinesInner[]>;
export declare const getRun: (id: string) => Promise<RunV2>;
export declare const getTestCase: (id: string) => Promise<TestCaseV2>;
/**
* Retrieves test cases for a given pipeline from the Gentrace API.
* @async
* @param {string} pipelineSlug - The slug of the pipeline to filter test cases by.
* @returns {Promise<Array<TestCase>>} - A promise that resolves to an array of test cases.
* @throws {Error} - Throws an error if the Gentrace API key is not initialized or if the pipeline is not found.
* @remarks The golden dataset for the specified pipeline will be used.
*/
export declare const getTestCases: (
pipelineSlug: string,
) => Promise<TestCase[]>;
/**
* Retrieves test cases for a specific dataset from the Gentrace API.
* @async
* @param {string} datasetId - The ID of the dataset to retrieve test cases for.
* @returns {Promise<Array<TestCase>>} - A promise that resolves to an array of test cases.
* @throws {Error} - Throws an error if the Gentrace API key is not initialized.
*/
export declare const getTestCasesForDataset: (
datasetId: string,
) => Promise<TestCase[]>;
export declare const getTestResult: (
resultId: string,
) => Promise<ExpandedTestResult>;
export declare const getTestResults: (
pipelineSlug?: string,
) => Promise<TestResult[]>;
export declare const getTestResultStatus: (
resultId: string,
) => Promise<StatusInfo>;
/**
* Retrieves test runners for a given pipeline
* @async
* @param {Pipeline<{ [key: string]: GentracePlugin<any, any> }>} pipeline - The pipeline instance
* @param {string} [datasetId] - Optional dataset ID to filter test cases by.
* @throws {Error} Throws an error if the SDK is not initialized. Call init() first.
* @returns {Promise<Array<PipelineRunDataTuple>>} A Promise that resolves with an array of PipelineRunDataTuple.
*/
export declare const getTestRunners: (
pipeline: Pipeline<{
[key: string]: GentracePlugin<any, any>;
}>,
datasetId?: string,
caseFilter?: (
testCase: Omit<TestCase, "createdAt" | "updatedAt" | "archivedAt">,
) => boolean,
) => Promise<Array<PipelineRunDataTuple>>;
export declare let globalGentraceApi: V1Api | null;
export declare let globalGentraceApiV2: V2Api | null;
export declare let globalGentraceApiV3: V3Api | null;
export declare let globalGentraceConfig: Configuration | null;
export declare let globalRequestBuffer: {
[pipelineRunId: string]: Promise<any>;
};
export declare function handleWebhook(
body: any,
sendResponse: (response: OutboundMessage) => void,
): Promise<void>;
export declare function init(values?: {
apiKey?:
| string
| Promise<string>
| ((name: string) => string)
| ((name: string) => Promise<string>);
basePath?: string;
branch?: string;
commit?: string;
showConnectionErrors?: string;
environmentName?: string;
runName?: string;
resultName?: string;
}): void;
export declare type InitPluginFunction<C extends object, A> = (
config: C | SimpleHandler<C>,
) => Promise<GentracePlugin<C, A>>;
declare type InteractionDefinition<
T extends any = any,
Fn extends InteractionFn<T> = InteractionFn<T>,
> = {
name: string;
fn: Fn;
parameters?:
| undefined
| {
name: string;
}[];
inputType?: undefined | ZodType<T>;
};
declare type InteractionFn<T = any> = (...args: [T, ...any[]]) => any;
declare type InteractionMetadata = {
name: string;
hasValidation: boolean;
parameters: Parameter[];
};
export declare function isConfig<C extends object>(
f: C | SimpleHandler<C>,
): f is C;
export declare function listen(values?: {
environmentName?: string | undefined;
}): Promise<void>;
/**
*
* @export
* @interface LocalEvaluation
*/
export declare interface LocalEvaluation {
/**
* The name of the local evaluation
* @type {string}
* @memberof LocalEvaluation
*/
name: string;
/**
* The numeric value of the evaluation
* @type {number}
* @memberof LocalEvaluation
*/
value: number;
/**
* Optional label for the evaluation
* @type {string}
* @memberof LocalEvaluation
*/
label?: string | null;
/**
*
* @type {LocalEvaluationDebug}
* @memberof LocalEvaluation
*/
debug?: LocalEvaluationDebug;
}
/**
*
* @export
* @interface LocalEvaluationDebug
*/
export declare interface LocalEvaluationDebug {
/**
* The resolved prompt used for the evaluation
* @type {string}
* @memberof LocalEvaluationDebug
*/
resolvedPrompt?: string;
/**
* The response received from the evaluation
* @type {string}
* @memberof LocalEvaluationDebug
*/
response?: string;
/**
* The final classification of the evaluation
* @type {string}
* @memberof LocalEvaluationDebug
*/
finalClassification?: string;
/**
* Processor logs
* @type {Array<Array<any>>}
* @memberof LocalEvaluationDebug
*/
processorLogs?: Array<Array<any>>;
/**
* Evaluator logs
* @type {Array<Array<any>>}
* @memberof LocalEvaluationDebug
*/
logs?: Array<Array<any>>;
/**
*
* @type {LocalEvaluationDebugError}
* @memberof LocalEvaluationDebug
*/
error?: LocalEvaluationDebugError;
}
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface LocalEvaluationDebugError
*/
export declare interface LocalEvaluationDebugError {
/**
* Error message
* @type {string}
* @memberof LocalEvaluationDebugError
*/
message?: string;
/**
* Date and time of the error
* @type {string}
* @memberof LocalEvaluationDebugError
*/
date?: string;
}
export declare type LocalTestData = {
name: string;
inputs: Record<string, any>;
expectedOutputs?: Record<string, any>;
};
declare type Metadata = {
[key: string]: MetadataValueObject;
};
/**
* @type MetadataValueObject
* @export
*/
declare type MetadataValueObject =
| ({
type: "boolean";
} & BooleanType)
| ({
type: "string";
} & StringType)
| ({
type: "url";
} & UrlType);
export declare const numericParameter: ({
name,
defaultValue,
}: {
name: string;
defaultValue: number;
}) => {
name: string;
getValue: () => number;
};
declare type OutboundMessage =
| OutboundMessageHeartbeat
| OutboundMessageEnvironmentDetails
| OutboundMessageRegisterInteraction
| OutboundMessageRegisterTestSuite
| OutboundMessageTestInteractionInputValidationResults
| OutboundMessageConfirmation;
declare type OutboundMessageConfirmation = {
type: "confirmation";
ok: boolean;
};
declare type OutboundMessageEnvironmentDetails = {
type: "environment-details";
interactions: InteractionMetadata[];
testSuites: {
name: string;
}[];
};
declare type OutboundMessageHeartbeat = {
type: "heartbeat";
};
declare type OutboundMessageRegisterInteraction = {
type: "register-interaction";
interaction: InteractionMetadata;
};
declare type OutboundMessageRegisterTestSuite = {
type: "register-test-suite";
testSuite: {
name: string;
};
};
declare type OutboundMessageTestInteractionInputValidationResults = {
type: "run-interaction-input-validation-results";
id: string;
interactionName: string;
data: {
id: string;
status: "success" | "failure";
error?: string;
}[];
};
declare type Parameter =
| {
type: "numeric";
name: string;
defaultValue: number;
}
| {
type: "string";
name: string;
defaultValue: string;
}
| {
type: "enum";
name: string;
defaultValue: string;
options: string[];
}
| {
type: "template";
name: string;
defaultValue: string;
variables: {
name: string;
example: any;
}[];
};
export declare type PartialStepRunType = Partial<StepRun>;
export declare class Pipeline<
T extends {
[key: string]: GentracePlugin<any, any>;
},
> {
id: string;
slug: string;
config: Configuration;
plugins: T;
constructor({
slug,
id,
apiKey,
basePath,
logger,
plugins,
}: {
slug?: string;
/**
* @deprecated Use the "slug" parameter instead
*/
id?: string;
/**
* @deprecated Declare the API key in the init() call instead.
*/
apiKey?:
| string
| Promise<string>
| ((name: string) => string)
| ((name: string) => Promise<string>);
/**
* @deprecated Declare the base path in the init() call instead.
*/
basePath?: string;
logger?: {
info: (message: string, context?: any) => void;
warn: (message: string | Error, context?: any) => void;
};
plugins?: T;
});
getLogger(): {
info: (message: string, context?: any) => void;
warn: (message: string | Error, context?: any) => void;
};
logInfo(message: string): void;
logWarn(e: Error | string): void;
start(context?: PluginContext): PipelineRun & {
[key in keyof T]: ReturnType<T[key]["advanced"]>;
};
}
/**
* Gentrace API
* These API routes are designed to ingest events from clients.
*
* The version of the OpenAPI document: 0.27.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface Pipeline
*/
declare interface Pipeline_2 {
/**
* The ID of the pipeline
* @type {string}
* @memberof Pipeline
*/
id: string;
/**
* The date and time when the pipeline was created
* @type {string}
* @memberof Pipeline
*/
createdAt: string;
/**
* The date and time when the pipeline was last updated
* @type {string}
* @memberof Pipeline
*/
updatedAt: string;
/**
* The date and time when the pipeline was archived, can be null if the pipeline has not been archived
* @type {string}
* @memberof Pipeline
*/
archivedAt?: string | null;
/**
* The labels attached to the pipeline
* @type {Array<string>}
* @memberof Pipeline
*/
labels: Array<string>;
/**
* The name of the pipeline
* @type {string}
* @memberof Pipeline
*/
displayName?: string | null;
/**
* The slug of the pipeline
* @type {string}
* @memberof Pipeline
*/
slug: string;
/**
* The ID of the organization that owns the pipeline
* @type {string}
* @memberof Pipeline
*/
organizationId: string;
/**
* The branch that the pipeline is associated with
* @type {string}
* @memberof Pipeline
*/
branch?: string | null;
/**
* The ID of the golden dataset associated with the pipeline
* @type {string}
* @memberof Pipeline
*/
goldenDatasetId: string | null;
}
declare interface PipelineLike {
slug: string;
config: Configuration;
logInfo: (message: string) => void;
logWarn: (message: string | Error) => void;
}
declare type PipelineParams = {
label?: string;
slug?: string;
};
export declare class PipelineRun {
private pipeline;
stepRuns: StepRun[];
private evaluations;
private path;
private error?;
context?: Context;
private id;
private instantiationTime;
constructor({
pipeline,
context,
}: {
pipeline: PipelineLike;
context?: Context;
});
getPipeline(): PipelineLike;
getId(): string;
getContext(): Context;
getError(): string;
setError(error: string | undefined): void;
updateContext(updatedContext: Partial<Context>): Context;
addStepRunNode(stepRun: StepRun): Promise<void>;
/**
* Creates a checkpoint by recording a `StepRun` instance with execution metadata and pushes it to `this.stepRuns`.
* If no prior `StepRun` instances exist, the elapsed time is set to 0 and the start and end times are set to the
* current timestamp. If it is empty, elapsed time is set to 0 and start time and end time are set to the current
* timestamp.
*
* @param {PRStepRunType & { inputs: any; outputs: any; }} step The information about the step to checkpoint.
* This includes the inputs and outputs of the step, as well as optional provider, invocation and modelParams metadata.
*
* @example
* const stepInfo = {
* providerName: 'MyProvider',
* invocation: 'doSomething',
* inputs: { x: