langsmith
Version:
Client library to connect to the LangSmith Observability and Evaluation Platform.
67 lines (66 loc) • 2.79 kB
JavaScript
// @ts-nocheck
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource.js';
import { OffsetPaginationOnlineEvaluators, } from '../core/pagination.js';
import { buildHeaders } from '../internal/headers.js';
import { path } from '../internal/utils/path.js';
export class OnlineEvaluators extends APIResource {
/**
* Create a new LLM or code evaluator for the current workspace.
*/
create(body, options) {
return this._client.post('/v1/platform/evaluators', { body, ...options });
}
/**
* Retrieve a single evaluator by its ID.
*/
retrieve(evaluatorID, options) {
return this._client.get(path `/v1/platform/evaluators/${evaluatorID}`, options);
}
/**
* Update an existing evaluator's name, LLM configuration, or code configuration.
*/
update(evaluatorID, body, options) {
return this._client.patch(path `/v1/platform/evaluators/${evaluatorID}`, { body, ...options });
}
/**
* List evaluators for the current workspace, with optional filtering by type,
* name, tag, feedback key, or resource ID.
*/
list(query = {}, options) {
return this._client.getAPIList('/v1/platform/evaluators', (OffsetPaginationOnlineEvaluators), { query, ...options });
}
/**
* Delete an evaluator. When delete_run_rules is true, all run rules referencing
* this evaluator are deleted first (same tenant). Associated llm_evaluators and
* code_evaluators rows are removed by foreign-key cascade when the evaluator row
* is deleted.
*/
delete(evaluatorID, params = {}, options) {
const { delete_run_rules } = params ?? {};
return this._client.delete(path `/v1/platform/evaluators/${evaluatorID}`, {
query: { delete_run_rules },
...options,
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
});
}
/**
* Delete multiple evaluators by their IDs. Returns per-item success/failure.
*/
bulkDelete(params, options) {
const { evaluator_ids, delete_run_rules } = params;
return this._client.delete('/v1/platform/evaluators', {
query: { evaluator_ids, delete_run_rules },
...options,
});
}
/**
* Returns per-day LLM evaluator spend for the requested 7-day period, grouped by
* evaluator, resource, or run rule. Exactly one of group_by, evaluator_id,
* session_id, or dataset_id is required. resource_id, type, and feedback_key may
* be supplied with group_by to narrow listing aggregations.
*/
spend(query, options) {
return this._client.get('/v1/platform/evaluators/spend', { query, ...options });
}
}