UNPKG

@arizeai/phoenix-client

Version:

A client for the Phoenix API

48 lines 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addSessionAnnotation = addSessionAnnotation; const client_1 = require("../client"); const types_1 = require("./types"); /** * Add an annotation to a session. * * The annotation can be of type "LLM", "CODE", or "HUMAN" and can include a label, score, and metadata. * If an identifier is provided and an annotation with that identifier already exists, it will be updated. * * @param params - The parameters to add a span annotation * @returns The ID of the created or updated annotation * * @example * ```ts * const result = await addSessionAnnotation({ * sessionAnnotation: { * sessionId: "123abc", * name: "quality_score", * label: "good", * score: 0.95, * annotatorKind: "LLM", * identifier: "custom_id_123", * metadata: { * model: "gpt-4" * } * } * }); * ``` */ async function addSessionAnnotation({ client: _client, sessionAnnotation, sync = false, }) { var _a; const client = _client !== null && _client !== void 0 ? _client : (0, client_1.createClient)(); const { data, error } = await client.POST("/v1/session_annotations", { params: { query: { sync }, }, body: { data: [(0, types_1.toSessionAnnotationData)(sessionAnnotation)], }, }); if (error) { throw new Error(`Failed to add session annotation: ${error}`); } return ((_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a[0]) || null; } //# sourceMappingURL=addSessionAnnotation.js.map