langsmith
Version:
Client library to connect to the LangSmith Observability and Evaluation Platform.
58 lines (57 loc) • 2.22 kB
JavaScript
// @ts-nocheck
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource.js';
import { ItemsCursorPostPagination, } from '../core/pagination.js';
import { buildHeaders } from '../internal/headers.js';
import { path } from '../internal/utils/path.js';
export class Traces extends 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(path `/v2/traces/${traceID}/runs`, {
query,
...options,
headers: 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', (ItemsCursorPostPagination), {
body,
method: 'post',
...options,
});
}
}