cloudflare/cloudflare-typescript

Public

mirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v4.0.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/resources/ai-gateway/evaluations.ts

526lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import { APIResource } from '../../resource';
4import * as Core from '../../core';
5import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../pagination';
6
7export class Evaluations extends APIResource {
8 /**
9 * Create a new Evaluation
10 */
11 create(
12 gatewayId: string,
13 params: EvaluationCreateParams,
14 options?: Core.RequestOptions,
15 ): Core.APIPromise<EvaluationCreateResponse> {
16 const { account_id, ...body } = params;
17 return (
18 this._client.post(`/accounts/${account_id}/ai-gateway/gateways/${gatewayId}/evaluations`, {
19 body,
20 ...options,
21 }) as Core.APIPromise<{ result: EvaluationCreateResponse }>
22 )._thenUnwrap((obj) => obj.result);
23 }
24
25 /**
26 * List Evaluations
27 */
28 list(
29 gatewayId: string,
30 params: EvaluationListParams,
31 options?: Core.RequestOptions,
32 ): Core.PagePromise<EvaluationListResponsesV4PagePaginationArray, EvaluationListResponse> {
33 const { account_id, ...query } = params;
34 return this._client.getAPIList(
35 `/accounts/${account_id}/ai-gateway/gateways/${gatewayId}/evaluations`,
36 EvaluationListResponsesV4PagePaginationArray,
37 { query, ...options },
38 );
39 }
40
41 /**
42 * Delete a Evaluation
43 */
44 delete(
45 gatewayId: string,
46 id: string,
47 params: EvaluationDeleteParams,
48 options?: Core.RequestOptions,
49 ): Core.APIPromise<EvaluationDeleteResponse> {
50 const { account_id } = params;
51 return (
52 this._client.delete(
53 `/accounts/${account_id}/ai-gateway/gateways/${gatewayId}/evaluations/${id}`,
54 options,
55 ) as Core.APIPromise<{ result: EvaluationDeleteResponse }>
56 )._thenUnwrap((obj) => obj.result);
57 }
58
59 /**
60 * Fetch a Evaluation
61 */
62 get(
63 gatewayId: string,
64 id: string,
65 params: EvaluationGetParams,
66 options?: Core.RequestOptions,
67 ): Core.APIPromise<EvaluationGetResponse> {
68 const { account_id } = params;
69 return (
70 this._client.get(
71 `/accounts/${account_id}/ai-gateway/gateways/${gatewayId}/evaluations/${id}`,
72 options,
73 ) as Core.APIPromise<{ result: EvaluationGetResponse }>
74 )._thenUnwrap((obj) => obj.result);
75 }
76}
77
78export class EvaluationListResponsesV4PagePaginationArray extends V4PagePaginationArray<EvaluationListResponse> {}
79
80export interface EvaluationCreateResponse {
81 id: string;
82
83 account_id: string;
84
85 account_tag: string;
86
87 created_at: string;
88
89 datasets: Array<EvaluationCreateResponse.Dataset>;
90
91 /**
92 * gateway id
93 */
94 gateway_id: string;
95
96 modified_at: string;
97
98 name: string;
99
100 processed: boolean;
101
102 results: Array<EvaluationCreateResponse.Result>;
103
104 total_logs: number;
105}
106
107export namespace EvaluationCreateResponse {
108 export interface Dataset {
109 id: string;
110
111 account_id: string;
112
113 account_tag: string;
114
115 created_at: string;
116
117 enable: boolean;
118
119 filters: Array<Dataset.Filter>;
120
121 /**
122 * gateway id
123 */
124 gateway_id: string;
125
126 modified_at: string;
127
128 name: string;
129 }
130
131 export namespace Dataset {
132 export interface Filter {
133 key:
134 | 'created_at'
135 | 'request_content_type'
136 | 'response_content_type'
137 | 'success'
138 | 'cached'
139 | 'provider'
140 | 'model'
141 | 'cost'
142 | 'tokens'
143 | 'tokens_in'
144 | 'tokens_out'
145 | 'duration'
146 | 'feedback';
147
148 operator: 'eq' | 'contains' | 'lt' | 'gt';
149
150 value: Array<string | number | boolean>;
151 }
152 }
153
154 export interface Result {
155 id: string;
156
157 created_at: string;
158
159 evaluation_id: string;
160
161 evaluation_type_id: string;
162
163 modified_at: string;
164
165 result: string;
166
167 status: number;
168
169 status_description: string;
170
171 total_logs: number;
172 }
173}
174
175export interface EvaluationListResponse {
176 id: string;
177
178 account_id: string;
179
180 account_tag: string;
181
182 created_at: string;
183
184 datasets: Array<EvaluationListResponse.Dataset>;
185
186 /**
187 * gateway id
188 */
189 gateway_id: string;
190
191 modified_at: string;
192
193 name: string;
194
195 processed: boolean;
196
197 results: Array<EvaluationListResponse.Result>;
198
199 total_logs: number;
200}
201
202export namespace EvaluationListResponse {
203 export interface Dataset {
204 id: string;
205
206 account_id: string;
207
208 account_tag: string;
209
210 created_at: string;
211
212 enable: boolean;
213
214 filters: Array<Dataset.Filter>;
215
216 /**
217 * gateway id
218 */
219 gateway_id: string;
220
221 modified_at: string;
222
223 name: string;
224 }
225
226 export namespace Dataset {
227 export interface Filter {
228 key:
229 | 'created_at'
230 | 'request_content_type'
231 | 'response_content_type'
232 | 'success'
233 | 'cached'
234 | 'provider'
235 | 'model'
236 | 'cost'
237 | 'tokens'
238 | 'tokens_in'
239 | 'tokens_out'
240 | 'duration'
241 | 'feedback';
242
243 operator: 'eq' | 'contains' | 'lt' | 'gt';
244
245 value: Array<string | number | boolean>;
246 }
247 }
248
249 export interface Result {
250 id: string;
251
252 created_at: string;
253
254 evaluation_id: string;
255
256 evaluation_type_id: string;
257
258 modified_at: string;
259
260 result: string;
261
262 status: number;
263
264 status_description: string;
265
266 total_logs: number;
267 }
268}
269
270export interface EvaluationDeleteResponse {
271 id: string;
272
273 account_id: string;
274
275 account_tag: string;
276
277 created_at: string;
278
279 datasets: Array<EvaluationDeleteResponse.Dataset>;
280
281 /**
282 * gateway id
283 */
284 gateway_id: string;
285
286 modified_at: string;
287
288 name: string;
289
290 processed: boolean;
291
292 results: Array<EvaluationDeleteResponse.Result>;
293
294 total_logs: number;
295}
296
297export namespace EvaluationDeleteResponse {
298 export interface Dataset {
299 id: string;
300
301 account_id: string;
302
303 account_tag: string;
304
305 created_at: string;
306
307 enable: boolean;
308
309 filters: Array<Dataset.Filter>;
310
311 /**
312 * gateway id
313 */
314 gateway_id: string;
315
316 modified_at: string;
317
318 name: string;
319 }
320
321 export namespace Dataset {
322 export interface Filter {
323 key:
324 | 'created_at'
325 | 'request_content_type'
326 | 'response_content_type'
327 | 'success'
328 | 'cached'
329 | 'provider'
330 | 'model'
331 | 'cost'
332 | 'tokens'
333 | 'tokens_in'
334 | 'tokens_out'
335 | 'duration'
336 | 'feedback';
337
338 operator: 'eq' | 'contains' | 'lt' | 'gt';
339
340 value: Array<string | number | boolean>;
341 }
342 }
343
344 export interface Result {
345 id: string;
346
347 created_at: string;
348
349 evaluation_id: string;
350
351 evaluation_type_id: string;
352
353 modified_at: string;
354
355 result: string;
356
357 status: number;
358
359 status_description: string;
360
361 total_logs: number;
362 }
363}
364
365export interface EvaluationGetResponse {
366 id: string;
367
368 account_id: string;
369
370 account_tag: string;
371
372 created_at: string;
373
374 datasets: Array<EvaluationGetResponse.Dataset>;
375
376 /**
377 * gateway id
378 */
379 gateway_id: string;
380
381 modified_at: string;
382
383 name: string;
384
385 processed: boolean;
386
387 results: Array<EvaluationGetResponse.Result>;
388
389 total_logs: number;
390}
391
392export namespace EvaluationGetResponse {
393 export interface Dataset {
394 id: string;
395
396 account_id: string;
397
398 account_tag: string;
399
400 created_at: string;
401
402 enable: boolean;
403
404 filters: Array<Dataset.Filter>;
405
406 /**
407 * gateway id
408 */
409 gateway_id: string;
410
411 modified_at: string;
412
413 name: string;
414 }
415
416 export namespace Dataset {
417 export interface Filter {
418 key:
419 | 'created_at'
420 | 'request_content_type'
421 | 'response_content_type'
422 | 'success'
423 | 'cached'
424 | 'provider'
425 | 'model'
426 | 'cost'
427 | 'tokens'
428 | 'tokens_in'
429 | 'tokens_out'
430 | 'duration'
431 | 'feedback';
432
433 operator: 'eq' | 'contains' | 'lt' | 'gt';
434
435 value: Array<string | number | boolean>;
436 }
437 }
438
439 export interface Result {
440 id: string;
441
442 created_at: string;
443
444 evaluation_id: string;
445
446 evaluation_type_id: string;
447
448 modified_at: string;
449
450 result: string;
451
452 status: number;
453
454 status_description: string;
455
456 total_logs: number;
457 }
458}
459
460export interface EvaluationCreateParams {
461 /**
462 * Path param:
463 */
464 account_id: string;
465
466 /**
467 * Body param:
468 */
469 dataset_ids: Array<string>;
470
471 /**
472 * Body param:
473 */
474 evaluation_type_ids: Array<string>;
475
476 /**
477 * Body param:
478 */
479 name: string;
480}
481
482export interface EvaluationListParams extends V4PagePaginationArrayParams {
483 /**
484 * Path param:
485 */
486 account_id: string;
487
488 /**
489 * Query param:
490 */
491 name?: string;
492
493 /**
494 * Query param:
495 */
496 processed?: boolean;
497
498 /**
499 * Query param: Search by id, name
500 */
501 search?: string;
502}
503
504export interface EvaluationDeleteParams {
505 account_id: string;
506}
507
508export interface EvaluationGetParams {
509 account_id: string;
510}
511
512Evaluations.EvaluationListResponsesV4PagePaginationArray = EvaluationListResponsesV4PagePaginationArray;
513
514export declare namespace Evaluations {
515 export {
516 type EvaluationCreateResponse as EvaluationCreateResponse,
517 type EvaluationListResponse as EvaluationListResponse,
518 type EvaluationDeleteResponse as EvaluationDeleteResponse,
519 type EvaluationGetResponse as EvaluationGetResponse,
520 EvaluationListResponsesV4PagePaginationArray as EvaluationListResponsesV4PagePaginationArray,
521 type EvaluationCreateParams as EvaluationCreateParams,
522 type EvaluationListParams as EvaluationListParams,
523 type EvaluationDeleteParams as EvaluationDeleteParams,
524 type EvaluationGetParams as EvaluationGetParams,
525 };
526}
527