@anyway-sh/node-server-sdk 0.22.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README +35 -0
- package/dist/index.d.ts +1957 -0
- package/dist/index.js +4458 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4382 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/lib/associations/associations.d.ts +32 -0
- package/dist/src/lib/client/annotation/base-annotation.d.ts +20 -0
- package/dist/src/lib/client/annotation/user-feedback.d.ts +32 -0
- package/dist/src/lib/client/dataset/attachment-uploader.d.ts +50 -0
- package/dist/src/lib/client/dataset/attachment.d.ts +84 -0
- package/dist/src/lib/client/dataset/base-dataset.d.ts +10 -0
- package/dist/src/lib/client/dataset/column.d.ts +23 -0
- package/dist/src/lib/client/dataset/dataset.d.ts +43 -0
- package/dist/src/lib/client/dataset/datasets.d.ts +14 -0
- package/dist/src/lib/client/dataset/index.d.ts +8 -0
- package/dist/src/lib/client/dataset/row.d.ts +73 -0
- package/dist/src/lib/client/evaluator/evaluator.d.ts +28 -0
- package/dist/src/lib/client/evaluator/index.d.ts +2 -0
- package/dist/src/lib/client/experiment/experiment.d.ts +76 -0
- package/dist/src/lib/client/experiment/index.d.ts +2 -0
- package/dist/src/lib/client/traceloop-client.d.ts +40 -0
- package/dist/src/lib/configuration/index.d.ts +35 -0
- package/dist/src/lib/configuration/validation.d.ts +3 -0
- package/dist/src/lib/errors/index.d.ts +36 -0
- package/dist/src/lib/generated/evaluators/index.d.ts +5 -0
- package/dist/src/lib/generated/evaluators/mbt-evaluators.d.ts +386 -0
- package/dist/src/lib/generated/evaluators/registry.d.ts +12 -0
- package/dist/src/lib/generated/evaluators/types.d.ts +401 -0
- package/dist/src/lib/images/image-uploader.d.ts +15 -0
- package/dist/src/lib/images/index.d.ts +2 -0
- package/dist/src/lib/interfaces/annotations.interface.d.ts +35 -0
- package/dist/src/lib/interfaces/dataset.interface.d.ts +105 -0
- package/dist/src/lib/interfaces/evaluator.interface.d.ts +83 -0
- package/dist/src/lib/interfaces/experiment.interface.d.ts +117 -0
- package/dist/src/lib/interfaces/index.d.ts +8 -0
- package/dist/src/lib/interfaces/initialize-options.interface.d.ts +133 -0
- package/dist/src/lib/interfaces/prompts.interface.d.ts +53 -0
- package/dist/src/lib/interfaces/traceloop-client.interface.d.ts +7 -0
- package/dist/src/lib/node-server-sdk.d.ts +19 -0
- package/dist/src/lib/prompts/fetch.d.ts +3 -0
- package/dist/src/lib/prompts/index.d.ts +3 -0
- package/dist/src/lib/prompts/registry.d.ts +9 -0
- package/dist/src/lib/prompts/template.d.ts +3 -0
- package/dist/src/lib/tracing/ai-sdk-transformations.d.ts +5 -0
- package/dist/src/lib/tracing/association.d.ts +4 -0
- package/dist/src/lib/tracing/baggage-utils.d.ts +2 -0
- package/dist/src/lib/tracing/custom-metric.d.ts +14 -0
- package/dist/src/lib/tracing/decorators.d.ts +22 -0
- package/dist/src/lib/tracing/index.d.ts +14 -0
- package/dist/src/lib/tracing/manual.d.ts +60 -0
- package/dist/src/lib/tracing/sampler.d.ts +7 -0
- package/dist/src/lib/tracing/span-processor.d.ts +48 -0
- package/dist/src/lib/tracing/tracing.d.ts +10 -0
- package/dist/src/lib/utils/response-transformer.d.ts +19 -0
- package/package.json +127 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Traceloop Node Server SDK
|
|
3
|
+
*
|
|
4
|
+
* For the full documentation, visit the {@link https://traceloop.com/docs/js-sdk | Traceloop Docs}.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export * from "./lib/node-server-sdk";
|
|
9
|
+
export * from "./lib/images";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard association properties for tracing.
|
|
3
|
+
* Use these with withAssociationProperties() or decorator associationProperties config.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* // With withAssociationProperties
|
|
8
|
+
* await traceloop.withAssociationProperties(
|
|
9
|
+
* {
|
|
10
|
+
* [traceloop.AssociationProperty.USER_ID]: "12345",
|
|
11
|
+
* [traceloop.AssociationProperty.SESSION_ID]: "session-abc"
|
|
12
|
+
* },
|
|
13
|
+
* async () => {
|
|
14
|
+
* await chat();
|
|
15
|
+
* }
|
|
16
|
+
* );
|
|
17
|
+
*
|
|
18
|
+
* // With decorator
|
|
19
|
+
* @traceloop.workflow((thisArg) => ({
|
|
20
|
+
* name: "my_workflow",
|
|
21
|
+
* associationProperties: {
|
|
22
|
+
* [traceloop.AssociationProperty.USER_ID]: (thisArg as MyClass).userId,
|
|
23
|
+
* },
|
|
24
|
+
* }))
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare enum AssociationProperty {
|
|
28
|
+
CUSTOMER_ID = "customer_id",
|
|
29
|
+
USER_ID = "user_id",
|
|
30
|
+
SESSION_ID = "session_id"
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=associations.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TraceloopClient } from "../traceloop-client";
|
|
2
|
+
import { AnnotationCreateOptions } from "../../interfaces/annotations.interface";
|
|
3
|
+
export type AnnotationFlow = "user_feedback";
|
|
4
|
+
/**
|
|
5
|
+
* Base class for handling annotation operations with the Traceloop API.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare class BaseAnnotation {
|
|
9
|
+
protected client: TraceloopClient;
|
|
10
|
+
protected flow: AnnotationFlow;
|
|
11
|
+
constructor(client: TraceloopClient, flow: AnnotationFlow);
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new annotation.
|
|
14
|
+
*
|
|
15
|
+
* @param options - The annotation creation options
|
|
16
|
+
* @returns Promise resolving to the fetch Response
|
|
17
|
+
*/
|
|
18
|
+
create(options: AnnotationCreateOptions): Promise<Response>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=base-annotation.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BaseAnnotation } from "./base-annotation";
|
|
2
|
+
import { TraceloopClient } from "../traceloop-client";
|
|
3
|
+
import { AnnotationCreateOptions } from "../../interfaces/annotations.interface";
|
|
4
|
+
/**
|
|
5
|
+
* Handles user feedback annotations with the Traceloop API.
|
|
6
|
+
*/
|
|
7
|
+
export declare class UserFeedback extends BaseAnnotation {
|
|
8
|
+
constructor(client: TraceloopClient);
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new annotation for a specific task and entity.
|
|
11
|
+
*
|
|
12
|
+
* @param options - The options for creating an annotation
|
|
13
|
+
* @returns Promise resolving to the fetch Response
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* await client.annotation.create({
|
|
18
|
+
* annotationTask: 'sample-annotation-task',
|
|
19
|
+
* entity: {
|
|
20
|
+
* id: '123456',
|
|
21
|
+
* },
|
|
22
|
+
* tags: {
|
|
23
|
+
* sentiment: 'positive',
|
|
24
|
+
* score: 0.85,
|
|
25
|
+
* tones: ['happy', 'surprised']
|
|
26
|
+
* }
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
create(options: AnnotationCreateOptions): Promise<Response>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=user-feedback.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { TraceloopClient } from "../traceloop-client";
|
|
2
|
+
import { Attachment, ExternalAttachment, AttachmentReference, FileCellType, AttachmentMetadata } from "./attachment";
|
|
3
|
+
/**
|
|
4
|
+
* Response from the upload URL endpoint
|
|
5
|
+
*/
|
|
6
|
+
export interface UploadUrlResponse {
|
|
7
|
+
uploadUrl: string;
|
|
8
|
+
storageKey: string;
|
|
9
|
+
expiresAt?: string;
|
|
10
|
+
method?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Handles attachment upload and registration operations
|
|
14
|
+
*/
|
|
15
|
+
export declare class AttachmentUploader {
|
|
16
|
+
private client;
|
|
17
|
+
constructor(client: TraceloopClient);
|
|
18
|
+
/**
|
|
19
|
+
* Requests a presigned upload URL from the API
|
|
20
|
+
*/
|
|
21
|
+
getUploadUrl(datasetSlug: string, rowId: string, columnSlug: string, fileName: string, contentType: string, fileType: FileCellType, metadata?: AttachmentMetadata): Promise<UploadUrlResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Uploads file data directly to S3 using the presigned URL
|
|
24
|
+
*/
|
|
25
|
+
uploadToS3(uploadUrl: string, data: Buffer, contentType: string): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Confirms the upload status with the API
|
|
28
|
+
*/
|
|
29
|
+
confirmUpload(datasetSlug: string, rowId: string, columnSlug: string, status: "success" | "failed", metadata?: AttachmentMetadata): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Registers an external URL as an attachment
|
|
32
|
+
*/
|
|
33
|
+
registerExternalUrl(datasetSlug: string, rowId: string, columnSlug: string, url: string, fileType: FileCellType, metadata?: AttachmentMetadata): Promise<AttachmentReference>;
|
|
34
|
+
/**
|
|
35
|
+
* Uploads an Attachment through the full flow:
|
|
36
|
+
* 1. Get presigned URL
|
|
37
|
+
* 2. Upload to S3
|
|
38
|
+
* 3. Confirm upload
|
|
39
|
+
*/
|
|
40
|
+
uploadAttachment(datasetSlug: string, rowId: string, columnSlug: string, attachment: Attachment): Promise<AttachmentReference>;
|
|
41
|
+
/**
|
|
42
|
+
* Processes an ExternalAttachment by registering the URL
|
|
43
|
+
*/
|
|
44
|
+
processExternalAttachment(datasetSlug: string, rowId: string, columnSlug: string, attachment: ExternalAttachment): Promise<AttachmentReference>;
|
|
45
|
+
/**
|
|
46
|
+
* Processes any attachment type (Attachment or ExternalAttachment)
|
|
47
|
+
*/
|
|
48
|
+
processAnyAttachment(datasetSlug: string, rowId: string, columnSlug: string, attachmentObj: Attachment | ExternalAttachment): Promise<AttachmentReference>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=attachment-uploader.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export type FileCellType = "image" | "video" | "audio" | "file";
|
|
2
|
+
export type FileStorageType = "internal" | "external";
|
|
3
|
+
export interface AttachmentMetadata {
|
|
4
|
+
[key: string]: string | number | boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface AttachmentOptions {
|
|
7
|
+
filePath?: string;
|
|
8
|
+
data?: Buffer | Uint8Array;
|
|
9
|
+
filename?: string;
|
|
10
|
+
contentType?: string;
|
|
11
|
+
fileType?: FileCellType;
|
|
12
|
+
metadata?: AttachmentMetadata;
|
|
13
|
+
}
|
|
14
|
+
export declare class Attachment {
|
|
15
|
+
readonly type: "attachment";
|
|
16
|
+
private _filePath?;
|
|
17
|
+
private _data?;
|
|
18
|
+
private _filename?;
|
|
19
|
+
private _contentType?;
|
|
20
|
+
private _fileType?;
|
|
21
|
+
private _metadata?;
|
|
22
|
+
constructor(options: AttachmentOptions);
|
|
23
|
+
getData(): Promise<Buffer>;
|
|
24
|
+
getFileName(): string;
|
|
25
|
+
getContentType(): string;
|
|
26
|
+
get fileType(): FileCellType;
|
|
27
|
+
get metadata(): AttachmentMetadata | undefined;
|
|
28
|
+
}
|
|
29
|
+
export interface ExternalAttachmentOptions {
|
|
30
|
+
url: string;
|
|
31
|
+
filename?: string;
|
|
32
|
+
contentType?: string;
|
|
33
|
+
fileType?: FileCellType;
|
|
34
|
+
metadata?: AttachmentMetadata;
|
|
35
|
+
}
|
|
36
|
+
export declare class ExternalAttachment {
|
|
37
|
+
readonly type: "external";
|
|
38
|
+
private _url;
|
|
39
|
+
private _filename?;
|
|
40
|
+
private _contentType?;
|
|
41
|
+
private _fileType;
|
|
42
|
+
private _metadata?;
|
|
43
|
+
constructor(options: ExternalAttachmentOptions);
|
|
44
|
+
get url(): string;
|
|
45
|
+
get filename(): string | undefined;
|
|
46
|
+
get contentType(): string | undefined;
|
|
47
|
+
get fileType(): FileCellType;
|
|
48
|
+
get metadata(): AttachmentMetadata | undefined;
|
|
49
|
+
}
|
|
50
|
+
export declare class AttachmentReference {
|
|
51
|
+
readonly storageType: FileStorageType;
|
|
52
|
+
readonly storageKey: string;
|
|
53
|
+
readonly url: string | undefined;
|
|
54
|
+
readonly fileType: FileCellType;
|
|
55
|
+
readonly metadata?: AttachmentMetadata | undefined;
|
|
56
|
+
constructor(storageType: FileStorageType, storageKey: string, url: string | undefined, fileType: FileCellType, metadata?: AttachmentMetadata | undefined);
|
|
57
|
+
download(filePath?: string): Promise<Buffer | void>;
|
|
58
|
+
getUrl(): string | undefined;
|
|
59
|
+
toJSON(): Record<string, unknown>;
|
|
60
|
+
}
|
|
61
|
+
export declare function isAttachment(value: unknown): value is Attachment;
|
|
62
|
+
export declare function isExternalAttachment(value: unknown): value is ExternalAttachment;
|
|
63
|
+
export declare function isAttachmentReference(value: unknown): value is AttachmentReference;
|
|
64
|
+
export declare function isAnyAttachment(value: unknown): value is Attachment | ExternalAttachment;
|
|
65
|
+
export declare const attachment: {
|
|
66
|
+
file: (filePath: string, options?: {
|
|
67
|
+
filename?: string;
|
|
68
|
+
contentType?: string;
|
|
69
|
+
fileType?: FileCellType;
|
|
70
|
+
metadata?: AttachmentMetadata;
|
|
71
|
+
}) => Attachment;
|
|
72
|
+
buffer: (data: Buffer | Uint8Array, filename: string, options?: {
|
|
73
|
+
contentType?: string;
|
|
74
|
+
fileType?: FileCellType;
|
|
75
|
+
metadata?: AttachmentMetadata;
|
|
76
|
+
}) => Attachment;
|
|
77
|
+
url: (url: string, options?: {
|
|
78
|
+
filename?: string;
|
|
79
|
+
contentType?: string;
|
|
80
|
+
fileType?: FileCellType;
|
|
81
|
+
metadata?: AttachmentMetadata;
|
|
82
|
+
}) => ExternalAttachment;
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=attachment.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TraceloopClient } from "../traceloop-client";
|
|
2
|
+
export declare abstract class BaseDatasetEntity {
|
|
3
|
+
protected client: TraceloopClient;
|
|
4
|
+
constructor(client: TraceloopClient);
|
|
5
|
+
protected handleResponse(response: Response): Promise<any>;
|
|
6
|
+
protected validateDatasetId(id: string): void;
|
|
7
|
+
protected validateDatasetSlug(slug: string): void;
|
|
8
|
+
protected validateDatasetName(name: string): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=base-dataset.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TraceloopClient } from "../traceloop-client";
|
|
2
|
+
import { BaseDatasetEntity } from "./base-dataset";
|
|
3
|
+
import { ColumnResponse, ColumnUpdateOptions, DatasetColumnValue } from "../../interfaces";
|
|
4
|
+
export declare class Column extends BaseDatasetEntity {
|
|
5
|
+
private _data;
|
|
6
|
+
private _deleted;
|
|
7
|
+
constructor(client: TraceloopClient, data: ColumnResponse);
|
|
8
|
+
get slug(): string;
|
|
9
|
+
get name(): string;
|
|
10
|
+
get type(): "string" | "number" | "boolean" | "date" | "file";
|
|
11
|
+
get required(): boolean;
|
|
12
|
+
get description(): string | undefined;
|
|
13
|
+
get datasetId(): string;
|
|
14
|
+
get datasetSlug(): string;
|
|
15
|
+
get createdAt(): string;
|
|
16
|
+
get updatedAt(): string;
|
|
17
|
+
get deleted(): boolean;
|
|
18
|
+
update(options: ColumnUpdateOptions): Promise<void>;
|
|
19
|
+
delete(): Promise<void>;
|
|
20
|
+
validateValue(value: DatasetColumnValue): boolean;
|
|
21
|
+
convertValue(value: unknown): DatasetColumnValue;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=column.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { TraceloopClient } from "../traceloop-client";
|
|
2
|
+
import { BaseDatasetEntity } from "./base-dataset";
|
|
3
|
+
import { Row } from "./row";
|
|
4
|
+
import { Column } from "./column";
|
|
5
|
+
import { DatasetResponse, DatasetUpdateOptions, ColumnDefinition, RowData, DatasetPublishOptions, CSVImportOptions, DatasetVersionsResponse, DatasetVersion } from "../../interfaces";
|
|
6
|
+
export declare class Dataset extends BaseDatasetEntity {
|
|
7
|
+
private _data;
|
|
8
|
+
private _deleted;
|
|
9
|
+
private _attachmentUploader;
|
|
10
|
+
constructor(client: TraceloopClient, data: DatasetResponse);
|
|
11
|
+
get id(): string;
|
|
12
|
+
get slug(): string;
|
|
13
|
+
get name(): string;
|
|
14
|
+
get description(): string | undefined;
|
|
15
|
+
get version(): string | undefined;
|
|
16
|
+
get published(): boolean;
|
|
17
|
+
get createdAt(): string;
|
|
18
|
+
get updatedAt(): string;
|
|
19
|
+
get deleted(): boolean;
|
|
20
|
+
update(options: DatasetUpdateOptions): Promise<void>;
|
|
21
|
+
delete(): Promise<void>;
|
|
22
|
+
publish(options?: DatasetPublishOptions): Promise<void>;
|
|
23
|
+
addColumn(columns: ColumnDefinition[]): Promise<Column[]>;
|
|
24
|
+
getColumns(): Promise<Column[]>;
|
|
25
|
+
addRow(rowData: RowData): Promise<Row>;
|
|
26
|
+
addRows(rows: RowData[]): Promise<Row[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Extracts attachments from rows and returns clean rows with null values
|
|
29
|
+
*/
|
|
30
|
+
private extractAttachments;
|
|
31
|
+
/**
|
|
32
|
+
* Processes attachments for created rows
|
|
33
|
+
*/
|
|
34
|
+
private processAttachments;
|
|
35
|
+
private transformValuesBackToNames;
|
|
36
|
+
getRows(limit?: number, offset?: number): Promise<Row[]>;
|
|
37
|
+
fromCSV(csvContent: string, options?: CSVImportOptions): Promise<void>;
|
|
38
|
+
getVersions(): Promise<DatasetVersionsResponse>;
|
|
39
|
+
getVersion(version: string): Promise<DatasetVersion | null>;
|
|
40
|
+
private parseCSV;
|
|
41
|
+
private parseValue;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=dataset.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TraceloopClient } from "../traceloop-client";
|
|
2
|
+
import { BaseDatasetEntity } from "./base-dataset";
|
|
3
|
+
import { Dataset } from "./dataset";
|
|
4
|
+
import { DatasetCreateOptions, DatasetListResponse } from "../../interfaces";
|
|
5
|
+
export declare class Datasets extends BaseDatasetEntity {
|
|
6
|
+
constructor(client: TraceloopClient);
|
|
7
|
+
create(options: DatasetCreateOptions): Promise<Dataset>;
|
|
8
|
+
get(slug: string): Promise<Dataset>;
|
|
9
|
+
list(): Promise<DatasetListResponse>;
|
|
10
|
+
delete(slug: string): Promise<void>;
|
|
11
|
+
getVersionCSV(slug: string, version: string): Promise<string>;
|
|
12
|
+
getVersionAsJsonl(slug: string, version: string): Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=datasets.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { BaseDatasetEntity as BaseDataset } from "./base-dataset";
|
|
2
|
+
export { Dataset } from "./dataset";
|
|
3
|
+
export { Datasets } from "./datasets";
|
|
4
|
+
export { Column } from "./column";
|
|
5
|
+
export { Row } from "./row";
|
|
6
|
+
export { Attachment, ExternalAttachment, AttachmentReference, attachment, isAttachment, isExternalAttachment, isAttachmentReference, isAnyAttachment, FileCellType, FileStorageType, AttachmentMetadata, AttachmentOptions, ExternalAttachmentOptions, } from "./attachment";
|
|
7
|
+
export { AttachmentUploader, UploadUrlResponse } from "./attachment-uploader";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { TraceloopClient } from "../traceloop-client";
|
|
2
|
+
import { BaseDatasetEntity } from "./base-dataset";
|
|
3
|
+
import { RowResponse, RowData, RowUpdateOptions } from "../../interfaces";
|
|
4
|
+
import { Attachment, ExternalAttachment, AttachmentReference } from "./attachment";
|
|
5
|
+
export declare class Row extends BaseDatasetEntity {
|
|
6
|
+
private _data;
|
|
7
|
+
private _deleted;
|
|
8
|
+
constructor(client: TraceloopClient, data: RowResponse);
|
|
9
|
+
get id(): string;
|
|
10
|
+
get datasetId(): string;
|
|
11
|
+
get datasetSlug(): string;
|
|
12
|
+
get data(): RowData;
|
|
13
|
+
get createdAt(): string;
|
|
14
|
+
get updatedAt(): string;
|
|
15
|
+
get deleted(): boolean;
|
|
16
|
+
getValue(columnName: string): string | number | boolean | Date | null | object;
|
|
17
|
+
hasColumn(columnName: string): boolean;
|
|
18
|
+
getColumns(): string[];
|
|
19
|
+
update(options: RowUpdateOptions): Promise<void>;
|
|
20
|
+
partialUpdate(updates: Partial<RowData>): Promise<void>;
|
|
21
|
+
delete(): Promise<void>;
|
|
22
|
+
toJSON(): RowData;
|
|
23
|
+
toCSVRow(columns?: string[], delimiter?: string): string;
|
|
24
|
+
validate(columnValidators?: {
|
|
25
|
+
[columnName: string]: (value: any) => boolean;
|
|
26
|
+
}): {
|
|
27
|
+
valid: boolean;
|
|
28
|
+
errors: string[];
|
|
29
|
+
};
|
|
30
|
+
clone(): Row;
|
|
31
|
+
/**
|
|
32
|
+
* Gets an attachment reference from a column
|
|
33
|
+
* @param columnName The name of the column containing the attachment
|
|
34
|
+
* @returns AttachmentReference if the column contains an attachment, null otherwise
|
|
35
|
+
*/
|
|
36
|
+
getAttachment(columnName: string): AttachmentReference | null;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if a column contains an attachment
|
|
39
|
+
* @param columnName The name of the column to check
|
|
40
|
+
*/
|
|
41
|
+
hasAttachment(columnName: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Sets/uploads an attachment to a column
|
|
44
|
+
* @param columnSlug The slug of the column to set the attachment in
|
|
45
|
+
* @param attachment The attachment to upload (Attachment or ExternalAttachment)
|
|
46
|
+
* @returns The created AttachmentReference
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* // Upload from file
|
|
50
|
+
* await row.setAttachment("image", new Attachment({ filePath: "./photo.jpg" }));
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // Set external URL
|
|
54
|
+
* await row.setAttachment("document", new ExternalAttachment({ url: "https://example.com/doc.pdf" }));
|
|
55
|
+
*/
|
|
56
|
+
setAttachment(columnSlug: string, attachment: Attachment | ExternalAttachment): Promise<AttachmentReference>;
|
|
57
|
+
/**
|
|
58
|
+
* Downloads an attachment from a column
|
|
59
|
+
* @param columnName The name of the column containing the attachment
|
|
60
|
+
* @param outputPath Optional file path to save the downloaded file
|
|
61
|
+
* @returns Buffer if no outputPath provided, void if saved to file
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* // Get as buffer
|
|
65
|
+
* const data = await row.downloadAttachment("image");
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* // Save to file
|
|
69
|
+
* await row.downloadAttachment("image", "./downloaded-image.png");
|
|
70
|
+
*/
|
|
71
|
+
downloadAttachment(columnName: string, outputPath?: string): Promise<Buffer | void>;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=row.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { TraceloopClient } from "../traceloop-client";
|
|
2
|
+
import { BaseDatasetEntity } from "../dataset/base-dataset";
|
|
3
|
+
import type { EvaluatorRunOptions, TriggerEvaluatorRequest, TriggerEvaluatorResponse } from "../../interfaces/evaluator.interface";
|
|
4
|
+
import type { ExecutionResponse } from "../../interfaces/experiment.interface";
|
|
5
|
+
export declare class Evaluator extends BaseDatasetEntity {
|
|
6
|
+
constructor(client: TraceloopClient);
|
|
7
|
+
/**
|
|
8
|
+
* Run evaluators on experiment task results and wait for completion
|
|
9
|
+
*/
|
|
10
|
+
runExperimentEvaluator(options: EvaluatorRunOptions): Promise<ExecutionResponse[]>;
|
|
11
|
+
/**
|
|
12
|
+
* Trigger evaluator execution without waiting for results
|
|
13
|
+
*/
|
|
14
|
+
triggerExperimentEvaluator(request: TriggerEvaluatorRequest): Promise<TriggerEvaluatorResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Wait for execution result via stream URL (actually JSON endpoint)
|
|
17
|
+
*/
|
|
18
|
+
waitForResult(executionId: string, streamUrl: string): Promise<ExecutionResponse[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Validate evaluator run options
|
|
21
|
+
*/
|
|
22
|
+
private validateEvaluatorOptions;
|
|
23
|
+
/**
|
|
24
|
+
* Create InputSchemaMapping from input object
|
|
25
|
+
*/
|
|
26
|
+
private createInputSchemaMapping;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=evaluator.d.ts.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { TraceloopClient } from "../traceloop-client";
|
|
2
|
+
import type { ExperimentTaskFunction, ExperimentRunOptions, ExperimentRunResult, InitExperimentRequest, ExperimentInitResponse, CreateTaskResponse, RunInGithubOptions, RunInGithubResponse } from "../../interfaces/experiment.interface";
|
|
3
|
+
export declare class Experiment {
|
|
4
|
+
private client;
|
|
5
|
+
private evaluator;
|
|
6
|
+
private datasets;
|
|
7
|
+
private _lastExperimentSlug?;
|
|
8
|
+
private _lastRunId?;
|
|
9
|
+
constructor(client: TraceloopClient);
|
|
10
|
+
/**
|
|
11
|
+
* Generate a unique experiment slug
|
|
12
|
+
*/
|
|
13
|
+
private generateExperimentSlug;
|
|
14
|
+
private handleResponse;
|
|
15
|
+
/**
|
|
16
|
+
* Run an experiment with the given task function and options
|
|
17
|
+
*/
|
|
18
|
+
run<TInput, TOutput>(task: ExperimentTaskFunction<TInput, TOutput>, options?: ExperimentRunOptions | RunInGithubOptions): Promise<ExperimentRunResult | RunInGithubResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Run an experiment locally (not in GitHub Actions)
|
|
21
|
+
*/
|
|
22
|
+
private runLocally;
|
|
23
|
+
/**
|
|
24
|
+
* Create a task for the experiment
|
|
25
|
+
*/
|
|
26
|
+
createTask(experimentSlug: string, experimentRunId: string, taskInput: Record<string, any>, taskOutput: Record<string, any>): Promise<CreateTaskResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* Initialize a new experiment
|
|
29
|
+
*/
|
|
30
|
+
initializeExperiment(request: InitExperimentRequest): Promise<ExperimentInitResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* Parse JSONL string into list of {col_name: col_value} dictionaries
|
|
33
|
+
* Skips the first line (columns definition)
|
|
34
|
+
*/
|
|
35
|
+
private parseJsonlToRows;
|
|
36
|
+
/**
|
|
37
|
+
* Get dataset rows for experiment execution
|
|
38
|
+
*/
|
|
39
|
+
private getDatasetRows;
|
|
40
|
+
/**
|
|
41
|
+
* Validate experiment run options
|
|
42
|
+
*/
|
|
43
|
+
private validateRunOptions;
|
|
44
|
+
/**
|
|
45
|
+
* Extract GitHub Actions context from environment variables
|
|
46
|
+
*/
|
|
47
|
+
private getGithubContext;
|
|
48
|
+
/**
|
|
49
|
+
* Execute tasks locally and capture results
|
|
50
|
+
*/
|
|
51
|
+
private executeTasksLocally;
|
|
52
|
+
/**
|
|
53
|
+
* Run an experiment in GitHub Actions environment
|
|
54
|
+
* This method executes tasks locally and submits results to the backend for evaluation
|
|
55
|
+
*/
|
|
56
|
+
runInGithub<TInput, TOutput>(task: ExperimentTaskFunction<TInput, TOutput>, options: RunInGithubOptions): Promise<RunInGithubResponse>;
|
|
57
|
+
/**
|
|
58
|
+
* Resolve export parameters by falling back to last used values
|
|
59
|
+
*/
|
|
60
|
+
private resolveExportParams;
|
|
61
|
+
/**
|
|
62
|
+
* Export experiment results as CSV string
|
|
63
|
+
* @param experimentSlug - Optional experiment slug (uses last run if not provided)
|
|
64
|
+
* @param runId - Optional run ID (uses last run if not provided)
|
|
65
|
+
* @returns CSV string of experiment results
|
|
66
|
+
*/
|
|
67
|
+
toCsvString(experimentSlug?: string, runId?: string): Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Export experiment results as JSON string
|
|
70
|
+
* @param experimentSlug - Optional experiment slug (uses last run if not provided)
|
|
71
|
+
* @param runId - Optional run ID (uses last run if not provided)
|
|
72
|
+
* @returns JSON string of experiment results
|
|
73
|
+
*/
|
|
74
|
+
toJsonString(experimentSlug?: string, runId?: string): Promise<string>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=experiment.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TraceloopClientOptions } from "../interfaces";
|
|
2
|
+
import { UserFeedback } from "./annotation/user-feedback";
|
|
3
|
+
import { Datasets } from "./dataset/datasets";
|
|
4
|
+
import { Experiment } from "./experiment/experiment";
|
|
5
|
+
import { Evaluator } from "./evaluator/evaluator";
|
|
6
|
+
/**
|
|
7
|
+
* The main client for interacting with Traceloop's API.
|
|
8
|
+
* This client can be used either directly or through the singleton pattern via configuration.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Direct usage
|
|
12
|
+
* const client = new TraceloopClient('your-api-key');
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Through configuration (recommended)
|
|
16
|
+
* initialize({ apiKey: 'your-api-key', appName: 'your-app' });
|
|
17
|
+
* const client = getClient();
|
|
18
|
+
*/
|
|
19
|
+
export declare class TraceloopClient {
|
|
20
|
+
private version;
|
|
21
|
+
appName: string;
|
|
22
|
+
private baseUrl;
|
|
23
|
+
private apiKey;
|
|
24
|
+
experimentSlug?: string;
|
|
25
|
+
userFeedback: UserFeedback;
|
|
26
|
+
datasets: Datasets;
|
|
27
|
+
experiment: Experiment;
|
|
28
|
+
evaluator: Evaluator;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new instance of the TraceloopClient.
|
|
31
|
+
*
|
|
32
|
+
* @param options - Configuration options for the client
|
|
33
|
+
*/
|
|
34
|
+
constructor(options: TraceloopClientOptions);
|
|
35
|
+
post(path: string, body: Record<string, unknown> | any): Promise<Response>;
|
|
36
|
+
get(path: string): Promise<Response>;
|
|
37
|
+
put(path: string, body: Record<string, unknown> | any): Promise<Response>;
|
|
38
|
+
delete(path: string): Promise<Response>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=traceloop-client.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { InitializeOptions } from "../interfaces";
|
|
2
|
+
import { TraceloopClient } from "../client/traceloop-client";
|
|
3
|
+
export declare let _configuration: InitializeOptions | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Initializes the Traceloop SDK and creates a singleton client instance if API key is provided.
|
|
6
|
+
* Must be called once before any other SDK methods.
|
|
7
|
+
*
|
|
8
|
+
* @param options - The options to initialize the SDK. See the {@link InitializeOptions} for details.
|
|
9
|
+
* @returns TraceloopClient - The singleton client instance if API key is provided, otherwise undefined.
|
|
10
|
+
* @throws {InitializationError} if the configuration is invalid or if failed to fetch feature data.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* initialize({
|
|
15
|
+
* apiKey: 'your-api-key',
|
|
16
|
+
* appName: 'your-app',
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const initialize: (options?: InitializeOptions) => TraceloopClient | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the singleton instance of the TraceloopClient.
|
|
23
|
+
* The SDK must be initialized with an API key before calling this function.
|
|
24
|
+
*
|
|
25
|
+
* @returns The TraceloopClient singleton instance
|
|
26
|
+
* @throws {Error} if the SDK hasn't been initialized or was initialized without an API key
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const client = getClient();
|
|
31
|
+
* await client.annotation.create({ annotationTask: 'taskId', entityInstanceId: 'entityId', tags: { score: 0.9 } });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare const getClient: () => TraceloopClient;
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The severity of an error.
|
|
3
|
+
*/
|
|
4
|
+
export declare const SEVERITY: {
|
|
5
|
+
readonly Warning: "Warning";
|
|
6
|
+
readonly Error: "Error";
|
|
7
|
+
readonly Critical: "Critical";
|
|
8
|
+
};
|
|
9
|
+
export type Severity = (typeof SEVERITY)[keyof typeof SEVERITY];
|
|
10
|
+
/**
|
|
11
|
+
* Base class for all Traceloop errors.
|
|
12
|
+
*/
|
|
13
|
+
export declare class TraceloopError extends Error {
|
|
14
|
+
/**
|
|
15
|
+
* The severity of the error.
|
|
16
|
+
*/
|
|
17
|
+
severity: Severity;
|
|
18
|
+
/**
|
|
19
|
+
* The underlying cause of the error.
|
|
20
|
+
*/
|
|
21
|
+
underlyingCause?: Error;
|
|
22
|
+
constructor(message: string, severity?: Severity);
|
|
23
|
+
}
|
|
24
|
+
export declare class NotInitializedError extends TraceloopError {
|
|
25
|
+
constructor();
|
|
26
|
+
}
|
|
27
|
+
export declare class InitializationError extends TraceloopError {
|
|
28
|
+
constructor(message?: string, cause?: Error);
|
|
29
|
+
}
|
|
30
|
+
export declare class ArgumentNotProvidedError extends TraceloopError {
|
|
31
|
+
constructor(argumentName: string);
|
|
32
|
+
}
|
|
33
|
+
export declare class PromptNotFoundError extends TraceloopError {
|
|
34
|
+
constructor(key: string);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { EVALUATOR_SLUGS, EVALUATOR_SCHEMAS, getEvaluatorSchema, isValidEvaluatorSlug, } from './registry';
|
|
2
|
+
export type { EvaluatorSlug, EvaluatorSchema } from './registry';
|
|
3
|
+
export { EvaluatorMadeByTraceloop, createEvaluator, validateEvaluatorInput, getAvailableEvaluatorSlugs, getEvaluatorSchemaInfo, } from './mbt-evaluators';
|
|
4
|
+
export type * from './mbt-evaluators';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|