cloudflare
Version:
The official TypeScript library for the Cloudflare API
94 lines • 3.71 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import { V4PagePaginationArray } from "../../core/pagination.mjs";
import { path } from "../../internal/utils/path.mjs";
export var BaseEvaluations = /* @__PURE__ */ (() => {
class BaseEvaluations extends APIResource {
/**
* Creates an evaluation that scores the logs in a dataset with the specified
* evaluator types. Evaluations and datasets are deprecated and unavailable to new
* accounts.
*
* @example
* ```ts
* const evaluation =
* await client.aiGateway.evaluations.create('my-gateway', {
* account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
* dataset_ids: ['string'],
* evaluation_type_ids: ['string'],
* name: 'name',
* });
* ```
*/
create(gatewayID, params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/ai-gateway/gateways/${gatewayID}/evaluations`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists the evaluations run on an AI Gateway. Evaluations and datasets are
* deprecated and unavailable to new accounts.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const evaluationListResponse of client.aiGateway.evaluations.list(
* 'my-gateway',
* { account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0' },
* )) {
* // ...
* }
* ```
*/
list(gatewayID, params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList(path `/accounts/${account_id}/ai-gateway/gateways/${gatewayID}/evaluations`, (V4PagePaginationArray), { query, ...options });
}
/**
* Deletes an evaluation and its results. Evaluations and datasets are deprecated
* and unavailable to new accounts.
*
* @example
* ```ts
* const evaluation =
* await client.aiGateway.evaluations.delete('id', {
* account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
* gateway_id: 'my-gateway',
* });
* ```
*/
delete(id, params, options) {
const { account_id, gateway_id } = params;
return this._client.delete(path `/accounts/${account_id}/ai-gateway/gateways/${gateway_id}/evaluations/${id}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Retrieves an evaluation and its results. Evaluations and datasets are deprecated
* and unavailable to new accounts.
*
* @example
* ```ts
* const evaluation = await client.aiGateway.evaluations.get(
* 'id',
* {
* account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
* gateway_id: 'my-gateway',
* },
* );
* ```
*/
get(id, params, options) {
const { account_id, gateway_id } = params;
return this._client.get(path `/accounts/${account_id}/ai-gateway/gateways/${gateway_id}/evaluations/${id}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseEvaluations._key = Object.freeze([
'aiGateway',
'evaluations',
]);
return BaseEvaluations;
})();
export class Evaluations extends BaseEvaluations {
}
//# sourceMappingURL=evaluations.mjs.map