@langfuse/core 5.5.0-beta.2 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +175 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -19
- package/dist/index.d.ts +74 -19
- package/dist/index.mjs +175 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -276,7 +276,7 @@ var resetGlobalLogger = () => {
|
|
|
276
276
|
// package.json
|
|
277
277
|
var package_default = {
|
|
278
278
|
name: "@langfuse/core",
|
|
279
|
-
version: "5.5.0
|
|
279
|
+
version: "5.5.0",
|
|
280
280
|
description: "Core functions and utilities for Langfuse packages",
|
|
281
281
|
type: "module",
|
|
282
282
|
sideEffects: false,
|
|
@@ -11446,15 +11446,22 @@ var ScoresV3 = class {
|
|
|
11446
11446
|
/**
|
|
11447
11447
|
* Get a list of scores with a polymorphic `value` field (v3).
|
|
11448
11448
|
*
|
|
11449
|
-
* This endpoint requires Langfuse v4 or later.
|
|
11450
|
-
*
|
|
11451
11449
|
* The `value` field type depends on `dataType`:
|
|
11452
11450
|
* - `NUMERIC` → number
|
|
11453
11451
|
* - `BOOLEAN` → boolean
|
|
11454
11452
|
* - `CATEGORICAL`, `TEXT`, `CORRECTION` → string
|
|
11455
11453
|
*
|
|
11456
|
-
*
|
|
11457
|
-
*
|
|
11454
|
+
* The response always includes the core fields: id, projectId, name,
|
|
11455
|
+
* value, dataType, source, timestamp, environment, createdAt, updatedAt.
|
|
11456
|
+
*
|
|
11457
|
+
* Additional field groups can be requested via the `fields` parameter:
|
|
11458
|
+
* - `details` — adds comment, configId, metadata
|
|
11459
|
+
* - `subject` — adds the subject object describing the entity the score
|
|
11460
|
+
* is attached to: kind (trace, observation, session, or experiment),
|
|
11461
|
+
* id, and traceId for observation-level scores
|
|
11462
|
+
* - `annotation` — adds authorUserId, queueId
|
|
11463
|
+
*
|
|
11464
|
+
* Unknown group names return HTTP 400.
|
|
11458
11465
|
*
|
|
11459
11466
|
* @param {LangfuseAPI.GetScoresV3Request} request
|
|
11460
11467
|
* @param {ScoresV3.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -11658,6 +11665,9 @@ var Scores = class {
|
|
|
11658
11665
|
this._options = _options;
|
|
11659
11666
|
}
|
|
11660
11667
|
/**
|
|
11668
|
+
* **Deprecated.** Use `GET /api/public/v3/scores` instead. This endpoint
|
|
11669
|
+
* is no longer available on Langfuse v4 and later.
|
|
11670
|
+
*
|
|
11661
11671
|
* Get a list of scores (supports both trace and session scores)
|
|
11662
11672
|
*
|
|
11663
11673
|
* @param {LangfuseAPI.GetScoresRequest} request
|
|
@@ -11856,6 +11866,9 @@ var Scores = class {
|
|
|
11856
11866
|
}
|
|
11857
11867
|
}
|
|
11858
11868
|
/**
|
|
11869
|
+
* **Deprecated.** Use `GET /api/public/v3/scores` with the `id` filter
|
|
11870
|
+
* instead. This endpoint is no longer available on Langfuse v4 and later.
|
|
11871
|
+
*
|
|
11859
11872
|
* Get a score (supports both trace and session scores)
|
|
11860
11873
|
*
|
|
11861
11874
|
* @param {string} scoreId - The unique langfuse identifier of a score
|
|
@@ -14151,6 +14164,163 @@ var Evaluators = class {
|
|
|
14151
14164
|
});
|
|
14152
14165
|
}
|
|
14153
14166
|
}
|
|
14167
|
+
/**
|
|
14168
|
+
* Delete an evaluator.
|
|
14169
|
+
*
|
|
14170
|
+
* Important behavior:
|
|
14171
|
+
* - This deletes the evaluator including all of its stored versions; `evaluatorId` may reference any version.
|
|
14172
|
+
* - The API returns `409` while evaluation rules still reference the evaluator. Delete those evaluation rules first.
|
|
14173
|
+
* - Langfuse-managed evaluators (`scope=managed`) cannot be deleted; the API returns `403`.
|
|
14174
|
+
* - Scores already produced by the evaluator are not deleted.
|
|
14175
|
+
*
|
|
14176
|
+
* @param {string} evaluatorId - Evaluator identifier returned by the evaluator endpoints.
|
|
14177
|
+
* @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
|
|
14178
|
+
*
|
|
14179
|
+
* @throws {@link LangfuseAPI.unstable.BadRequestError}
|
|
14180
|
+
* @throws {@link LangfuseAPI.unstable.UnauthorizedError}
|
|
14181
|
+
* @throws {@link LangfuseAPI.unstable.AccessDeniedError}
|
|
14182
|
+
* @throws {@link LangfuseAPI.unstable.NotFoundError}
|
|
14183
|
+
* @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
|
|
14184
|
+
* @throws {@link LangfuseAPI.unstable.ConflictError}
|
|
14185
|
+
* @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
|
|
14186
|
+
* @throws {@link LangfuseAPI.unstable.InternalServerError}
|
|
14187
|
+
* @throws {@link LangfuseAPI.Error}
|
|
14188
|
+
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
14189
|
+
* @throws {@link LangfuseAPI.AccessDeniedError}
|
|
14190
|
+
* @throws {@link LangfuseAPI.MethodNotAllowedError}
|
|
14191
|
+
* @throws {@link LangfuseAPI.NotFoundError}
|
|
14192
|
+
*
|
|
14193
|
+
* @example
|
|
14194
|
+
* await client.unstable.evaluators.delete("evaluatorId")
|
|
14195
|
+
*/
|
|
14196
|
+
delete(evaluatorId, requestOptions) {
|
|
14197
|
+
return HttpResponsePromise.fromPromise(
|
|
14198
|
+
this.__delete(evaluatorId, requestOptions)
|
|
14199
|
+
);
|
|
14200
|
+
}
|
|
14201
|
+
async __delete(evaluatorId, requestOptions) {
|
|
14202
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
14203
|
+
let _headers = mergeHeaders(
|
|
14204
|
+
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
14205
|
+
mergeOnlyDefinedHeaders({
|
|
14206
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
14207
|
+
"X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
|
|
14208
|
+
"X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
|
|
14209
|
+
"X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
|
|
14210
|
+
}),
|
|
14211
|
+
requestOptions == null ? void 0 : requestOptions.headers
|
|
14212
|
+
);
|
|
14213
|
+
const _response = await fetcher({
|
|
14214
|
+
url: url_exports.join(
|
|
14215
|
+
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
14216
|
+
`/api/public/unstable/evaluators/${encodeURIComponent(evaluatorId)}`
|
|
14217
|
+
),
|
|
14218
|
+
method: "DELETE",
|
|
14219
|
+
headers: _headers,
|
|
14220
|
+
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
14221
|
+
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
14222
|
+
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
14223
|
+
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
14224
|
+
});
|
|
14225
|
+
if (_response.ok) {
|
|
14226
|
+
return {
|
|
14227
|
+
data: _response.body,
|
|
14228
|
+
rawResponse: _response.rawResponse
|
|
14229
|
+
};
|
|
14230
|
+
}
|
|
14231
|
+
if (_response.error.reason === "status-code") {
|
|
14232
|
+
switch (_response.error.statusCode) {
|
|
14233
|
+
case 400:
|
|
14234
|
+
throw new unstable_exports.BadRequestError(
|
|
14235
|
+
_response.error.body,
|
|
14236
|
+
_response.rawResponse
|
|
14237
|
+
);
|
|
14238
|
+
case 401:
|
|
14239
|
+
throw new unstable_exports.UnauthorizedError(
|
|
14240
|
+
_response.error.body,
|
|
14241
|
+
_response.rawResponse
|
|
14242
|
+
);
|
|
14243
|
+
case 403:
|
|
14244
|
+
throw new unstable_exports.AccessDeniedError(
|
|
14245
|
+
_response.error.body,
|
|
14246
|
+
_response.rawResponse
|
|
14247
|
+
);
|
|
14248
|
+
case 404:
|
|
14249
|
+
throw new unstable_exports.NotFoundError(
|
|
14250
|
+
_response.error.body,
|
|
14251
|
+
_response.rawResponse
|
|
14252
|
+
);
|
|
14253
|
+
case 405:
|
|
14254
|
+
throw new unstable_exports.MethodNotAllowedError(
|
|
14255
|
+
_response.error.body,
|
|
14256
|
+
_response.rawResponse
|
|
14257
|
+
);
|
|
14258
|
+
case 409:
|
|
14259
|
+
throw new unstable_exports.ConflictError(
|
|
14260
|
+
_response.error.body,
|
|
14261
|
+
_response.rawResponse
|
|
14262
|
+
);
|
|
14263
|
+
case 429:
|
|
14264
|
+
throw new unstable_exports.TooManyRequestsError(
|
|
14265
|
+
_response.error.body,
|
|
14266
|
+
_response.rawResponse
|
|
14267
|
+
);
|
|
14268
|
+
case 500:
|
|
14269
|
+
throw new unstable_exports.InternalServerError(
|
|
14270
|
+
_response.error.body,
|
|
14271
|
+
_response.rawResponse
|
|
14272
|
+
);
|
|
14273
|
+
case 400:
|
|
14274
|
+
throw new Error2(
|
|
14275
|
+
_response.error.body,
|
|
14276
|
+
_response.rawResponse
|
|
14277
|
+
);
|
|
14278
|
+
case 401:
|
|
14279
|
+
throw new UnauthorizedError(
|
|
14280
|
+
_response.error.body,
|
|
14281
|
+
_response.rawResponse
|
|
14282
|
+
);
|
|
14283
|
+
case 403:
|
|
14284
|
+
throw new AccessDeniedError(
|
|
14285
|
+
_response.error.body,
|
|
14286
|
+
_response.rawResponse
|
|
14287
|
+
);
|
|
14288
|
+
case 405:
|
|
14289
|
+
throw new MethodNotAllowedError(
|
|
14290
|
+
_response.error.body,
|
|
14291
|
+
_response.rawResponse
|
|
14292
|
+
);
|
|
14293
|
+
case 404:
|
|
14294
|
+
throw new NotFoundError(
|
|
14295
|
+
_response.error.body,
|
|
14296
|
+
_response.rawResponse
|
|
14297
|
+
);
|
|
14298
|
+
default:
|
|
14299
|
+
throw new LangfuseAPIError({
|
|
14300
|
+
statusCode: _response.error.statusCode,
|
|
14301
|
+
body: _response.error.body,
|
|
14302
|
+
rawResponse: _response.rawResponse
|
|
14303
|
+
});
|
|
14304
|
+
}
|
|
14305
|
+
}
|
|
14306
|
+
switch (_response.error.reason) {
|
|
14307
|
+
case "non-json":
|
|
14308
|
+
throw new LangfuseAPIError({
|
|
14309
|
+
statusCode: _response.error.statusCode,
|
|
14310
|
+
body: _response.error.rawBody,
|
|
14311
|
+
rawResponse: _response.rawResponse
|
|
14312
|
+
});
|
|
14313
|
+
case "timeout":
|
|
14314
|
+
throw new LangfuseAPITimeoutError(
|
|
14315
|
+
"Timeout exceeded when calling DELETE /api/public/unstable/evaluators/{evaluatorId}."
|
|
14316
|
+
);
|
|
14317
|
+
case "unknown":
|
|
14318
|
+
throw new LangfuseAPIError({
|
|
14319
|
+
message: _response.error.errorMessage,
|
|
14320
|
+
rawResponse: _response.rawResponse
|
|
14321
|
+
});
|
|
14322
|
+
}
|
|
14323
|
+
}
|
|
14154
14324
|
async _getAuthorizationHeader() {
|
|
14155
14325
|
const username = await Supplier.get(this._options.username);
|
|
14156
14326
|
const password = await Supplier.get(this._options.password);
|