UNPKG

langsmith

Version:

Client library to connect to the LangSmith Observability and Evaluation Platform.

62 lines (61 loc) 2.19 kB
// @ts-nocheck // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource.js'; import { ItemsCursorGetPagination, ItemsCursorPostPagination, } from '../core/pagination.js'; import { path } from '../internal/utils/path.js'; export class Threads extends APIResource { /** * **Alpha:** The request and response contract may change; Retrieve all traces * belonging to a specific thread within a project. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const threadTraceListItem of client.threads.listTraces( * 'thread_id', * { project_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' }, * )) { * // ... * } * ``` */ listTraces(threadID, query, options) { return this._client.getAPIList(path `/v2/threads/${threadID}/traces`, (ItemsCursorGetPagination), { query, ...options }); } /** * **Alpha:** The request and response contract may change; Query threads within a * project (session), with cursor-based pagination. Returns threads matching the * given time range and optional filter. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const threadListItem of client.threads.query()) { * // ... * } * ``` */ query(body, options) { return this._client.getAPIList('/v2/threads/query', (ItemsCursorPostPagination), { body, method: 'post', ...options, }); } /** * **Alpha:** The request and response contract may change; Compute aggregate stats * for a single thread (turn count, latency percentiles, token/cost sums, and * detail breakdowns) within a project. * * @example * ```ts * const response = await client.threads.stats('thread_id', { * selects: ['TURNS'], * session_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * }); * ``` */ stats(threadID, query, options) { return this._client.get(path `/v2/threads/${threadID}/stats`, { query, ...options }); } }