@pauly4010/evalai-sdk 1.3.0

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.
@@ -0,0 +1,358 @@
1
+ import { ClientConfig, Trace, CreateTraceParams, ListTracesParams, Evaluation, CreateEvaluationParams, UpdateEvaluationParams, ListEvaluationsParams, LLMJudgeResult, RunLLMJudgeParams, TestCase, CreateTestCaseParams, EvaluationRun, CreateRunParams, Span, CreateSpanParams, OrganizationLimits, Annotation, CreateAnnotationParams, ListAnnotationsParams, AnnotationTask, CreateAnnotationTaskParams, ListAnnotationTasksParams, AnnotationItem, CreateAnnotationItemParams, ListAnnotationItemsParams, APIKey, APIKeyWithSecret, CreateAPIKeyParams, UpdateAPIKeyParams, ListAPIKeysParams, APIKeyUsage, Webhook, CreateWebhookParams, UpdateWebhookParams, ListWebhooksParams, WebhookDelivery, ListWebhookDeliveriesParams, UsageStats, GetUsageParams, UsageSummary, LLMJudgeConfig, CreateLLMJudgeConfigParams, ListLLMJudgeConfigsParams, ListLLMJudgeResultsParams, LLMJudgeAlignment, GetLLMJudgeAlignmentParams, Organization } from './types';
2
+ import { Logger } from './logger';
3
+ /**
4
+ * AI Evaluation Platform SDK Client
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { AIEvalClient } from '@ai-eval-platform/sdk';
9
+ *
10
+ * // Zero-config initialization (uses env variables)
11
+ * const client = AIEvalClient.init();
12
+ *
13
+ * // Or with explicit config
14
+ * const client = new AIEvalClient({
15
+ * apiKey: 'your-api-key',
16
+ * organizationId: 123,
17
+ * debug: true
18
+ * });
19
+ *
20
+ * // Create a trace with automatic context propagation
21
+ * const trace = await client.traces.create({
22
+ * name: 'User Query',
23
+ * traceId: 'trace-123'
24
+ * });
25
+ * ```
26
+ */
27
+ export declare class AIEvalClient {
28
+ private apiKey;
29
+ private baseUrl;
30
+ private organizationId?;
31
+ private timeout;
32
+ private logger;
33
+ private requestLogger;
34
+ private cache;
35
+ private batcher;
36
+ private retryConfig;
37
+ traces: TraceAPI;
38
+ evaluations: EvaluationAPI;
39
+ llmJudge: LLMJudgeAPI;
40
+ annotations: AnnotationsAPI;
41
+ developer: DeveloperAPI;
42
+ organizations: OrganizationsAPI;
43
+ constructor(config?: ClientConfig);
44
+ /**
45
+ * Zero-config initialization using environment variables
46
+ *
47
+ * Works in both Node.js and browsers. In Node.js, reads from environment variables.
48
+ * In browsers, you must provide config explicitly.
49
+ *
50
+ * Environment variables (Node.js only):
51
+ * - EVALAI_API_KEY or AI_EVAL_API_KEY: Your API key
52
+ * - EVALAI_ORGANIZATION_ID or AI_EVAL_ORGANIZATION_ID: Your organization ID
53
+ * - EVALAI_BASE_URL: Custom API base URL (optional)
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * // Node.js - reads from env vars:
58
+ * // EVALAI_API_KEY=your-key
59
+ * // EVALAI_ORGANIZATION_ID=123
60
+ * const client = AIEvalClient.init();
61
+ *
62
+ * // Browser - must provide config:
63
+ * const client = AIEvalClient.init({
64
+ * apiKey: 'your-key',
65
+ * organizationId: 123
66
+ * });
67
+ * ```
68
+ */
69
+ static init(config?: Partial<ClientConfig>): AIEvalClient;
70
+ /**
71
+ * Internal method to make HTTP requests with retry logic and error handling
72
+ */
73
+ request<T>(endpoint: string, options?: RequestInit, attempt?: number): Promise<T>;
74
+ /**
75
+ * Calculate backoff delay for retries
76
+ */
77
+ private calculateBackoff;
78
+ getOrganizationId(): number | undefined;
79
+ /**
80
+ * Get the logger instance for custom logging
81
+ */
82
+ getLogger(): Logger;
83
+ /**
84
+ * Get organization resource limits and usage
85
+ * Returns feature usage data for per-organization quotas
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * const limits = await client.getOrganizationLimits();
90
+ * console.log('Traces:', limits.traces_per_organization);
91
+ * console.log('Evaluations:', limits.evals_per_organization);
92
+ * ```
93
+ */
94
+ getOrganizationLimits(): Promise<OrganizationLimits>;
95
+ }
96
+ /**
97
+ * Trace API methods
98
+ */
99
+ declare class TraceAPI {
100
+ private client;
101
+ constructor(client: AIEvalClient);
102
+ /**
103
+ * Create a new trace with automatic context propagation
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * const trace = await client.traces.create({
108
+ * name: 'User Query',
109
+ * traceId: 'trace-123',
110
+ * metadata: { userId: '456' }
111
+ * });
112
+ * ```
113
+ */
114
+ create<TMetadata = Record<string, any>>(params: CreateTraceParams<TMetadata>): Promise<Trace<TMetadata>>;
115
+ /**
116
+ * List traces with optional filtering
117
+ */
118
+ list(params?: ListTracesParams): Promise<Trace[]>;
119
+ /**
120
+ * Delete a trace by ID
121
+ */
122
+ delete(id: number): Promise<{
123
+ message: string;
124
+ }>;
125
+ /**
126
+ * Get a single trace by ID
127
+ */
128
+ get(id: number): Promise<Trace>;
129
+ /**
130
+ * Create a span for a trace
131
+ */
132
+ createSpan(traceId: number, params: CreateSpanParams): Promise<Span>;
133
+ /**
134
+ * List spans for a trace
135
+ */
136
+ listSpans(traceId: number): Promise<Span[]>;
137
+ }
138
+ /**
139
+ * Evaluation API methods
140
+ */
141
+ declare class EvaluationAPI {
142
+ private client;
143
+ constructor(client: AIEvalClient);
144
+ /**
145
+ * Create a new evaluation
146
+ */
147
+ create(params: CreateEvaluationParams): Promise<Evaluation>;
148
+ /**
149
+ * Get a single evaluation by ID
150
+ */
151
+ get(id: number): Promise<Evaluation>;
152
+ /**
153
+ * List evaluations with optional filtering
154
+ */
155
+ list(params?: ListEvaluationsParams): Promise<Evaluation[]>;
156
+ /**
157
+ * Update an evaluation
158
+ */
159
+ update(id: number, params: UpdateEvaluationParams): Promise<Evaluation>;
160
+ /**
161
+ * Delete an evaluation
162
+ */
163
+ delete(id: number): Promise<{
164
+ message: string;
165
+ }>;
166
+ /**
167
+ * Create a test case for an evaluation
168
+ */
169
+ createTestCase(evaluationId: number, params: CreateTestCaseParams): Promise<TestCase>;
170
+ /**
171
+ * List test cases for an evaluation
172
+ */
173
+ listTestCases(evaluationId: number): Promise<TestCase[]>;
174
+ /**
175
+ * Create a run for an evaluation
176
+ */
177
+ createRun(evaluationId: number, params: CreateRunParams): Promise<EvaluationRun>;
178
+ /**
179
+ * List runs for an evaluation
180
+ */
181
+ listRuns(evaluationId: number): Promise<EvaluationRun[]>;
182
+ /**
183
+ * Get a specific run
184
+ */
185
+ getRun(evaluationId: number, runId: number): Promise<EvaluationRun>;
186
+ }
187
+ /**
188
+ * LLM Judge API methods
189
+ */
190
+ declare class LLMJudgeAPI {
191
+ private client;
192
+ constructor(client: AIEvalClient);
193
+ /**
194
+ * Run an LLM judge evaluation
195
+ */
196
+ evaluate(params: RunLLMJudgeParams): Promise<{
197
+ result: LLMJudgeResult;
198
+ config: any;
199
+ }>;
200
+ /**
201
+ * Create an LLM judge configuration
202
+ */
203
+ createConfig(params: CreateLLMJudgeConfigParams): Promise<LLMJudgeConfig>;
204
+ /**
205
+ * List LLM judge configurations
206
+ */
207
+ listConfigs(params?: ListLLMJudgeConfigsParams): Promise<LLMJudgeConfig[]>;
208
+ /**
209
+ * List LLM judge results
210
+ */
211
+ listResults(params?: ListLLMJudgeResultsParams): Promise<LLMJudgeResult[]>;
212
+ /**
213
+ * Get alignment analysis
214
+ */
215
+ getAlignment(params: GetLLMJudgeAlignmentParams): Promise<LLMJudgeAlignment>;
216
+ }
217
+ /**
218
+ * Annotations API methods
219
+ */
220
+ declare class AnnotationsAPI {
221
+ private client;
222
+ readonly tasks: AnnotationTasksAPI;
223
+ constructor(client: AIEvalClient);
224
+ /**
225
+ * Create an annotation
226
+ */
227
+ create(params: CreateAnnotationParams): Promise<Annotation>;
228
+ /**
229
+ * List annotations
230
+ */
231
+ list(params?: ListAnnotationsParams): Promise<Annotation[]>;
232
+ }
233
+ /**
234
+ * Annotation Tasks API methods
235
+ */
236
+ declare class AnnotationTasksAPI {
237
+ private client;
238
+ readonly items: AnnotationTaskItemsAPI;
239
+ constructor(client: AIEvalClient);
240
+ /**
241
+ * Create an annotation task
242
+ */
243
+ create(params: CreateAnnotationTaskParams): Promise<AnnotationTask>;
244
+ /**
245
+ * List annotation tasks
246
+ */
247
+ list(params?: ListAnnotationTasksParams): Promise<AnnotationTask[]>;
248
+ /**
249
+ * Get an annotation task
250
+ */
251
+ get(taskId: number): Promise<AnnotationTask>;
252
+ }
253
+ /**
254
+ * Annotation Task Items API methods
255
+ */
256
+ declare class AnnotationTaskItemsAPI {
257
+ private client;
258
+ constructor(client: AIEvalClient);
259
+ /**
260
+ * Create an annotation item
261
+ */
262
+ create(taskId: number, params: CreateAnnotationItemParams): Promise<AnnotationItem>;
263
+ /**
264
+ * List annotation items
265
+ */
266
+ list(taskId: number, params?: ListAnnotationItemsParams): Promise<AnnotationItem[]>;
267
+ }
268
+ /**
269
+ * Developer API methods
270
+ */
271
+ declare class DeveloperAPI {
272
+ private client;
273
+ readonly apiKeys: APIKeysAPI;
274
+ readonly webhooks: WebhooksAPI;
275
+ constructor(client: AIEvalClient);
276
+ /**
277
+ * Get usage statistics
278
+ */
279
+ getUsage(params: GetUsageParams): Promise<UsageStats>;
280
+ /**
281
+ * Get usage summary
282
+ */
283
+ getUsageSummary(organizationId: number): Promise<UsageSummary>;
284
+ }
285
+ /**
286
+ * API Keys API methods
287
+ */
288
+ declare class APIKeysAPI {
289
+ private client;
290
+ constructor(client: AIEvalClient);
291
+ /**
292
+ * Create an API key
293
+ */
294
+ create(params: CreateAPIKeyParams): Promise<APIKeyWithSecret>;
295
+ /**
296
+ * List API keys
297
+ */
298
+ list(params?: ListAPIKeysParams): Promise<APIKey[]>;
299
+ /**
300
+ * Update an API key
301
+ */
302
+ update(keyId: number, params: UpdateAPIKeyParams): Promise<APIKey>;
303
+ /**
304
+ * Revoke an API key
305
+ */
306
+ revoke(keyId: number): Promise<{
307
+ message: string;
308
+ }>;
309
+ /**
310
+ * Get API key usage
311
+ */
312
+ getUsage(keyId: number): Promise<APIKeyUsage>;
313
+ }
314
+ /**
315
+ * Webhooks API methods
316
+ */
317
+ declare class WebhooksAPI {
318
+ private client;
319
+ constructor(client: AIEvalClient);
320
+ /**
321
+ * Create a webhook
322
+ */
323
+ create(params: CreateWebhookParams): Promise<Webhook>;
324
+ /**
325
+ * List webhooks
326
+ */
327
+ list(params: ListWebhooksParams): Promise<Webhook[]>;
328
+ /**
329
+ * Get a webhook
330
+ */
331
+ get(webhookId: number): Promise<Webhook>;
332
+ /**
333
+ * Update a webhook
334
+ */
335
+ update(webhookId: number, params: UpdateWebhookParams): Promise<Webhook>;
336
+ /**
337
+ * Delete a webhook
338
+ */
339
+ delete(webhookId: number): Promise<{
340
+ message: string;
341
+ }>;
342
+ /**
343
+ * Get webhook deliveries
344
+ */
345
+ getDeliveries(webhookId: number, params?: ListWebhookDeliveriesParams): Promise<WebhookDelivery[]>;
346
+ }
347
+ /**
348
+ * Organizations API methods
349
+ */
350
+ declare class OrganizationsAPI {
351
+ private client;
352
+ constructor(client: AIEvalClient);
353
+ /**
354
+ * Get current organization
355
+ */
356
+ getCurrent(): Promise<Organization>;
357
+ }
358
+ export {};