langsmith
Version:
Client library to connect to the LangSmith Observability and Evaluation Platform.
62 lines (61 loc) • 2.41 kB
JavaScript
;
// @ts-nocheck
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Traces = void 0;
const resource_js_1 = require("../core/resource.cjs");
const pagination_js_1 = require("../core/pagination.cjs");
const headers_js_1 = require("../internal/headers.cjs");
const path_js_1 = require("../internal/utils/path.cjs");
class Traces extends resource_js_1.APIResource {
/**
* **Alpha:** The request and response contract may change; Returns runs for a
* trace ID within min/max start time. Optional `filter`; repeatable `selects` to
* select fields to return.
*
* @example
* ```ts
* const response = await client.traces.listRuns(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { project_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' },
* );
* ```
*/
listRuns(traceID, params, options) {
const { Accept, ...query } = params;
return this._client.get((0, path_js_1.path) `/v2/traces/${traceID}/runs`, {
query,
...options,
headers: (0, headers_js_1.buildHeaders)([{ ...(Accept != null ? { Accept: Accept } : undefined) }, options?.headers]),
});
}
/**
* Returns a paginated list of traces (root runs) for a single tracing project.
* Each item carries the trace's root run plus optional trace-wide aggregates
* (`total_tokens`, `total_cost`, `first_token_time`) under `trace_aggregates`, so
* clients never have to merge by `trace_id`.
*
* Traces are scanned within a `start_time` window: `min_start_time` defaults to 24
* hours before the request, `max_start_time` defaults to the request time. Set
* either explicitly to widen or narrow the window.
*
* Supports filters (`trace_filter`, `tree_filter`), cursor pagination (`cursor`),
* and field projection (`selects`).
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const trace of client.traces.query()) {
* // ...
* }
* ```
*/
query(body, options) {
return this._client.getAPIList('/v2/traces/query', (pagination_js_1.ItemsCursorPostPagination), {
body,
method: 'post',
...options,
});
}
}
exports.Traces = Traces;