UNPKG

@arizeai/phoenix-client

Version:
72 lines 2.82 kB
import type { components } from "../__generated__/api/v1"; import type { ClientFn } from "../types/core"; type Span = components["schemas"]["Span"]; /** * Input or output extracted from a root span's attributes. * * @experimental this interface is experimental and may change in the future */ export interface SessionTurnIO { /** The string value of the input or output */ value: string; /** Optional MIME type (e.g. "text/plain", "application/json") */ mimeType?: string; } /** * A single turn in a session, representing one trace's root span input/output. * * **Note:** A "turn" is derived from a trace's root span. For input/output to appear, * the root span must have `input.value` and `output.value` attributes set * (per OpenInference semantic conventions). This typically requires instrumentation * that records these attributes on the top-level span. * * @experimental this interface is experimental and may change in the future */ export interface SessionTurn { /** The trace ID for this turn */ traceId: string; /** ISO 8601 timestamp of when the trace started */ startTime: string; /** ISO 8601 timestamp of when the trace ended */ endTime: string; /** Input extracted from the root span's attributes */ input?: SessionTurnIO; /** Output extracted from the root span's attributes */ output?: SessionTurnIO; /** The full root span, if found */ rootSpan?: Span; } /** * @experimental this interface is experimental and may change in the future */ export interface GetSessionTurnsParams extends ClientFn { /** The session identifier: either a GlobalID or user-provided session_id string. */ sessionId: string; } /** * Get the turns (root span I/O) for a session. * * Returns input/output extracted from root spans for each trace, along with * the full root span. Turns are ordered by trace start_time. * * **Note:** A "turn" is derived from a trace's root span. For input/output to appear, * the root span must have `input.value` and `output.value` attributes set * (per OpenInference semantic conventions). This typically requires instrumentation * that records these attributes on the top-level span. * * @experimental this function is experimental and may change in the future * * @example * ```ts * import { getSessionTurns } from "@arizeai/phoenix-client/sessions"; * * const turns = await getSessionTurns({ sessionId: "my-session" }); * for (const turn of turns) { * console.log(`[${turn.startTime}] Input: ${turn.input?.value}`); * console.log(`[${turn.startTime}] Output: ${turn.output?.value}`); * } * ``` */ export declare function getSessionTurns({ client: _client, sessionId, }: GetSessionTurnsParams): Promise<SessionTurn[]>; export {}; //# sourceMappingURL=getSessionTurns.d.ts.map