import { APIResource } from "../../core/resource.mjs"; import * as Shared from "../shared.mjs"; import * as RunsAPI from "../runs/runs.mjs"; import * as TracesAPI from "./traces.mjs"; import { APIPromise } from "../../core/api-promise.mjs"; import { Stream } from "../../core/streaming.mjs"; import { RequestOptions } from "../../internal/request-options.mjs"; export declare class Streaming extends APIResource { /** * GET with body payload — no resources created. Returns the traces matching the * query passed as the request payload. * * 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`). * * `ai_search` cannot be combined with `sem_filter`. With full AI search enabled, * `ai_search` translates natural language into query filters and time bounds and * cannot be combined with explicit filter expressions. Otherwise, `ai_search` * retains legacy semantic-only behavior. Use `sem_filter` for semantic-only * matching combined with structured filters. AI search requires organization * consent. When semantic matching is needed, `Accept: text/event-stream` is * required; requests without it return 406. AI search is unavailable on * deployments that route queries to the v1 backend and returns 501 there. * * Self-hosted deployments require LangSmith `v0.16` or later. * * @example * ```ts * const response = await client.traces.streaming.query(); * ``` */ query(params: StreamingQueryParams, options?: RequestOptions): APIPromise>; /** * Yields the items of `query` one at a time across pages, following the next page cursor. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const trace of client.traces.streaming.queryItems( * {}, * )) { * // ... * } * ``` */ queryItems(params: StreamingQueryParams, options?: RequestOptions): AsyncIterable; } export interface StreamingQueryResponse { /** * `items` is the page of traces. */ items?: Array; /** * `next_cursor` is the opaque cursor for the next page. Null on the final page. */ next_cursor?: string; } export interface StreamingQueryParams { /** * Body param: `ai_search` translates natural language into structured filters, * semantic criteria and time bounds. Cannot be combined with sem_filter. With full * AI search enabled, also cannot be combined with explicit filter expressions; * otherwise retains legacy semantic-only behavior. Must contain nonempty text of * at most 2000 UTF-8 bytes. */ ai_search?: string; /** * Body param: `cursor` is the opaque string returned in a previous response's * `next_cursor`. */ cursor?: string; /** * Body param: `max_feedback_modified_at` is the exclusive upper bound (RFC3339) on * feedback `modified_at`, applied to the feedback conditions in `trace_filter` or * `tree_filter` (for example eq(feedback_key, "correctness")). Requires at least * one feedback condition. Root runs must still fall within the `start_time` * window. */ max_feedback_modified_at?: string; /** * Body param: `max_start_time` is the exclusive upper bound for the root-run start * time scan (RFC3339). Defaults to the request time when omitted. */ max_start_time?: string; /** * Body param: `min_feedback_modified_at` is the inclusive lower bound (RFC3339) on * feedback `modified_at`, applied to the feedback conditions in `trace_filter` or * `tree_filter` (for example eq(feedback_key, "correctness")). Requires at least * one feedback condition. Root runs must still fall within the `start_time` * window. */ min_feedback_modified_at?: string; /** * Body param: `min_start_time` is the inclusive lower bound for the root-run start * time scan (RFC3339). Defaults to 24 hours before the request when omitted. */ min_start_time?: string; /** * Body param: `page_size` is the maximum number of traces to return per page. * Defaults to 20; must be between 1 and 100 when set. */ page_size?: number; /** * Body param: `project_id` is the UUID of the tracing project that owns the * traces. Required. */ project_id?: string; /** * Body param: `selects` lists which properties to include on each returned trace. * Properties listed here are routed to the appropriate sub-object on each item: * `total_tokens`, `total_cost`, and `first_token_time` appear under * `trace_aggregates`; everything else appears under `root_run`. If omitted, only * `id` is returned on `root_run`. */ selects?: Array; /** * Body param: SemFilter evaluates a plain-language criterion against trajectory * messages, AND-ed with structured filters. */ sem_filter?: string; /** * Body param: `trace_filter` narrows results to traces whose root run matches this * LangSmith filter expression. This filter targets root runs only — * `is_root = true` is implied. See * https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language * for syntax. */ trace_filter?: string; /** * Body param: `trace_ids` is an optional fast-path restriction to a known set of * trace UUIDs. Equivalent in result to including each UUID in a `trace_filter`, * but more efficient at scale. */ trace_ids?: Array; /** * Body param: `tree_filter` narrows results to traces containing at least one run * anywhere in the run tree (root or descendant) that matches this LangSmith filter * expression. */ tree_filter?: string; /** * Header param: application/json, or text/event-stream (required for semantic * matching) */ Accept?: string; } export declare namespace Streaming { export { type StreamingQueryResponse as StreamingQueryResponse, type StreamingQueryParams as StreamingQueryParams, }; }