@arizeai/phoenix-client
Version:
A client for the Phoenix API
53 lines • 1.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.logTraceAnnotations = logTraceAnnotations;
const client_1 = require("../client");
const types_1 = require("./types");
/**
* Log multiple trace annotations in a single request.
*
* Each 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 log trace annotations
* @returns The IDs of the created or updated annotations
*
* @example
* ```ts
* const results = await logTraceAnnotations({
* traceAnnotations: [
* {
* traceId: "abc123",
* name: "correctness",
* label: "correct",
* score: 1.0,
* annotatorKind: "HUMAN",
* },
* {
* traceId: "def456",
* name: "faithfulness",
* label: "faithful",
* score: 0.9,
* annotatorKind: "LLM",
* },
* ],
* sync: true,
* });
* ```
*/
async function logTraceAnnotations({ client: _client, traceAnnotations, sync = false, }) {
const client = _client !== null && _client !== void 0 ? _client : (0, client_1.createClient)();
const { data, error } = await client.POST("/v1/trace_annotations", {
params: {
query: { sync },
},
body: {
data: traceAnnotations.map(types_1.toTraceAnnotationData),
},
});
if (error) {
throw new Error(`Failed to log trace annotations: ${error}`);
}
return (data === null || data === void 0 ? void 0 : data.data) || [];
}
//# sourceMappingURL=logTraceAnnotations.js.map