UNPKG

@arizeai/phoenix-client

Version:
57 lines 2.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addSessionNote = addSessionNote; const client_1 = require("../client"); const serverRequirements_1 = require("../constants/serverRequirements"); const apiErrorUtils_1 = require("../utils/apiErrorUtils"); const serverVersionUtils_1 = require("../utils/serverVersionUtils"); /** * Add a note to a session. * * When `sessionNote.identifier` is omitted, each call appends a new note with * an auto-generated identifier. When `identifier` is non-empty, repeated calls * with the same `(sessionId, name='note', identifier)` overwrite the existing * note. * * @param params - The parameters to add a session note. * @returns The ID of the created note annotation. * * @requires Phoenix server >= 14.17.0 * * @example * ```ts * const result = await addSessionNote({ * sessionNote: { * sessionId: "my-session", * note: "Needs review" * } * }); * ``` */ async function addSessionNote({ client: _client, sessionNote, }) { const client = _client !== null && _client !== void 0 ? _client : (0, client_1.createClient)(); await (0, serverVersionUtils_1.ensureServerCapability)({ client, requirement: serverRequirements_1.ADD_SESSION_NOTE }); if (sessionNote.identifier) { await (0, serverVersionUtils_1.ensureServerCapability)({ client, requirement: serverRequirements_1.ADD_SESSION_NOTE_IDENTIFIER, }); } const { data, error } = await client.POST("/v1/session_notes", { body: { data: { session_id: sessionNote.sessionId.trim(), note: sessionNote.note, identifier: sessionNote.identifier, }, }, }); if (error) { throw new Error(`Failed to add session note: ${(0, apiErrorUtils_1.formatApiError)(error)}`); } if (!(data === null || data === void 0 ? void 0 : data.data)) { throw new Error("Failed to add session note: no data returned"); } return data.data; } //# sourceMappingURL=addSessionNote.js.map