@langfuse/core 5.0.0-beta.1 → 5.0.1
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 +953 -820
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1145 -1041
- package/dist/index.d.ts +1145 -1041
- package/dist/index.mjs +951 -817
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -273,7 +273,7 @@ var resetGlobalLogger = () => {
|
|
|
273
273
|
// package.json
|
|
274
274
|
var package_default = {
|
|
275
275
|
name: "@langfuse/core",
|
|
276
|
-
version: "5.0.
|
|
276
|
+
version: "5.0.1",
|
|
277
277
|
description: "Core functions and utilities for Langfuse packages",
|
|
278
278
|
type: "module",
|
|
279
279
|
sideEffects: false,
|
|
@@ -384,7 +384,8 @@ __export(blobStorageIntegrations_exports, {
|
|
|
384
384
|
BlobStorageExportFrequency: () => BlobStorageExportFrequency,
|
|
385
385
|
BlobStorageExportMode: () => BlobStorageExportMode,
|
|
386
386
|
BlobStorageIntegrationFileType: () => BlobStorageIntegrationFileType,
|
|
387
|
-
BlobStorageIntegrationType: () => BlobStorageIntegrationType
|
|
387
|
+
BlobStorageIntegrationType: () => BlobStorageIntegrationType,
|
|
388
|
+
BlobStorageSyncStatus: () => BlobStorageSyncStatus
|
|
388
389
|
});
|
|
389
390
|
|
|
390
391
|
// src/api/api/resources/blobStorageIntegrations/types/BlobStorageIntegrationType.ts
|
|
@@ -415,6 +416,15 @@ var BlobStorageExportFrequency = {
|
|
|
415
416
|
Weekly: "weekly"
|
|
416
417
|
};
|
|
417
418
|
|
|
419
|
+
// src/api/api/resources/blobStorageIntegrations/types/BlobStorageSyncStatus.ts
|
|
420
|
+
var BlobStorageSyncStatus = {
|
|
421
|
+
Idle: "idle",
|
|
422
|
+
Queued: "queued",
|
|
423
|
+
UpToDate: "up_to_date",
|
|
424
|
+
Disabled: "disabled",
|
|
425
|
+
Error: "error"
|
|
426
|
+
};
|
|
427
|
+
|
|
418
428
|
// src/api/api/resources/comments/index.ts
|
|
419
429
|
var comments_exports = {};
|
|
420
430
|
|
|
@@ -661,6 +671,23 @@ var ObservationType = {
|
|
|
661
671
|
Guardrail: "GUARDRAIL"
|
|
662
672
|
};
|
|
663
673
|
|
|
674
|
+
// src/api/api/resources/legacy/index.ts
|
|
675
|
+
var legacy_exports = {};
|
|
676
|
+
__export(legacy_exports, {
|
|
677
|
+
metricsV1: () => metricsV1_exports,
|
|
678
|
+
observationsV1: () => observationsV1_exports,
|
|
679
|
+
scoreV1: () => scoreV1_exports
|
|
680
|
+
});
|
|
681
|
+
|
|
682
|
+
// src/api/api/resources/legacy/resources/metricsV1/index.ts
|
|
683
|
+
var metricsV1_exports = {};
|
|
684
|
+
|
|
685
|
+
// src/api/api/resources/legacy/resources/observationsV1/index.ts
|
|
686
|
+
var observationsV1_exports = {};
|
|
687
|
+
|
|
688
|
+
// src/api/api/resources/legacy/resources/scoreV1/index.ts
|
|
689
|
+
var scoreV1_exports = {};
|
|
690
|
+
|
|
664
691
|
// src/api/api/resources/llmConnections/index.ts
|
|
665
692
|
var llmConnections_exports = {};
|
|
666
693
|
__export(llmConnections_exports, {
|
|
@@ -739,18 +766,12 @@ var MediaContentType = {
|
|
|
739
766
|
ApplicationX7ZCompressed: "application/x-7z-compressed"
|
|
740
767
|
};
|
|
741
768
|
|
|
742
|
-
// src/api/api/resources/metricsV2/index.ts
|
|
743
|
-
var metricsV2_exports = {};
|
|
744
|
-
|
|
745
769
|
// src/api/api/resources/metrics/index.ts
|
|
746
770
|
var metrics_exports = {};
|
|
747
771
|
|
|
748
772
|
// src/api/api/resources/models/index.ts
|
|
749
773
|
var models_exports = {};
|
|
750
774
|
|
|
751
|
-
// src/api/api/resources/observationsV2/index.ts
|
|
752
|
-
var observationsV2_exports = {};
|
|
753
|
-
|
|
754
775
|
// src/api/api/resources/observations/index.ts
|
|
755
776
|
var observations_exports = {};
|
|
756
777
|
|
|
@@ -816,11 +837,8 @@ var scim_exports = {};
|
|
|
816
837
|
// src/api/api/resources/scoreConfigs/index.ts
|
|
817
838
|
var scoreConfigs_exports = {};
|
|
818
839
|
|
|
819
|
-
// src/api/api/resources/
|
|
820
|
-
var
|
|
821
|
-
|
|
822
|
-
// src/api/api/resources/score/index.ts
|
|
823
|
-
var score_exports = {};
|
|
840
|
+
// src/api/api/resources/scores/index.ts
|
|
841
|
+
var scores_exports = {};
|
|
824
842
|
|
|
825
843
|
// src/api/api/resources/sessions/index.ts
|
|
826
844
|
var sessions_exports = {};
|
|
@@ -2912,6 +2930,109 @@ var BlobStorageIntegrations = class {
|
|
|
2912
2930
|
});
|
|
2913
2931
|
}
|
|
2914
2932
|
}
|
|
2933
|
+
/**
|
|
2934
|
+
* Get the sync status of a blob storage integration by integration ID (requires organization-scoped API key)
|
|
2935
|
+
*
|
|
2936
|
+
* @param {string} id
|
|
2937
|
+
* @param {BlobStorageIntegrations.RequestOptions} requestOptions - Request-specific configuration.
|
|
2938
|
+
*
|
|
2939
|
+
* @throws {@link LangfuseAPI.Error}
|
|
2940
|
+
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
2941
|
+
* @throws {@link LangfuseAPI.AccessDeniedError}
|
|
2942
|
+
* @throws {@link LangfuseAPI.MethodNotAllowedError}
|
|
2943
|
+
* @throws {@link LangfuseAPI.NotFoundError}
|
|
2944
|
+
*
|
|
2945
|
+
* @example
|
|
2946
|
+
* await client.blobStorageIntegrations.getBlobStorageIntegrationStatus("id")
|
|
2947
|
+
*/
|
|
2948
|
+
getBlobStorageIntegrationStatus(id, requestOptions) {
|
|
2949
|
+
return HttpResponsePromise.fromPromise(
|
|
2950
|
+
this.__getBlobStorageIntegrationStatus(id, requestOptions)
|
|
2951
|
+
);
|
|
2952
|
+
}
|
|
2953
|
+
async __getBlobStorageIntegrationStatus(id, requestOptions) {
|
|
2954
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
2955
|
+
let _headers = mergeHeaders(
|
|
2956
|
+
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
2957
|
+
mergeOnlyDefinedHeaders({
|
|
2958
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
2959
|
+
"X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
|
|
2960
|
+
"X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
|
|
2961
|
+
"X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
|
|
2962
|
+
}),
|
|
2963
|
+
requestOptions == null ? void 0 : requestOptions.headers
|
|
2964
|
+
);
|
|
2965
|
+
const _response = await fetcher({
|
|
2966
|
+
url: url_exports.join(
|
|
2967
|
+
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
2968
|
+
`/api/public/integrations/blob-storage/${encodeURIComponent(id)}`
|
|
2969
|
+
),
|
|
2970
|
+
method: "GET",
|
|
2971
|
+
headers: _headers,
|
|
2972
|
+
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
2973
|
+
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
2974
|
+
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
2975
|
+
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
2976
|
+
});
|
|
2977
|
+
if (_response.ok) {
|
|
2978
|
+
return {
|
|
2979
|
+
data: _response.body,
|
|
2980
|
+
rawResponse: _response.rawResponse
|
|
2981
|
+
};
|
|
2982
|
+
}
|
|
2983
|
+
if (_response.error.reason === "status-code") {
|
|
2984
|
+
switch (_response.error.statusCode) {
|
|
2985
|
+
case 400:
|
|
2986
|
+
throw new Error2(
|
|
2987
|
+
_response.error.body,
|
|
2988
|
+
_response.rawResponse
|
|
2989
|
+
);
|
|
2990
|
+
case 401:
|
|
2991
|
+
throw new UnauthorizedError(
|
|
2992
|
+
_response.error.body,
|
|
2993
|
+
_response.rawResponse
|
|
2994
|
+
);
|
|
2995
|
+
case 403:
|
|
2996
|
+
throw new AccessDeniedError(
|
|
2997
|
+
_response.error.body,
|
|
2998
|
+
_response.rawResponse
|
|
2999
|
+
);
|
|
3000
|
+
case 405:
|
|
3001
|
+
throw new MethodNotAllowedError(
|
|
3002
|
+
_response.error.body,
|
|
3003
|
+
_response.rawResponse
|
|
3004
|
+
);
|
|
3005
|
+
case 404:
|
|
3006
|
+
throw new NotFoundError(
|
|
3007
|
+
_response.error.body,
|
|
3008
|
+
_response.rawResponse
|
|
3009
|
+
);
|
|
3010
|
+
default:
|
|
3011
|
+
throw new LangfuseAPIError({
|
|
3012
|
+
statusCode: _response.error.statusCode,
|
|
3013
|
+
body: _response.error.body,
|
|
3014
|
+
rawResponse: _response.rawResponse
|
|
3015
|
+
});
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
3018
|
+
switch (_response.error.reason) {
|
|
3019
|
+
case "non-json":
|
|
3020
|
+
throw new LangfuseAPIError({
|
|
3021
|
+
statusCode: _response.error.statusCode,
|
|
3022
|
+
body: _response.error.rawBody,
|
|
3023
|
+
rawResponse: _response.rawResponse
|
|
3024
|
+
});
|
|
3025
|
+
case "timeout":
|
|
3026
|
+
throw new LangfuseAPITimeoutError(
|
|
3027
|
+
"Timeout exceeded when calling GET /api/public/integrations/blob-storage/{id}."
|
|
3028
|
+
);
|
|
3029
|
+
case "unknown":
|
|
3030
|
+
throw new LangfuseAPIError({
|
|
3031
|
+
message: _response.error.errorMessage,
|
|
3032
|
+
rawResponse: _response.rawResponse
|
|
3033
|
+
});
|
|
3034
|
+
}
|
|
3035
|
+
}
|
|
2915
3036
|
/**
|
|
2916
3037
|
* Delete a blob storage integration by ID (requires organization-scoped API key)
|
|
2917
3038
|
*
|
|
@@ -5072,16 +5193,20 @@ var Ingestion = class {
|
|
|
5072
5193
|
}
|
|
5073
5194
|
};
|
|
5074
5195
|
|
|
5075
|
-
// src/api/api/resources/
|
|
5076
|
-
var
|
|
5196
|
+
// src/api/api/resources/legacy/resources/metricsV1/client/Client.ts
|
|
5197
|
+
var MetricsV1 = class {
|
|
5077
5198
|
constructor(_options) {
|
|
5078
5199
|
this._options = _options;
|
|
5079
5200
|
}
|
|
5080
5201
|
/**
|
|
5081
|
-
* Get
|
|
5202
|
+
* Get metrics from the Langfuse project using a query object.
|
|
5082
5203
|
*
|
|
5083
|
-
*
|
|
5084
|
-
*
|
|
5204
|
+
* Consider using the [v2 metrics endpoint](/api-reference#tag/metricsv2/GET/api/public/v2/metrics) for better performance.
|
|
5205
|
+
*
|
|
5206
|
+
* For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api).
|
|
5207
|
+
*
|
|
5208
|
+
* @param {LangfuseAPI.legacy.GetMetricsRequest} request
|
|
5209
|
+
* @param {MetricsV1.RequestOptions} requestOptions - Request-specific configuration.
|
|
5085
5210
|
*
|
|
5086
5211
|
* @throws {@link LangfuseAPI.Error}
|
|
5087
5212
|
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
@@ -5090,23 +5215,20 @@ var LlmConnections = class {
|
|
|
5090
5215
|
* @throws {@link LangfuseAPI.NotFoundError}
|
|
5091
5216
|
*
|
|
5092
5217
|
* @example
|
|
5093
|
-
* await client.
|
|
5218
|
+
* await client.legacy.metricsV1.metrics({
|
|
5219
|
+
* query: "query"
|
|
5220
|
+
* })
|
|
5094
5221
|
*/
|
|
5095
|
-
|
|
5222
|
+
metrics(request, requestOptions) {
|
|
5096
5223
|
return HttpResponsePromise.fromPromise(
|
|
5097
|
-
this.
|
|
5224
|
+
this.__metrics(request, requestOptions)
|
|
5098
5225
|
);
|
|
5099
5226
|
}
|
|
5100
|
-
async
|
|
5227
|
+
async __metrics(request, requestOptions) {
|
|
5101
5228
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
5102
|
-
const {
|
|
5229
|
+
const { query } = request;
|
|
5103
5230
|
const _queryParams = {};
|
|
5104
|
-
|
|
5105
|
-
_queryParams["page"] = page.toString();
|
|
5106
|
-
}
|
|
5107
|
-
if (limit != null) {
|
|
5108
|
-
_queryParams["limit"] = limit.toString();
|
|
5109
|
-
}
|
|
5231
|
+
_queryParams["query"] = query;
|
|
5110
5232
|
let _headers = mergeHeaders(
|
|
5111
5233
|
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
5112
5234
|
mergeOnlyDefinedHeaders({
|
|
@@ -5120,7 +5242,7 @@ var LlmConnections = class {
|
|
|
5120
5242
|
const _response = await fetcher({
|
|
5121
5243
|
url: url_exports.join(
|
|
5122
5244
|
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
5123
|
-
"/api/public/
|
|
5245
|
+
"/api/public/metrics"
|
|
5124
5246
|
),
|
|
5125
5247
|
method: "GET",
|
|
5126
5248
|
headers: _headers,
|
|
@@ -5179,7 +5301,7 @@ var LlmConnections = class {
|
|
|
5179
5301
|
});
|
|
5180
5302
|
case "timeout":
|
|
5181
5303
|
throw new LangfuseAPITimeoutError(
|
|
5182
|
-
"Timeout exceeded when calling GET /api/public/
|
|
5304
|
+
"Timeout exceeded when calling GET /api/public/metrics."
|
|
5183
5305
|
);
|
|
5184
5306
|
case "unknown":
|
|
5185
5307
|
throw new LangfuseAPIError({
|
|
@@ -5188,11 +5310,29 @@ var LlmConnections = class {
|
|
|
5188
5310
|
});
|
|
5189
5311
|
}
|
|
5190
5312
|
}
|
|
5313
|
+
async _getAuthorizationHeader() {
|
|
5314
|
+
const username = await Supplier.get(this._options.username);
|
|
5315
|
+
const password = await Supplier.get(this._options.password);
|
|
5316
|
+
if (username != null && password != null) {
|
|
5317
|
+
return BasicAuth.toAuthorizationHeader({
|
|
5318
|
+
username,
|
|
5319
|
+
password
|
|
5320
|
+
});
|
|
5321
|
+
}
|
|
5322
|
+
return void 0;
|
|
5323
|
+
}
|
|
5324
|
+
};
|
|
5325
|
+
|
|
5326
|
+
// src/api/api/resources/legacy/resources/observationsV1/client/Client.ts
|
|
5327
|
+
var ObservationsV1 = class {
|
|
5328
|
+
constructor(_options) {
|
|
5329
|
+
this._options = _options;
|
|
5330
|
+
}
|
|
5191
5331
|
/**
|
|
5192
|
-
*
|
|
5332
|
+
* Get a observation
|
|
5193
5333
|
*
|
|
5194
|
-
* @param {
|
|
5195
|
-
* @param {
|
|
5334
|
+
* @param {string} observationId - The unique langfuse identifier of an observation, can be an event, span or generation
|
|
5335
|
+
* @param {ObservationsV1.RequestOptions} requestOptions - Request-specific configuration.
|
|
5196
5336
|
*
|
|
5197
5337
|
* @throws {@link LangfuseAPI.Error}
|
|
5198
5338
|
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
@@ -5201,23 +5341,14 @@ var LlmConnections = class {
|
|
|
5201
5341
|
* @throws {@link LangfuseAPI.NotFoundError}
|
|
5202
5342
|
*
|
|
5203
5343
|
* @example
|
|
5204
|
-
* await client.
|
|
5205
|
-
* provider: "provider",
|
|
5206
|
-
* adapter: "anthropic",
|
|
5207
|
-
* secretKey: "secretKey",
|
|
5208
|
-
* baseURL: undefined,
|
|
5209
|
-
* customModels: undefined,
|
|
5210
|
-
* withDefaultModels: undefined,
|
|
5211
|
-
* extraHeaders: undefined,
|
|
5212
|
-
* config: undefined
|
|
5213
|
-
* })
|
|
5344
|
+
* await client.legacy.observationsV1.get("observationId")
|
|
5214
5345
|
*/
|
|
5215
|
-
|
|
5346
|
+
get(observationId, requestOptions) {
|
|
5216
5347
|
return HttpResponsePromise.fromPromise(
|
|
5217
|
-
this.
|
|
5348
|
+
this.__get(observationId, requestOptions)
|
|
5218
5349
|
);
|
|
5219
5350
|
}
|
|
5220
|
-
async
|
|
5351
|
+
async __get(observationId, requestOptions) {
|
|
5221
5352
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
5222
5353
|
let _headers = mergeHeaders(
|
|
5223
5354
|
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
@@ -5232,14 +5363,11 @@ var LlmConnections = class {
|
|
|
5232
5363
|
const _response = await fetcher({
|
|
5233
5364
|
url: url_exports.join(
|
|
5234
5365
|
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
5235
|
-
|
|
5366
|
+
`/api/public/observations/${encodeURIComponent(observationId)}`
|
|
5236
5367
|
),
|
|
5237
|
-
method: "
|
|
5368
|
+
method: "GET",
|
|
5238
5369
|
headers: _headers,
|
|
5239
|
-
contentType: "application/json",
|
|
5240
5370
|
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
5241
|
-
requestType: "json",
|
|
5242
|
-
body: request,
|
|
5243
5371
|
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
5244
5372
|
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
5245
5373
|
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
@@ -5294,7 +5422,7 @@ var LlmConnections = class {
|
|
|
5294
5422
|
});
|
|
5295
5423
|
case "timeout":
|
|
5296
5424
|
throw new LangfuseAPITimeoutError(
|
|
5297
|
-
"Timeout exceeded when calling
|
|
5425
|
+
"Timeout exceeded when calling GET /api/public/observations/{observationId}."
|
|
5298
5426
|
);
|
|
5299
5427
|
case "unknown":
|
|
5300
5428
|
throw new LangfuseAPIError({
|
|
@@ -5303,29 +5431,13 @@ var LlmConnections = class {
|
|
|
5303
5431
|
});
|
|
5304
5432
|
}
|
|
5305
5433
|
}
|
|
5306
|
-
async _getAuthorizationHeader() {
|
|
5307
|
-
const username = await Supplier.get(this._options.username);
|
|
5308
|
-
const password = await Supplier.get(this._options.password);
|
|
5309
|
-
if (username != null && password != null) {
|
|
5310
|
-
return BasicAuth.toAuthorizationHeader({
|
|
5311
|
-
username,
|
|
5312
|
-
password
|
|
5313
|
-
});
|
|
5314
|
-
}
|
|
5315
|
-
return void 0;
|
|
5316
|
-
}
|
|
5317
|
-
};
|
|
5318
|
-
|
|
5319
|
-
// src/api/api/resources/media/client/Client.ts
|
|
5320
|
-
var Media = class {
|
|
5321
|
-
constructor(_options) {
|
|
5322
|
-
this._options = _options;
|
|
5323
|
-
}
|
|
5324
5434
|
/**
|
|
5325
|
-
* Get a
|
|
5435
|
+
* Get a list of observations.
|
|
5326
5436
|
*
|
|
5327
|
-
*
|
|
5328
|
-
*
|
|
5437
|
+
* Consider using the [v2 observations endpoint](/api-reference#tag/observationsv2/GET/api/public/v2/observations) for cursor-based pagination and field selection.
|
|
5438
|
+
*
|
|
5439
|
+
* @param {LangfuseAPI.legacy.GetObservationsRequest} request
|
|
5440
|
+
* @param {ObservationsV1.RequestOptions} requestOptions - Request-specific configuration.
|
|
5329
5441
|
*
|
|
5330
5442
|
* @throws {@link LangfuseAPI.Error}
|
|
5331
5443
|
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
@@ -5334,55 +5446,114 @@ var Media = class {
|
|
|
5334
5446
|
* @throws {@link LangfuseAPI.NotFoundError}
|
|
5335
5447
|
*
|
|
5336
5448
|
* @example
|
|
5337
|
-
* await client.
|
|
5449
|
+
* await client.legacy.observationsV1.getMany()
|
|
5338
5450
|
*/
|
|
5339
|
-
|
|
5451
|
+
getMany(request = {}, requestOptions) {
|
|
5340
5452
|
return HttpResponsePromise.fromPromise(
|
|
5341
|
-
this.
|
|
5453
|
+
this.__getMany(request, requestOptions)
|
|
5342
5454
|
);
|
|
5343
5455
|
}
|
|
5344
|
-
async
|
|
5456
|
+
async __getMany(request = {}, requestOptions) {
|
|
5345
5457
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
}
|
|
5368
|
-
if (
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
}
|
|
5374
|
-
if (
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5458
|
+
const {
|
|
5459
|
+
page,
|
|
5460
|
+
limit,
|
|
5461
|
+
name,
|
|
5462
|
+
userId,
|
|
5463
|
+
type: type_,
|
|
5464
|
+
traceId,
|
|
5465
|
+
level,
|
|
5466
|
+
parentObservationId,
|
|
5467
|
+
environment,
|
|
5468
|
+
fromStartTime,
|
|
5469
|
+
toStartTime,
|
|
5470
|
+
version,
|
|
5471
|
+
filter
|
|
5472
|
+
} = request;
|
|
5473
|
+
const _queryParams = {};
|
|
5474
|
+
if (page != null) {
|
|
5475
|
+
_queryParams["page"] = page.toString();
|
|
5476
|
+
}
|
|
5477
|
+
if (limit != null) {
|
|
5478
|
+
_queryParams["limit"] = limit.toString();
|
|
5479
|
+
}
|
|
5480
|
+
if (name != null) {
|
|
5481
|
+
_queryParams["name"] = name;
|
|
5482
|
+
}
|
|
5483
|
+
if (userId != null) {
|
|
5484
|
+
_queryParams["userId"] = userId;
|
|
5485
|
+
}
|
|
5486
|
+
if (type_ != null) {
|
|
5487
|
+
_queryParams["type"] = type_;
|
|
5488
|
+
}
|
|
5489
|
+
if (traceId != null) {
|
|
5490
|
+
_queryParams["traceId"] = traceId;
|
|
5491
|
+
}
|
|
5492
|
+
if (level != null) {
|
|
5493
|
+
_queryParams["level"] = level;
|
|
5494
|
+
}
|
|
5495
|
+
if (parentObservationId != null) {
|
|
5496
|
+
_queryParams["parentObservationId"] = parentObservationId;
|
|
5497
|
+
}
|
|
5498
|
+
if (environment != null) {
|
|
5499
|
+
if (Array.isArray(environment)) {
|
|
5500
|
+
_queryParams["environment"] = environment.map((item) => item);
|
|
5501
|
+
} else {
|
|
5502
|
+
_queryParams["environment"] = environment;
|
|
5503
|
+
}
|
|
5504
|
+
}
|
|
5505
|
+
if (fromStartTime != null) {
|
|
5506
|
+
_queryParams["fromStartTime"] = fromStartTime;
|
|
5507
|
+
}
|
|
5508
|
+
if (toStartTime != null) {
|
|
5509
|
+
_queryParams["toStartTime"] = toStartTime;
|
|
5510
|
+
}
|
|
5511
|
+
if (version != null) {
|
|
5512
|
+
_queryParams["version"] = version;
|
|
5513
|
+
}
|
|
5514
|
+
if (filter != null) {
|
|
5515
|
+
_queryParams["filter"] = filter;
|
|
5516
|
+
}
|
|
5517
|
+
let _headers = mergeHeaders(
|
|
5518
|
+
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
5519
|
+
mergeOnlyDefinedHeaders({
|
|
5520
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
5521
|
+
"X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
|
|
5522
|
+
"X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
|
|
5523
|
+
"X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
|
|
5524
|
+
}),
|
|
5525
|
+
requestOptions == null ? void 0 : requestOptions.headers
|
|
5526
|
+
);
|
|
5527
|
+
const _response = await fetcher({
|
|
5528
|
+
url: url_exports.join(
|
|
5529
|
+
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
5530
|
+
"/api/public/observations"
|
|
5531
|
+
),
|
|
5532
|
+
method: "GET",
|
|
5533
|
+
headers: _headers,
|
|
5534
|
+
queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
|
|
5535
|
+
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
5536
|
+
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
5537
|
+
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
5538
|
+
});
|
|
5539
|
+
if (_response.ok) {
|
|
5540
|
+
return {
|
|
5541
|
+
data: _response.body,
|
|
5542
|
+
rawResponse: _response.rawResponse
|
|
5543
|
+
};
|
|
5544
|
+
}
|
|
5545
|
+
if (_response.error.reason === "status-code") {
|
|
5546
|
+
switch (_response.error.statusCode) {
|
|
5547
|
+
case 400:
|
|
5548
|
+
throw new Error2(
|
|
5549
|
+
_response.error.body,
|
|
5550
|
+
_response.rawResponse
|
|
5551
|
+
);
|
|
5552
|
+
case 401:
|
|
5553
|
+
throw new UnauthorizedError(
|
|
5554
|
+
_response.error.body,
|
|
5555
|
+
_response.rawResponse
|
|
5556
|
+
);
|
|
5386
5557
|
case 403:
|
|
5387
5558
|
throw new AccessDeniedError(
|
|
5388
5559
|
_response.error.body,
|
|
@@ -5415,7 +5586,7 @@ var Media = class {
|
|
|
5415
5586
|
});
|
|
5416
5587
|
case "timeout":
|
|
5417
5588
|
throw new LangfuseAPITimeoutError(
|
|
5418
|
-
"Timeout exceeded when calling GET /api/public/
|
|
5589
|
+
"Timeout exceeded when calling GET /api/public/observations."
|
|
5419
5590
|
);
|
|
5420
5591
|
case "unknown":
|
|
5421
5592
|
throw new LangfuseAPIError({
|
|
@@ -5424,12 +5595,286 @@ var Media = class {
|
|
|
5424
5595
|
});
|
|
5425
5596
|
}
|
|
5426
5597
|
}
|
|
5598
|
+
async _getAuthorizationHeader() {
|
|
5599
|
+
const username = await Supplier.get(this._options.username);
|
|
5600
|
+
const password = await Supplier.get(this._options.password);
|
|
5601
|
+
if (username != null && password != null) {
|
|
5602
|
+
return BasicAuth.toAuthorizationHeader({
|
|
5603
|
+
username,
|
|
5604
|
+
password
|
|
5605
|
+
});
|
|
5606
|
+
}
|
|
5607
|
+
return void 0;
|
|
5608
|
+
}
|
|
5609
|
+
};
|
|
5610
|
+
|
|
5611
|
+
// src/api/api/resources/legacy/resources/scoreV1/client/Client.ts
|
|
5612
|
+
var ScoreV1 = class {
|
|
5613
|
+
constructor(_options) {
|
|
5614
|
+
this._options = _options;
|
|
5615
|
+
}
|
|
5427
5616
|
/**
|
|
5428
|
-
*
|
|
5617
|
+
* Create a score (supports both trace and session scores)
|
|
5429
5618
|
*
|
|
5430
|
-
* @param {
|
|
5431
|
-
* @param {
|
|
5432
|
-
*
|
|
5619
|
+
* @param {LangfuseAPI.legacy.CreateScoreRequest} request
|
|
5620
|
+
* @param {ScoreV1.RequestOptions} requestOptions - Request-specific configuration.
|
|
5621
|
+
*
|
|
5622
|
+
* @throws {@link LangfuseAPI.Error}
|
|
5623
|
+
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
5624
|
+
* @throws {@link LangfuseAPI.AccessDeniedError}
|
|
5625
|
+
* @throws {@link LangfuseAPI.MethodNotAllowedError}
|
|
5626
|
+
* @throws {@link LangfuseAPI.NotFoundError}
|
|
5627
|
+
*
|
|
5628
|
+
* @example
|
|
5629
|
+
* await client.legacy.scoreV1.create({
|
|
5630
|
+
* id: undefined,
|
|
5631
|
+
* traceId: undefined,
|
|
5632
|
+
* sessionId: undefined,
|
|
5633
|
+
* observationId: undefined,
|
|
5634
|
+
* datasetRunId: undefined,
|
|
5635
|
+
* name: "name",
|
|
5636
|
+
* value: 1.1,
|
|
5637
|
+
* comment: undefined,
|
|
5638
|
+
* metadata: undefined,
|
|
5639
|
+
* environment: undefined,
|
|
5640
|
+
* queueId: undefined,
|
|
5641
|
+
* dataType: undefined,
|
|
5642
|
+
* configId: undefined
|
|
5643
|
+
* })
|
|
5644
|
+
*/
|
|
5645
|
+
create(request, requestOptions) {
|
|
5646
|
+
return HttpResponsePromise.fromPromise(
|
|
5647
|
+
this.__create(request, requestOptions)
|
|
5648
|
+
);
|
|
5649
|
+
}
|
|
5650
|
+
async __create(request, requestOptions) {
|
|
5651
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
5652
|
+
let _headers = mergeHeaders(
|
|
5653
|
+
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
5654
|
+
mergeOnlyDefinedHeaders({
|
|
5655
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
5656
|
+
"X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
|
|
5657
|
+
"X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
|
|
5658
|
+
"X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
|
|
5659
|
+
}),
|
|
5660
|
+
requestOptions == null ? void 0 : requestOptions.headers
|
|
5661
|
+
);
|
|
5662
|
+
const _response = await fetcher({
|
|
5663
|
+
url: url_exports.join(
|
|
5664
|
+
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
5665
|
+
"/api/public/scores"
|
|
5666
|
+
),
|
|
5667
|
+
method: "POST",
|
|
5668
|
+
headers: _headers,
|
|
5669
|
+
contentType: "application/json",
|
|
5670
|
+
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
5671
|
+
requestType: "json",
|
|
5672
|
+
body: request,
|
|
5673
|
+
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
5674
|
+
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
5675
|
+
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
5676
|
+
});
|
|
5677
|
+
if (_response.ok) {
|
|
5678
|
+
return {
|
|
5679
|
+
data: _response.body,
|
|
5680
|
+
rawResponse: _response.rawResponse
|
|
5681
|
+
};
|
|
5682
|
+
}
|
|
5683
|
+
if (_response.error.reason === "status-code") {
|
|
5684
|
+
switch (_response.error.statusCode) {
|
|
5685
|
+
case 400:
|
|
5686
|
+
throw new Error2(
|
|
5687
|
+
_response.error.body,
|
|
5688
|
+
_response.rawResponse
|
|
5689
|
+
);
|
|
5690
|
+
case 401:
|
|
5691
|
+
throw new UnauthorizedError(
|
|
5692
|
+
_response.error.body,
|
|
5693
|
+
_response.rawResponse
|
|
5694
|
+
);
|
|
5695
|
+
case 403:
|
|
5696
|
+
throw new AccessDeniedError(
|
|
5697
|
+
_response.error.body,
|
|
5698
|
+
_response.rawResponse
|
|
5699
|
+
);
|
|
5700
|
+
case 405:
|
|
5701
|
+
throw new MethodNotAllowedError(
|
|
5702
|
+
_response.error.body,
|
|
5703
|
+
_response.rawResponse
|
|
5704
|
+
);
|
|
5705
|
+
case 404:
|
|
5706
|
+
throw new NotFoundError(
|
|
5707
|
+
_response.error.body,
|
|
5708
|
+
_response.rawResponse
|
|
5709
|
+
);
|
|
5710
|
+
default:
|
|
5711
|
+
throw new LangfuseAPIError({
|
|
5712
|
+
statusCode: _response.error.statusCode,
|
|
5713
|
+
body: _response.error.body,
|
|
5714
|
+
rawResponse: _response.rawResponse
|
|
5715
|
+
});
|
|
5716
|
+
}
|
|
5717
|
+
}
|
|
5718
|
+
switch (_response.error.reason) {
|
|
5719
|
+
case "non-json":
|
|
5720
|
+
throw new LangfuseAPIError({
|
|
5721
|
+
statusCode: _response.error.statusCode,
|
|
5722
|
+
body: _response.error.rawBody,
|
|
5723
|
+
rawResponse: _response.rawResponse
|
|
5724
|
+
});
|
|
5725
|
+
case "timeout":
|
|
5726
|
+
throw new LangfuseAPITimeoutError(
|
|
5727
|
+
"Timeout exceeded when calling POST /api/public/scores."
|
|
5728
|
+
);
|
|
5729
|
+
case "unknown":
|
|
5730
|
+
throw new LangfuseAPIError({
|
|
5731
|
+
message: _response.error.errorMessage,
|
|
5732
|
+
rawResponse: _response.rawResponse
|
|
5733
|
+
});
|
|
5734
|
+
}
|
|
5735
|
+
}
|
|
5736
|
+
/**
|
|
5737
|
+
* Delete a score (supports both trace and session scores)
|
|
5738
|
+
*
|
|
5739
|
+
* @param {string} scoreId - The unique langfuse identifier of a score
|
|
5740
|
+
* @param {ScoreV1.RequestOptions} requestOptions - Request-specific configuration.
|
|
5741
|
+
*
|
|
5742
|
+
* @throws {@link LangfuseAPI.Error}
|
|
5743
|
+
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
5744
|
+
* @throws {@link LangfuseAPI.AccessDeniedError}
|
|
5745
|
+
* @throws {@link LangfuseAPI.MethodNotAllowedError}
|
|
5746
|
+
* @throws {@link LangfuseAPI.NotFoundError}
|
|
5747
|
+
*
|
|
5748
|
+
* @example
|
|
5749
|
+
* await client.legacy.scoreV1.delete("scoreId")
|
|
5750
|
+
*/
|
|
5751
|
+
delete(scoreId, requestOptions) {
|
|
5752
|
+
return HttpResponsePromise.fromPromise(
|
|
5753
|
+
this.__delete(scoreId, requestOptions)
|
|
5754
|
+
);
|
|
5755
|
+
}
|
|
5756
|
+
async __delete(scoreId, requestOptions) {
|
|
5757
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
5758
|
+
let _headers = mergeHeaders(
|
|
5759
|
+
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
5760
|
+
mergeOnlyDefinedHeaders({
|
|
5761
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
5762
|
+
"X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
|
|
5763
|
+
"X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
|
|
5764
|
+
"X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
|
|
5765
|
+
}),
|
|
5766
|
+
requestOptions == null ? void 0 : requestOptions.headers
|
|
5767
|
+
);
|
|
5768
|
+
const _response = await fetcher({
|
|
5769
|
+
url: url_exports.join(
|
|
5770
|
+
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
5771
|
+
`/api/public/scores/${encodeURIComponent(scoreId)}`
|
|
5772
|
+
),
|
|
5773
|
+
method: "DELETE",
|
|
5774
|
+
headers: _headers,
|
|
5775
|
+
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
5776
|
+
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
5777
|
+
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
5778
|
+
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
5779
|
+
});
|
|
5780
|
+
if (_response.ok) {
|
|
5781
|
+
return { data: void 0, rawResponse: _response.rawResponse };
|
|
5782
|
+
}
|
|
5783
|
+
if (_response.error.reason === "status-code") {
|
|
5784
|
+
switch (_response.error.statusCode) {
|
|
5785
|
+
case 400:
|
|
5786
|
+
throw new Error2(
|
|
5787
|
+
_response.error.body,
|
|
5788
|
+
_response.rawResponse
|
|
5789
|
+
);
|
|
5790
|
+
case 401:
|
|
5791
|
+
throw new UnauthorizedError(
|
|
5792
|
+
_response.error.body,
|
|
5793
|
+
_response.rawResponse
|
|
5794
|
+
);
|
|
5795
|
+
case 403:
|
|
5796
|
+
throw new AccessDeniedError(
|
|
5797
|
+
_response.error.body,
|
|
5798
|
+
_response.rawResponse
|
|
5799
|
+
);
|
|
5800
|
+
case 405:
|
|
5801
|
+
throw new MethodNotAllowedError(
|
|
5802
|
+
_response.error.body,
|
|
5803
|
+
_response.rawResponse
|
|
5804
|
+
);
|
|
5805
|
+
case 404:
|
|
5806
|
+
throw new NotFoundError(
|
|
5807
|
+
_response.error.body,
|
|
5808
|
+
_response.rawResponse
|
|
5809
|
+
);
|
|
5810
|
+
default:
|
|
5811
|
+
throw new LangfuseAPIError({
|
|
5812
|
+
statusCode: _response.error.statusCode,
|
|
5813
|
+
body: _response.error.body,
|
|
5814
|
+
rawResponse: _response.rawResponse
|
|
5815
|
+
});
|
|
5816
|
+
}
|
|
5817
|
+
}
|
|
5818
|
+
switch (_response.error.reason) {
|
|
5819
|
+
case "non-json":
|
|
5820
|
+
throw new LangfuseAPIError({
|
|
5821
|
+
statusCode: _response.error.statusCode,
|
|
5822
|
+
body: _response.error.rawBody,
|
|
5823
|
+
rawResponse: _response.rawResponse
|
|
5824
|
+
});
|
|
5825
|
+
case "timeout":
|
|
5826
|
+
throw new LangfuseAPITimeoutError(
|
|
5827
|
+
"Timeout exceeded when calling DELETE /api/public/scores/{scoreId}."
|
|
5828
|
+
);
|
|
5829
|
+
case "unknown":
|
|
5830
|
+
throw new LangfuseAPIError({
|
|
5831
|
+
message: _response.error.errorMessage,
|
|
5832
|
+
rawResponse: _response.rawResponse
|
|
5833
|
+
});
|
|
5834
|
+
}
|
|
5835
|
+
}
|
|
5836
|
+
async _getAuthorizationHeader() {
|
|
5837
|
+
const username = await Supplier.get(this._options.username);
|
|
5838
|
+
const password = await Supplier.get(this._options.password);
|
|
5839
|
+
if (username != null && password != null) {
|
|
5840
|
+
return BasicAuth.toAuthorizationHeader({
|
|
5841
|
+
username,
|
|
5842
|
+
password
|
|
5843
|
+
});
|
|
5844
|
+
}
|
|
5845
|
+
return void 0;
|
|
5846
|
+
}
|
|
5847
|
+
};
|
|
5848
|
+
|
|
5849
|
+
// src/api/api/resources/legacy/client/Client.ts
|
|
5850
|
+
var Legacy = class {
|
|
5851
|
+
constructor(_options) {
|
|
5852
|
+
this._options = _options;
|
|
5853
|
+
}
|
|
5854
|
+
get metricsV1() {
|
|
5855
|
+
var _a2;
|
|
5856
|
+
return (_a2 = this._metricsV1) != null ? _a2 : this._metricsV1 = new MetricsV1(this._options);
|
|
5857
|
+
}
|
|
5858
|
+
get observationsV1() {
|
|
5859
|
+
var _a2;
|
|
5860
|
+
return (_a2 = this._observationsV1) != null ? _a2 : this._observationsV1 = new ObservationsV1(this._options);
|
|
5861
|
+
}
|
|
5862
|
+
get scoreV1() {
|
|
5863
|
+
var _a2;
|
|
5864
|
+
return (_a2 = this._scoreV1) != null ? _a2 : this._scoreV1 = new ScoreV1(this._options);
|
|
5865
|
+
}
|
|
5866
|
+
};
|
|
5867
|
+
|
|
5868
|
+
// src/api/api/resources/llmConnections/client/Client.ts
|
|
5869
|
+
var LlmConnections = class {
|
|
5870
|
+
constructor(_options) {
|
|
5871
|
+
this._options = _options;
|
|
5872
|
+
}
|
|
5873
|
+
/**
|
|
5874
|
+
* Get all LLM connections in a project
|
|
5875
|
+
*
|
|
5876
|
+
* @param {LangfuseAPI.GetLlmConnectionsRequest} request
|
|
5877
|
+
* @param {LlmConnections.RequestOptions} requestOptions - Request-specific configuration.
|
|
5433
5878
|
*
|
|
5434
5879
|
* @throws {@link LangfuseAPI.Error}
|
|
5435
5880
|
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
@@ -5438,20 +5883,23 @@ var Media = class {
|
|
|
5438
5883
|
* @throws {@link LangfuseAPI.NotFoundError}
|
|
5439
5884
|
*
|
|
5440
5885
|
* @example
|
|
5441
|
-
* await client.
|
|
5442
|
-
* uploadedAt: "2024-01-15T09:30:00Z",
|
|
5443
|
-
* uploadHttpStatus: 1,
|
|
5444
|
-
* uploadHttpError: undefined,
|
|
5445
|
-
* uploadTimeMs: undefined
|
|
5446
|
-
* })
|
|
5886
|
+
* await client.llmConnections.list()
|
|
5447
5887
|
*/
|
|
5448
|
-
|
|
5888
|
+
list(request = {}, requestOptions) {
|
|
5449
5889
|
return HttpResponsePromise.fromPromise(
|
|
5450
|
-
this.
|
|
5890
|
+
this.__list(request, requestOptions)
|
|
5451
5891
|
);
|
|
5452
5892
|
}
|
|
5453
|
-
async
|
|
5893
|
+
async __list(request = {}, requestOptions) {
|
|
5454
5894
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
5895
|
+
const { page, limit } = request;
|
|
5896
|
+
const _queryParams = {};
|
|
5897
|
+
if (page != null) {
|
|
5898
|
+
_queryParams["page"] = page.toString();
|
|
5899
|
+
}
|
|
5900
|
+
if (limit != null) {
|
|
5901
|
+
_queryParams["limit"] = limit.toString();
|
|
5902
|
+
}
|
|
5455
5903
|
let _headers = mergeHeaders(
|
|
5456
5904
|
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
5457
5905
|
mergeOnlyDefinedHeaders({
|
|
@@ -5465,20 +5913,20 @@ var Media = class {
|
|
|
5465
5913
|
const _response = await fetcher({
|
|
5466
5914
|
url: url_exports.join(
|
|
5467
5915
|
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
5468
|
-
|
|
5916
|
+
"/api/public/llm-connections"
|
|
5469
5917
|
),
|
|
5470
|
-
method: "
|
|
5918
|
+
method: "GET",
|
|
5471
5919
|
headers: _headers,
|
|
5472
|
-
|
|
5473
|
-
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
5474
|
-
requestType: "json",
|
|
5475
|
-
body: request,
|
|
5920
|
+
queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
|
|
5476
5921
|
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
5477
5922
|
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
5478
5923
|
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
5479
5924
|
});
|
|
5480
5925
|
if (_response.ok) {
|
|
5481
|
-
return {
|
|
5926
|
+
return {
|
|
5927
|
+
data: _response.body,
|
|
5928
|
+
rawResponse: _response.rawResponse
|
|
5929
|
+
};
|
|
5482
5930
|
}
|
|
5483
5931
|
if (_response.error.reason === "status-code") {
|
|
5484
5932
|
switch (_response.error.statusCode) {
|
|
@@ -5524,7 +5972,7 @@ var Media = class {
|
|
|
5524
5972
|
});
|
|
5525
5973
|
case "timeout":
|
|
5526
5974
|
throw new LangfuseAPITimeoutError(
|
|
5527
|
-
"Timeout exceeded when calling
|
|
5975
|
+
"Timeout exceeded when calling GET /api/public/llm-connections."
|
|
5528
5976
|
);
|
|
5529
5977
|
case "unknown":
|
|
5530
5978
|
throw new LangfuseAPIError({
|
|
@@ -5534,10 +5982,10 @@ var Media = class {
|
|
|
5534
5982
|
}
|
|
5535
5983
|
}
|
|
5536
5984
|
/**
|
|
5537
|
-
*
|
|
5985
|
+
* Create or update an LLM connection. The connection is upserted on provider.
|
|
5538
5986
|
*
|
|
5539
|
-
* @param {LangfuseAPI.
|
|
5540
|
-
* @param {
|
|
5987
|
+
* @param {LangfuseAPI.UpsertLlmConnectionRequest} request
|
|
5988
|
+
* @param {LlmConnections.RequestOptions} requestOptions - Request-specific configuration.
|
|
5541
5989
|
*
|
|
5542
5990
|
* @throws {@link LangfuseAPI.Error}
|
|
5543
5991
|
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
@@ -5546,21 +5994,23 @@ var Media = class {
|
|
|
5546
5994
|
* @throws {@link LangfuseAPI.NotFoundError}
|
|
5547
5995
|
*
|
|
5548
5996
|
* @example
|
|
5549
|
-
* await client.
|
|
5550
|
-
*
|
|
5551
|
-
*
|
|
5552
|
-
*
|
|
5553
|
-
*
|
|
5554
|
-
*
|
|
5555
|
-
*
|
|
5997
|
+
* await client.llmConnections.upsert({
|
|
5998
|
+
* provider: "provider",
|
|
5999
|
+
* adapter: "anthropic",
|
|
6000
|
+
* secretKey: "secretKey",
|
|
6001
|
+
* baseURL: undefined,
|
|
6002
|
+
* customModels: undefined,
|
|
6003
|
+
* withDefaultModels: undefined,
|
|
6004
|
+
* extraHeaders: undefined,
|
|
6005
|
+
* config: undefined
|
|
5556
6006
|
* })
|
|
5557
6007
|
*/
|
|
5558
|
-
|
|
6008
|
+
upsert(request, requestOptions) {
|
|
5559
6009
|
return HttpResponsePromise.fromPromise(
|
|
5560
|
-
this.
|
|
6010
|
+
this.__upsert(request, requestOptions)
|
|
5561
6011
|
);
|
|
5562
6012
|
}
|
|
5563
|
-
async
|
|
6013
|
+
async __upsert(request, requestOptions) {
|
|
5564
6014
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
5565
6015
|
let _headers = mergeHeaders(
|
|
5566
6016
|
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
@@ -5575,9 +6025,9 @@ var Media = class {
|
|
|
5575
6025
|
const _response = await fetcher({
|
|
5576
6026
|
url: url_exports.join(
|
|
5577
6027
|
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
5578
|
-
"/api/public/
|
|
6028
|
+
"/api/public/llm-connections"
|
|
5579
6029
|
),
|
|
5580
|
-
method: "
|
|
6030
|
+
method: "PUT",
|
|
5581
6031
|
headers: _headers,
|
|
5582
6032
|
contentType: "application/json",
|
|
5583
6033
|
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
@@ -5637,7 +6087,7 @@ var Media = class {
|
|
|
5637
6087
|
});
|
|
5638
6088
|
case "timeout":
|
|
5639
6089
|
throw new LangfuseAPITimeoutError(
|
|
5640
|
-
"Timeout exceeded when calling
|
|
6090
|
+
"Timeout exceeded when calling PUT /api/public/llm-connections."
|
|
5641
6091
|
);
|
|
5642
6092
|
case "unknown":
|
|
5643
6093
|
throw new LangfuseAPIError({
|
|
@@ -5659,116 +6109,16 @@ var Media = class {
|
|
|
5659
6109
|
}
|
|
5660
6110
|
};
|
|
5661
6111
|
|
|
5662
|
-
// src/api/api/resources/
|
|
5663
|
-
var
|
|
6112
|
+
// src/api/api/resources/media/client/Client.ts
|
|
6113
|
+
var Media = class {
|
|
5664
6114
|
constructor(_options) {
|
|
5665
6115
|
this._options = _options;
|
|
5666
6116
|
}
|
|
5667
6117
|
/**
|
|
5668
|
-
* Get
|
|
5669
|
-
*
|
|
5670
|
-
* ## V2 Differences
|
|
5671
|
-
* - Supports `observations`, `scores-numeric`, and `scores-categorical` views only (traces view not supported)
|
|
5672
|
-
* - Direct access to tags and release fields on observations
|
|
5673
|
-
* - Backwards-compatible: traceName, traceRelease, traceVersion dimensions are still available on observations view
|
|
5674
|
-
* - High cardinality dimensions are not supported and will return a 400 error (see below)
|
|
5675
|
-
*
|
|
5676
|
-
* For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api).
|
|
5677
|
-
*
|
|
5678
|
-
* ## Available Views
|
|
5679
|
-
*
|
|
5680
|
-
* ### observations
|
|
5681
|
-
* Query observation-level data (spans, generations, events).
|
|
5682
|
-
*
|
|
5683
|
-
* **Dimensions:**
|
|
5684
|
-
* - `environment` - Deployment environment (e.g., production, staging)
|
|
5685
|
-
* - `type` - Type of observation (SPAN, GENERATION, EVENT)
|
|
5686
|
-
* - `name` - Name of the observation
|
|
5687
|
-
* - `level` - Logging level of the observation
|
|
5688
|
-
* - `version` - Version of the observation
|
|
5689
|
-
* - `tags` - User-defined tags
|
|
5690
|
-
* - `release` - Release version
|
|
5691
|
-
* - `traceName` - Name of the parent trace (backwards-compatible)
|
|
5692
|
-
* - `traceRelease` - Release version of the parent trace (backwards-compatible, maps to release)
|
|
5693
|
-
* - `traceVersion` - Version of the parent trace (backwards-compatible, maps to version)
|
|
5694
|
-
* - `providedModelName` - Name of the model used
|
|
5695
|
-
* - `promptName` - Name of the prompt used
|
|
5696
|
-
* - `promptVersion` - Version of the prompt used
|
|
5697
|
-
* - `startTimeMonth` - Month of start_time in YYYY-MM format
|
|
5698
|
-
*
|
|
5699
|
-
* **Measures:**
|
|
5700
|
-
* - `count` - Total number of observations
|
|
5701
|
-
* - `latency` - Observation latency (milliseconds)
|
|
5702
|
-
* - `streamingLatency` - Generation latency from completion start to end (milliseconds)
|
|
5703
|
-
* - `inputTokens` - Sum of input tokens consumed
|
|
5704
|
-
* - `outputTokens` - Sum of output tokens produced
|
|
5705
|
-
* - `totalTokens` - Sum of all tokens consumed
|
|
5706
|
-
* - `outputTokensPerSecond` - Output tokens per second
|
|
5707
|
-
* - `tokensPerSecond` - Total tokens per second
|
|
5708
|
-
* - `inputCost` - Input cost (USD)
|
|
5709
|
-
* - `outputCost` - Output cost (USD)
|
|
5710
|
-
* - `totalCost` - Total cost (USD)
|
|
5711
|
-
* - `timeToFirstToken` - Time to first token (milliseconds)
|
|
5712
|
-
* - `countScores` - Number of scores attached to the observation
|
|
5713
|
-
*
|
|
5714
|
-
* ### scores-numeric
|
|
5715
|
-
* Query numeric and boolean score data.
|
|
5716
|
-
*
|
|
5717
|
-
* **Dimensions:**
|
|
5718
|
-
* - `environment` - Deployment environment
|
|
5719
|
-
* - `name` - Name of the score (e.g., accuracy, toxicity)
|
|
5720
|
-
* - `source` - Origin of the score (API, ANNOTATION, EVAL)
|
|
5721
|
-
* - `dataType` - Data type (NUMERIC, BOOLEAN)
|
|
5722
|
-
* - `configId` - Identifier of the score config
|
|
5723
|
-
* - `timestampMonth` - Month in YYYY-MM format
|
|
5724
|
-
* - `timestampDay` - Day in YYYY-MM-DD format
|
|
5725
|
-
* - `value` - Numeric value of the score
|
|
5726
|
-
* - `traceName` - Name of the parent trace
|
|
5727
|
-
* - `tags` - Tags
|
|
5728
|
-
* - `traceRelease` - Release version
|
|
5729
|
-
* - `traceVersion` - Version
|
|
5730
|
-
* - `observationName` - Name of the associated observation
|
|
5731
|
-
* - `observationModelName` - Model name of the associated observation
|
|
5732
|
-
* - `observationPromptName` - Prompt name of the associated observation
|
|
5733
|
-
* - `observationPromptVersion` - Prompt version of the associated observation
|
|
5734
|
-
*
|
|
5735
|
-
* **Measures:**
|
|
5736
|
-
* - `count` - Total number of scores
|
|
5737
|
-
* - `value` - Score value (for aggregations)
|
|
5738
|
-
*
|
|
5739
|
-
* ### scores-categorical
|
|
5740
|
-
* Query categorical score data. Same dimensions as scores-numeric except uses `stringValue` instead of `value`.
|
|
5741
|
-
*
|
|
5742
|
-
* **Measures:**
|
|
5743
|
-
* - `count` - Total number of scores
|
|
5744
|
-
*
|
|
5745
|
-
* ## High Cardinality Dimensions
|
|
5746
|
-
* The following dimensions cannot be used as grouping dimensions in v2 metrics API as they can cause performance issues.
|
|
5747
|
-
* Use them in filters instead.
|
|
5748
|
-
*
|
|
5749
|
-
* **observations view:**
|
|
5750
|
-
* - `id` - Use traceId filter to narrow down results
|
|
5751
|
-
* - `traceId` - Use traceId filter instead
|
|
5752
|
-
* - `userId` - Use userId filter instead
|
|
5753
|
-
* - `sessionId` - Use sessionId filter instead
|
|
5754
|
-
* - `parentObservationId` - Use parentObservationId filter instead
|
|
5755
|
-
*
|
|
5756
|
-
* **scores-numeric / scores-categorical views:**
|
|
5757
|
-
* - `id` - Use specific filters to narrow down results
|
|
5758
|
-
* - `traceId` - Use traceId filter instead
|
|
5759
|
-
* - `userId` - Use userId filter instead
|
|
5760
|
-
* - `sessionId` - Use sessionId filter instead
|
|
5761
|
-
* - `observationId` - Use observationId filter instead
|
|
5762
|
-
*
|
|
5763
|
-
* ## Aggregations
|
|
5764
|
-
* Available aggregation functions: `sum`, `avg`, `count`, `max`, `min`, `p50`, `p75`, `p90`, `p95`, `p99`, `histogram`
|
|
5765
|
-
*
|
|
5766
|
-
* ## Time Granularities
|
|
5767
|
-
* Available granularities for timeDimension: `auto`, `minute`, `hour`, `day`, `week`, `month`
|
|
5768
|
-
* - `auto` bins the data into approximately 50 buckets based on the time range
|
|
6118
|
+
* Get a media record
|
|
5769
6119
|
*
|
|
5770
|
-
* @param {
|
|
5771
|
-
* @param {
|
|
6120
|
+
* @param {string} mediaId - The unique langfuse identifier of a media record
|
|
6121
|
+
* @param {Media.RequestOptions} requestOptions - Request-specific configuration.
|
|
5772
6122
|
*
|
|
5773
6123
|
* @throws {@link LangfuseAPI.Error}
|
|
5774
6124
|
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
@@ -5777,20 +6127,15 @@ var MetricsV2 = class {
|
|
|
5777
6127
|
* @throws {@link LangfuseAPI.NotFoundError}
|
|
5778
6128
|
*
|
|
5779
6129
|
* @example
|
|
5780
|
-
* await client.
|
|
5781
|
-
* query: "query"
|
|
5782
|
-
* })
|
|
6130
|
+
* await client.media.get("mediaId")
|
|
5783
6131
|
*/
|
|
5784
|
-
|
|
6132
|
+
get(mediaId, requestOptions) {
|
|
5785
6133
|
return HttpResponsePromise.fromPromise(
|
|
5786
|
-
this.
|
|
6134
|
+
this.__get(mediaId, requestOptions)
|
|
5787
6135
|
);
|
|
5788
6136
|
}
|
|
5789
|
-
async
|
|
6137
|
+
async __get(mediaId, requestOptions) {
|
|
5790
6138
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
5791
|
-
const { query } = request;
|
|
5792
|
-
const _queryParams = {};
|
|
5793
|
-
_queryParams["query"] = query;
|
|
5794
6139
|
let _headers = mergeHeaders(
|
|
5795
6140
|
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
5796
6141
|
mergeOnlyDefinedHeaders({
|
|
@@ -5804,11 +6149,11 @@ var MetricsV2 = class {
|
|
|
5804
6149
|
const _response = await fetcher({
|
|
5805
6150
|
url: url_exports.join(
|
|
5806
6151
|
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
5807
|
-
|
|
6152
|
+
`/api/public/media/${encodeURIComponent(mediaId)}`
|
|
5808
6153
|
),
|
|
5809
6154
|
method: "GET",
|
|
5810
6155
|
headers: _headers,
|
|
5811
|
-
queryParameters:
|
|
6156
|
+
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
5812
6157
|
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
5813
6158
|
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
5814
6159
|
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
@@ -5863,7 +6208,7 @@ var MetricsV2 = class {
|
|
|
5863
6208
|
});
|
|
5864
6209
|
case "timeout":
|
|
5865
6210
|
throw new LangfuseAPITimeoutError(
|
|
5866
|
-
"Timeout exceeded when calling GET /api/public/
|
|
6211
|
+
"Timeout exceeded when calling GET /api/public/media/{mediaId}."
|
|
5867
6212
|
);
|
|
5868
6213
|
case "unknown":
|
|
5869
6214
|
throw new LangfuseAPIError({
|
|
@@ -5872,33 +6217,12 @@ var MetricsV2 = class {
|
|
|
5872
6217
|
});
|
|
5873
6218
|
}
|
|
5874
6219
|
}
|
|
5875
|
-
async _getAuthorizationHeader() {
|
|
5876
|
-
const username = await Supplier.get(this._options.username);
|
|
5877
|
-
const password = await Supplier.get(this._options.password);
|
|
5878
|
-
if (username != null && password != null) {
|
|
5879
|
-
return BasicAuth.toAuthorizationHeader({
|
|
5880
|
-
username,
|
|
5881
|
-
password
|
|
5882
|
-
});
|
|
5883
|
-
}
|
|
5884
|
-
return void 0;
|
|
5885
|
-
}
|
|
5886
|
-
};
|
|
5887
|
-
|
|
5888
|
-
// src/api/api/resources/metrics/client/Client.ts
|
|
5889
|
-
var Metrics = class {
|
|
5890
|
-
constructor(_options) {
|
|
5891
|
-
this._options = _options;
|
|
5892
|
-
}
|
|
5893
6220
|
/**
|
|
5894
|
-
*
|
|
5895
|
-
*
|
|
5896
|
-
* Consider using the [v2 metrics endpoint](/api-reference#tag/metricsv2/GET/api/public/v2/metrics) for better performance.
|
|
5897
|
-
*
|
|
5898
|
-
* For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api).
|
|
6221
|
+
* Patch a media record
|
|
5899
6222
|
*
|
|
5900
|
-
* @param {
|
|
5901
|
-
* @param {
|
|
6223
|
+
* @param {string} mediaId - The unique langfuse identifier of a media record
|
|
6224
|
+
* @param {LangfuseAPI.PatchMediaBody} request
|
|
6225
|
+
* @param {Media.RequestOptions} requestOptions - Request-specific configuration.
|
|
5902
6226
|
*
|
|
5903
6227
|
* @throws {@link LangfuseAPI.Error}
|
|
5904
6228
|
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
@@ -5907,20 +6231,20 @@ var Metrics = class {
|
|
|
5907
6231
|
* @throws {@link LangfuseAPI.NotFoundError}
|
|
5908
6232
|
*
|
|
5909
6233
|
* @example
|
|
5910
|
-
* await client.
|
|
5911
|
-
*
|
|
6234
|
+
* await client.media.patch("mediaId", {
|
|
6235
|
+
* uploadedAt: "2024-01-15T09:30:00Z",
|
|
6236
|
+
* uploadHttpStatus: 1,
|
|
6237
|
+
* uploadHttpError: undefined,
|
|
6238
|
+
* uploadTimeMs: undefined
|
|
5912
6239
|
* })
|
|
5913
6240
|
*/
|
|
5914
|
-
|
|
6241
|
+
patch(mediaId, request, requestOptions) {
|
|
5915
6242
|
return HttpResponsePromise.fromPromise(
|
|
5916
|
-
this.
|
|
6243
|
+
this.__patch(mediaId, request, requestOptions)
|
|
5917
6244
|
);
|
|
5918
6245
|
}
|
|
5919
|
-
async
|
|
6246
|
+
async __patch(mediaId, request, requestOptions) {
|
|
5920
6247
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
5921
|
-
const { query } = request;
|
|
5922
|
-
const _queryParams = {};
|
|
5923
|
-
_queryParams["query"] = query;
|
|
5924
6248
|
let _headers = mergeHeaders(
|
|
5925
6249
|
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
5926
6250
|
mergeOnlyDefinedHeaders({
|
|
@@ -5934,20 +6258,20 @@ var Metrics = class {
|
|
|
5934
6258
|
const _response = await fetcher({
|
|
5935
6259
|
url: url_exports.join(
|
|
5936
6260
|
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
5937
|
-
|
|
6261
|
+
`/api/public/media/${encodeURIComponent(mediaId)}`
|
|
5938
6262
|
),
|
|
5939
|
-
method: "
|
|
6263
|
+
method: "PATCH",
|
|
5940
6264
|
headers: _headers,
|
|
5941
|
-
|
|
6265
|
+
contentType: "application/json",
|
|
6266
|
+
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
6267
|
+
requestType: "json",
|
|
6268
|
+
body: request,
|
|
5942
6269
|
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
5943
6270
|
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
5944
6271
|
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
5945
6272
|
});
|
|
5946
6273
|
if (_response.ok) {
|
|
5947
|
-
return {
|
|
5948
|
-
data: _response.body,
|
|
5949
|
-
rawResponse: _response.rawResponse
|
|
5950
|
-
};
|
|
6274
|
+
return { data: void 0, rawResponse: _response.rawResponse };
|
|
5951
6275
|
}
|
|
5952
6276
|
if (_response.error.reason === "status-code") {
|
|
5953
6277
|
switch (_response.error.statusCode) {
|
|
@@ -5993,7 +6317,7 @@ var Metrics = class {
|
|
|
5993
6317
|
});
|
|
5994
6318
|
case "timeout":
|
|
5995
6319
|
throw new LangfuseAPITimeoutError(
|
|
5996
|
-
"Timeout exceeded when calling
|
|
6320
|
+
"Timeout exceeded when calling PATCH /api/public/media/{mediaId}."
|
|
5997
6321
|
);
|
|
5998
6322
|
case "unknown":
|
|
5999
6323
|
throw new LangfuseAPIError({
|
|
@@ -6002,29 +6326,11 @@ var Metrics = class {
|
|
|
6002
6326
|
});
|
|
6003
6327
|
}
|
|
6004
6328
|
}
|
|
6005
|
-
async _getAuthorizationHeader() {
|
|
6006
|
-
const username = await Supplier.get(this._options.username);
|
|
6007
|
-
const password = await Supplier.get(this._options.password);
|
|
6008
|
-
if (username != null && password != null) {
|
|
6009
|
-
return BasicAuth.toAuthorizationHeader({
|
|
6010
|
-
username,
|
|
6011
|
-
password
|
|
6012
|
-
});
|
|
6013
|
-
}
|
|
6014
|
-
return void 0;
|
|
6015
|
-
}
|
|
6016
|
-
};
|
|
6017
|
-
|
|
6018
|
-
// src/api/api/resources/models/client/Client.ts
|
|
6019
|
-
var Models = class {
|
|
6020
|
-
constructor(_options) {
|
|
6021
|
-
this._options = _options;
|
|
6022
|
-
}
|
|
6023
6329
|
/**
|
|
6024
|
-
*
|
|
6330
|
+
* Get a presigned upload URL for a media record
|
|
6025
6331
|
*
|
|
6026
|
-
* @param {LangfuseAPI.
|
|
6027
|
-
* @param {
|
|
6332
|
+
* @param {LangfuseAPI.GetMediaUploadUrlRequest} request
|
|
6333
|
+
* @param {Media.RequestOptions} requestOptions - Request-specific configuration.
|
|
6028
6334
|
*
|
|
6029
6335
|
* @throws {@link LangfuseAPI.Error}
|
|
6030
6336
|
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
@@ -6033,25 +6339,21 @@ var Models = class {
|
|
|
6033
6339
|
* @throws {@link LangfuseAPI.NotFoundError}
|
|
6034
6340
|
*
|
|
6035
6341
|
* @example
|
|
6036
|
-
* await client.
|
|
6037
|
-
*
|
|
6038
|
-
*
|
|
6039
|
-
*
|
|
6040
|
-
*
|
|
6041
|
-
*
|
|
6042
|
-
*
|
|
6043
|
-
* totalPrice: undefined,
|
|
6044
|
-
* pricingTiers: undefined,
|
|
6045
|
-
* tokenizerId: undefined,
|
|
6046
|
-
* tokenizerConfig: undefined
|
|
6342
|
+
* await client.media.getUploadUrl({
|
|
6343
|
+
* traceId: "traceId",
|
|
6344
|
+
* observationId: undefined,
|
|
6345
|
+
* contentType: "image/png",
|
|
6346
|
+
* contentLength: 1,
|
|
6347
|
+
* sha256Hash: "sha256Hash",
|
|
6348
|
+
* field: "field"
|
|
6047
6349
|
* })
|
|
6048
6350
|
*/
|
|
6049
|
-
|
|
6351
|
+
getUploadUrl(request, requestOptions) {
|
|
6050
6352
|
return HttpResponsePromise.fromPromise(
|
|
6051
|
-
this.
|
|
6353
|
+
this.__getUploadUrl(request, requestOptions)
|
|
6052
6354
|
);
|
|
6053
6355
|
}
|
|
6054
|
-
async
|
|
6356
|
+
async __getUploadUrl(request, requestOptions) {
|
|
6055
6357
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
6056
6358
|
let _headers = mergeHeaders(
|
|
6057
6359
|
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
@@ -6066,7 +6368,7 @@ var Models = class {
|
|
|
6066
6368
|
const _response = await fetcher({
|
|
6067
6369
|
url: url_exports.join(
|
|
6068
6370
|
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
6069
|
-
"/api/public/
|
|
6371
|
+
"/api/public/media"
|
|
6070
6372
|
),
|
|
6071
6373
|
method: "POST",
|
|
6072
6374
|
headers: _headers,
|
|
@@ -6128,7 +6430,7 @@ var Models = class {
|
|
|
6128
6430
|
});
|
|
6129
6431
|
case "timeout":
|
|
6130
6432
|
throw new LangfuseAPITimeoutError(
|
|
6131
|
-
"Timeout exceeded when calling POST /api/public/
|
|
6433
|
+
"Timeout exceeded when calling POST /api/public/media."
|
|
6132
6434
|
);
|
|
6133
6435
|
case "unknown":
|
|
6134
6436
|
throw new LangfuseAPIError({
|
|
@@ -6137,11 +6439,129 @@ var Models = class {
|
|
|
6137
6439
|
});
|
|
6138
6440
|
}
|
|
6139
6441
|
}
|
|
6442
|
+
async _getAuthorizationHeader() {
|
|
6443
|
+
const username = await Supplier.get(this._options.username);
|
|
6444
|
+
const password = await Supplier.get(this._options.password);
|
|
6445
|
+
if (username != null && password != null) {
|
|
6446
|
+
return BasicAuth.toAuthorizationHeader({
|
|
6447
|
+
username,
|
|
6448
|
+
password
|
|
6449
|
+
});
|
|
6450
|
+
}
|
|
6451
|
+
return void 0;
|
|
6452
|
+
}
|
|
6453
|
+
};
|
|
6454
|
+
|
|
6455
|
+
// src/api/api/resources/metrics/client/Client.ts
|
|
6456
|
+
var Metrics = class {
|
|
6457
|
+
constructor(_options) {
|
|
6458
|
+
this._options = _options;
|
|
6459
|
+
}
|
|
6140
6460
|
/**
|
|
6141
|
-
* Get
|
|
6461
|
+
* Get metrics from the Langfuse project using a query object. V2 endpoint with optimized performance.
|
|
6142
6462
|
*
|
|
6143
|
-
*
|
|
6144
|
-
*
|
|
6463
|
+
* ## V2 Differences
|
|
6464
|
+
* - Supports `observations`, `scores-numeric`, and `scores-categorical` views only (traces view not supported)
|
|
6465
|
+
* - Direct access to tags and release fields on observations
|
|
6466
|
+
* - Backwards-compatible: traceName, traceRelease, traceVersion dimensions are still available on observations view
|
|
6467
|
+
* - High cardinality dimensions are not supported and will return a 400 error (see below)
|
|
6468
|
+
*
|
|
6469
|
+
* For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api).
|
|
6470
|
+
*
|
|
6471
|
+
* ## Available Views
|
|
6472
|
+
*
|
|
6473
|
+
* ### observations
|
|
6474
|
+
* Query observation-level data (spans, generations, events).
|
|
6475
|
+
*
|
|
6476
|
+
* **Dimensions:**
|
|
6477
|
+
* - `environment` - Deployment environment (e.g., production, staging)
|
|
6478
|
+
* - `type` - Type of observation (SPAN, GENERATION, EVENT)
|
|
6479
|
+
* - `name` - Name of the observation
|
|
6480
|
+
* - `level` - Logging level of the observation
|
|
6481
|
+
* - `version` - Version of the observation
|
|
6482
|
+
* - `tags` - User-defined tags
|
|
6483
|
+
* - `release` - Release version
|
|
6484
|
+
* - `traceName` - Name of the parent trace (backwards-compatible)
|
|
6485
|
+
* - `traceRelease` - Release version of the parent trace (backwards-compatible, maps to release)
|
|
6486
|
+
* - `traceVersion` - Version of the parent trace (backwards-compatible, maps to version)
|
|
6487
|
+
* - `providedModelName` - Name of the model used
|
|
6488
|
+
* - `promptName` - Name of the prompt used
|
|
6489
|
+
* - `promptVersion` - Version of the prompt used
|
|
6490
|
+
* - `startTimeMonth` - Month of start_time in YYYY-MM format
|
|
6491
|
+
*
|
|
6492
|
+
* **Measures:**
|
|
6493
|
+
* - `count` - Total number of observations
|
|
6494
|
+
* - `latency` - Observation latency (milliseconds)
|
|
6495
|
+
* - `streamingLatency` - Generation latency from completion start to end (milliseconds)
|
|
6496
|
+
* - `inputTokens` - Sum of input tokens consumed
|
|
6497
|
+
* - `outputTokens` - Sum of output tokens produced
|
|
6498
|
+
* - `totalTokens` - Sum of all tokens consumed
|
|
6499
|
+
* - `outputTokensPerSecond` - Output tokens per second
|
|
6500
|
+
* - `tokensPerSecond` - Total tokens per second
|
|
6501
|
+
* - `inputCost` - Input cost (USD)
|
|
6502
|
+
* - `outputCost` - Output cost (USD)
|
|
6503
|
+
* - `totalCost` - Total cost (USD)
|
|
6504
|
+
* - `timeToFirstToken` - Time to first token (milliseconds)
|
|
6505
|
+
* - `countScores` - Number of scores attached to the observation
|
|
6506
|
+
*
|
|
6507
|
+
* ### scores-numeric
|
|
6508
|
+
* Query numeric and boolean score data.
|
|
6509
|
+
*
|
|
6510
|
+
* **Dimensions:**
|
|
6511
|
+
* - `environment` - Deployment environment
|
|
6512
|
+
* - `name` - Name of the score (e.g., accuracy, toxicity)
|
|
6513
|
+
* - `source` - Origin of the score (API, ANNOTATION, EVAL)
|
|
6514
|
+
* - `dataType` - Data type (NUMERIC, BOOLEAN)
|
|
6515
|
+
* - `configId` - Identifier of the score config
|
|
6516
|
+
* - `timestampMonth` - Month in YYYY-MM format
|
|
6517
|
+
* - `timestampDay` - Day in YYYY-MM-DD format
|
|
6518
|
+
* - `value` - Numeric value of the score
|
|
6519
|
+
* - `traceName` - Name of the parent trace
|
|
6520
|
+
* - `tags` - Tags
|
|
6521
|
+
* - `traceRelease` - Release version
|
|
6522
|
+
* - `traceVersion` - Version
|
|
6523
|
+
* - `observationName` - Name of the associated observation
|
|
6524
|
+
* - `observationModelName` - Model name of the associated observation
|
|
6525
|
+
* - `observationPromptName` - Prompt name of the associated observation
|
|
6526
|
+
* - `observationPromptVersion` - Prompt version of the associated observation
|
|
6527
|
+
*
|
|
6528
|
+
* **Measures:**
|
|
6529
|
+
* - `count` - Total number of scores
|
|
6530
|
+
* - `value` - Score value (for aggregations)
|
|
6531
|
+
*
|
|
6532
|
+
* ### scores-categorical
|
|
6533
|
+
* Query categorical score data. Same dimensions as scores-numeric except uses `stringValue` instead of `value`.
|
|
6534
|
+
*
|
|
6535
|
+
* **Measures:**
|
|
6536
|
+
* - `count` - Total number of scores
|
|
6537
|
+
*
|
|
6538
|
+
* ## High Cardinality Dimensions
|
|
6539
|
+
* The following dimensions cannot be used as grouping dimensions in v2 metrics API as they can cause performance issues.
|
|
6540
|
+
* Use them in filters instead.
|
|
6541
|
+
*
|
|
6542
|
+
* **observations view:**
|
|
6543
|
+
* - `id` - Use traceId filter to narrow down results
|
|
6544
|
+
* - `traceId` - Use traceId filter instead
|
|
6545
|
+
* - `userId` - Use userId filter instead
|
|
6546
|
+
* - `sessionId` - Use sessionId filter instead
|
|
6547
|
+
* - `parentObservationId` - Use parentObservationId filter instead
|
|
6548
|
+
*
|
|
6549
|
+
* **scores-numeric / scores-categorical views:**
|
|
6550
|
+
* - `id` - Use specific filters to narrow down results
|
|
6551
|
+
* - `traceId` - Use traceId filter instead
|
|
6552
|
+
* - `userId` - Use userId filter instead
|
|
6553
|
+
* - `sessionId` - Use sessionId filter instead
|
|
6554
|
+
* - `observationId` - Use observationId filter instead
|
|
6555
|
+
*
|
|
6556
|
+
* ## Aggregations
|
|
6557
|
+
* Available aggregation functions: `sum`, `avg`, `count`, `max`, `min`, `p50`, `p75`, `p90`, `p95`, `p99`, `histogram`
|
|
6558
|
+
*
|
|
6559
|
+
* ## Time Granularities
|
|
6560
|
+
* Available granularities for timeDimension: `auto`, `minute`, `hour`, `day`, `week`, `month`
|
|
6561
|
+
* - `auto` bins the data into approximately 50 buckets based on the time range
|
|
6562
|
+
*
|
|
6563
|
+
* @param {LangfuseAPI.GetMetricsV2Request} request
|
|
6564
|
+
* @param {Metrics.RequestOptions} requestOptions - Request-specific configuration.
|
|
6145
6565
|
*
|
|
6146
6566
|
* @throws {@link LangfuseAPI.Error}
|
|
6147
6567
|
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
@@ -6150,23 +6570,20 @@ var Models = class {
|
|
|
6150
6570
|
* @throws {@link LangfuseAPI.NotFoundError}
|
|
6151
6571
|
*
|
|
6152
6572
|
* @example
|
|
6153
|
-
* await client.
|
|
6573
|
+
* await client.metrics.metrics({
|
|
6574
|
+
* query: "query"
|
|
6575
|
+
* })
|
|
6154
6576
|
*/
|
|
6155
|
-
|
|
6577
|
+
metrics(request, requestOptions) {
|
|
6156
6578
|
return HttpResponsePromise.fromPromise(
|
|
6157
|
-
this.
|
|
6579
|
+
this.__metrics(request, requestOptions)
|
|
6158
6580
|
);
|
|
6159
6581
|
}
|
|
6160
|
-
async
|
|
6582
|
+
async __metrics(request, requestOptions) {
|
|
6161
6583
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
6162
|
-
const {
|
|
6584
|
+
const { query } = request;
|
|
6163
6585
|
const _queryParams = {};
|
|
6164
|
-
|
|
6165
|
-
_queryParams["page"] = page.toString();
|
|
6166
|
-
}
|
|
6167
|
-
if (limit != null) {
|
|
6168
|
-
_queryParams["limit"] = limit.toString();
|
|
6169
|
-
}
|
|
6586
|
+
_queryParams["query"] = query;
|
|
6170
6587
|
let _headers = mergeHeaders(
|
|
6171
6588
|
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
6172
6589
|
mergeOnlyDefinedHeaders({
|
|
@@ -6180,7 +6597,7 @@ var Models = class {
|
|
|
6180
6597
|
const _response = await fetcher({
|
|
6181
6598
|
url: url_exports.join(
|
|
6182
6599
|
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
6183
|
-
"/api/public/
|
|
6600
|
+
"/api/public/v2/metrics"
|
|
6184
6601
|
),
|
|
6185
6602
|
method: "GET",
|
|
6186
6603
|
headers: _headers,
|
|
@@ -6239,7 +6656,7 @@ var Models = class {
|
|
|
6239
6656
|
});
|
|
6240
6657
|
case "timeout":
|
|
6241
6658
|
throw new LangfuseAPITimeoutError(
|
|
6242
|
-
"Timeout exceeded when calling GET /api/public/
|
|
6659
|
+
"Timeout exceeded when calling GET /api/public/v2/metrics."
|
|
6243
6660
|
);
|
|
6244
6661
|
case "unknown":
|
|
6245
6662
|
throw new LangfuseAPIError({
|
|
@@ -6248,10 +6665,28 @@ var Models = class {
|
|
|
6248
6665
|
});
|
|
6249
6666
|
}
|
|
6250
6667
|
}
|
|
6668
|
+
async _getAuthorizationHeader() {
|
|
6669
|
+
const username = await Supplier.get(this._options.username);
|
|
6670
|
+
const password = await Supplier.get(this._options.password);
|
|
6671
|
+
if (username != null && password != null) {
|
|
6672
|
+
return BasicAuth.toAuthorizationHeader({
|
|
6673
|
+
username,
|
|
6674
|
+
password
|
|
6675
|
+
});
|
|
6676
|
+
}
|
|
6677
|
+
return void 0;
|
|
6678
|
+
}
|
|
6679
|
+
};
|
|
6680
|
+
|
|
6681
|
+
// src/api/api/resources/models/client/Client.ts
|
|
6682
|
+
var Models = class {
|
|
6683
|
+
constructor(_options) {
|
|
6684
|
+
this._options = _options;
|
|
6685
|
+
}
|
|
6251
6686
|
/**
|
|
6252
|
-
*
|
|
6687
|
+
* Create a model
|
|
6253
6688
|
*
|
|
6254
|
-
* @param {
|
|
6689
|
+
* @param {LangfuseAPI.CreateModelRequest} request
|
|
6255
6690
|
* @param {Models.RequestOptions} requestOptions - Request-specific configuration.
|
|
6256
6691
|
*
|
|
6257
6692
|
* @throws {@link LangfuseAPI.Error}
|
|
@@ -6261,12 +6696,25 @@ var Models = class {
|
|
|
6261
6696
|
* @throws {@link LangfuseAPI.NotFoundError}
|
|
6262
6697
|
*
|
|
6263
6698
|
* @example
|
|
6264
|
-
* await client.models.
|
|
6699
|
+
* await client.models.create({
|
|
6700
|
+
* modelName: "modelName",
|
|
6701
|
+
* matchPattern: "matchPattern",
|
|
6702
|
+
* startDate: undefined,
|
|
6703
|
+
* unit: undefined,
|
|
6704
|
+
* inputPrice: undefined,
|
|
6705
|
+
* outputPrice: undefined,
|
|
6706
|
+
* totalPrice: undefined,
|
|
6707
|
+
* pricingTiers: undefined,
|
|
6708
|
+
* tokenizerId: undefined,
|
|
6709
|
+
* tokenizerConfig: undefined
|
|
6710
|
+
* })
|
|
6265
6711
|
*/
|
|
6266
|
-
|
|
6267
|
-
return HttpResponsePromise.fromPromise(
|
|
6712
|
+
create(request, requestOptions) {
|
|
6713
|
+
return HttpResponsePromise.fromPromise(
|
|
6714
|
+
this.__create(request, requestOptions)
|
|
6715
|
+
);
|
|
6268
6716
|
}
|
|
6269
|
-
async
|
|
6717
|
+
async __create(request, requestOptions) {
|
|
6270
6718
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
6271
6719
|
let _headers = mergeHeaders(
|
|
6272
6720
|
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
@@ -6281,11 +6729,14 @@ var Models = class {
|
|
|
6281
6729
|
const _response = await fetcher({
|
|
6282
6730
|
url: url_exports.join(
|
|
6283
6731
|
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
6284
|
-
|
|
6732
|
+
"/api/public/models"
|
|
6285
6733
|
),
|
|
6286
|
-
method: "
|
|
6734
|
+
method: "POST",
|
|
6287
6735
|
headers: _headers,
|
|
6736
|
+
contentType: "application/json",
|
|
6288
6737
|
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
6738
|
+
requestType: "json",
|
|
6739
|
+
body: request,
|
|
6289
6740
|
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
6290
6741
|
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
6291
6742
|
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
@@ -6340,7 +6791,7 @@ var Models = class {
|
|
|
6340
6791
|
});
|
|
6341
6792
|
case "timeout":
|
|
6342
6793
|
throw new LangfuseAPITimeoutError(
|
|
6343
|
-
"Timeout exceeded when calling
|
|
6794
|
+
"Timeout exceeded when calling POST /api/public/models."
|
|
6344
6795
|
);
|
|
6345
6796
|
case "unknown":
|
|
6346
6797
|
throw new LangfuseAPIError({
|
|
@@ -6350,9 +6801,9 @@ var Models = class {
|
|
|
6350
6801
|
}
|
|
6351
6802
|
}
|
|
6352
6803
|
/**
|
|
6353
|
-
*
|
|
6804
|
+
* Get all models
|
|
6354
6805
|
*
|
|
6355
|
-
* @param {
|
|
6806
|
+
* @param {LangfuseAPI.GetModelsRequest} request
|
|
6356
6807
|
* @param {Models.RequestOptions} requestOptions - Request-specific configuration.
|
|
6357
6808
|
*
|
|
6358
6809
|
* @throws {@link LangfuseAPI.Error}
|
|
@@ -6362,15 +6813,23 @@ var Models = class {
|
|
|
6362
6813
|
* @throws {@link LangfuseAPI.NotFoundError}
|
|
6363
6814
|
*
|
|
6364
6815
|
* @example
|
|
6365
|
-
* await client.models.
|
|
6816
|
+
* await client.models.list()
|
|
6366
6817
|
*/
|
|
6367
|
-
|
|
6818
|
+
list(request = {}, requestOptions) {
|
|
6368
6819
|
return HttpResponsePromise.fromPromise(
|
|
6369
|
-
this.
|
|
6820
|
+
this.__list(request, requestOptions)
|
|
6370
6821
|
);
|
|
6371
6822
|
}
|
|
6372
|
-
async
|
|
6823
|
+
async __list(request = {}, requestOptions) {
|
|
6373
6824
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
6825
|
+
const { page, limit } = request;
|
|
6826
|
+
const _queryParams = {};
|
|
6827
|
+
if (page != null) {
|
|
6828
|
+
_queryParams["page"] = page.toString();
|
|
6829
|
+
}
|
|
6830
|
+
if (limit != null) {
|
|
6831
|
+
_queryParams["limit"] = limit.toString();
|
|
6832
|
+
}
|
|
6374
6833
|
let _headers = mergeHeaders(
|
|
6375
6834
|
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
6376
6835
|
mergeOnlyDefinedHeaders({
|
|
@@ -6384,17 +6843,20 @@ var Models = class {
|
|
|
6384
6843
|
const _response = await fetcher({
|
|
6385
6844
|
url: url_exports.join(
|
|
6386
6845
|
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
6387
|
-
|
|
6846
|
+
"/api/public/models"
|
|
6388
6847
|
),
|
|
6389
|
-
method: "
|
|
6848
|
+
method: "GET",
|
|
6390
6849
|
headers: _headers,
|
|
6391
|
-
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
6850
|
+
queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
|
|
6392
6851
|
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
6393
6852
|
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
6394
6853
|
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
6395
6854
|
});
|
|
6396
6855
|
if (_response.ok) {
|
|
6397
|
-
return {
|
|
6856
|
+
return {
|
|
6857
|
+
data: _response.body,
|
|
6858
|
+
rawResponse: _response.rawResponse
|
|
6859
|
+
};
|
|
6398
6860
|
}
|
|
6399
6861
|
if (_response.error.reason === "status-code") {
|
|
6400
6862
|
switch (_response.error.statusCode) {
|
|
@@ -6440,7 +6902,7 @@ var Models = class {
|
|
|
6440
6902
|
});
|
|
6441
6903
|
case "timeout":
|
|
6442
6904
|
throw new LangfuseAPITimeoutError(
|
|
6443
|
-
"Timeout exceeded when calling
|
|
6905
|
+
"Timeout exceeded when calling GET /api/public/models."
|
|
6444
6906
|
);
|
|
6445
6907
|
case "unknown":
|
|
6446
6908
|
throw new LangfuseAPIError({
|
|
@@ -6449,52 +6911,11 @@ var Models = class {
|
|
|
6449
6911
|
});
|
|
6450
6912
|
}
|
|
6451
6913
|
}
|
|
6452
|
-
async _getAuthorizationHeader() {
|
|
6453
|
-
const username = await Supplier.get(this._options.username);
|
|
6454
|
-
const password = await Supplier.get(this._options.password);
|
|
6455
|
-
if (username != null && password != null) {
|
|
6456
|
-
return BasicAuth.toAuthorizationHeader({
|
|
6457
|
-
username,
|
|
6458
|
-
password
|
|
6459
|
-
});
|
|
6460
|
-
}
|
|
6461
|
-
return void 0;
|
|
6462
|
-
}
|
|
6463
|
-
};
|
|
6464
|
-
|
|
6465
|
-
// src/api/api/resources/observationsV2/client/Client.ts
|
|
6466
|
-
var ObservationsV2 = class {
|
|
6467
|
-
constructor(_options) {
|
|
6468
|
-
this._options = _options;
|
|
6469
|
-
}
|
|
6470
6914
|
/**
|
|
6471
|
-
* Get a
|
|
6472
|
-
*
|
|
6473
|
-
* ## Cursor-based Pagination
|
|
6474
|
-
* This endpoint uses cursor-based pagination for efficient traversal of large datasets.
|
|
6475
|
-
* The cursor is returned in the response metadata and should be passed in subsequent requests
|
|
6476
|
-
* to retrieve the next page of results.
|
|
6477
|
-
*
|
|
6478
|
-
* ## Field Selection
|
|
6479
|
-
* Use the `fields` parameter to control which observation fields are returned:
|
|
6480
|
-
* - `core` - Always included: id, traceId, startTime, endTime, projectId, parentObservationId, type
|
|
6481
|
-
* - `basic` - name, level, statusMessage, version, environment, bookmarked, public, userId, sessionId
|
|
6482
|
-
* - `time` - completionStartTime, createdAt, updatedAt
|
|
6483
|
-
* - `io` - input, output
|
|
6484
|
-
* - `metadata` - metadata (truncated to 200 chars by default, use `expandMetadata` to get full values)
|
|
6485
|
-
* - `model` - providedModelName, internalModelId, modelParameters
|
|
6486
|
-
* - `usage` - usageDetails, costDetails, totalCost
|
|
6487
|
-
* - `prompt` - promptId, promptName, promptVersion
|
|
6488
|
-
* - `metrics` - latency, timeToFirstToken
|
|
6489
|
-
*
|
|
6490
|
-
* If not specified, `core` and `basic` field groups are returned.
|
|
6491
|
-
*
|
|
6492
|
-
* ## Filters
|
|
6493
|
-
* Multiple filtering options are available via query parameters or the structured `filter` parameter.
|
|
6494
|
-
* When using the `filter` parameter, it takes precedence over individual query parameter filters.
|
|
6915
|
+
* Get a model
|
|
6495
6916
|
*
|
|
6496
|
-
* @param {
|
|
6497
|
-
* @param {
|
|
6917
|
+
* @param {string} id
|
|
6918
|
+
* @param {Models.RequestOptions} requestOptions - Request-specific configuration.
|
|
6498
6919
|
*
|
|
6499
6920
|
* @throws {@link LangfuseAPI.Error}
|
|
6500
6921
|
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
@@ -6503,86 +6924,13 @@ var ObservationsV2 = class {
|
|
|
6503
6924
|
* @throws {@link LangfuseAPI.NotFoundError}
|
|
6504
6925
|
*
|
|
6505
6926
|
* @example
|
|
6506
|
-
* await client.
|
|
6927
|
+
* await client.models.get("id")
|
|
6507
6928
|
*/
|
|
6508
|
-
|
|
6509
|
-
return HttpResponsePromise.fromPromise(
|
|
6510
|
-
this.__getMany(request, requestOptions)
|
|
6511
|
-
);
|
|
6929
|
+
get(id, requestOptions) {
|
|
6930
|
+
return HttpResponsePromise.fromPromise(this.__get(id, requestOptions));
|
|
6512
6931
|
}
|
|
6513
|
-
async
|
|
6932
|
+
async __get(id, requestOptions) {
|
|
6514
6933
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
6515
|
-
const {
|
|
6516
|
-
fields,
|
|
6517
|
-
expandMetadata,
|
|
6518
|
-
limit,
|
|
6519
|
-
cursor,
|
|
6520
|
-
parseIoAsJson,
|
|
6521
|
-
name,
|
|
6522
|
-
userId,
|
|
6523
|
-
type: type_,
|
|
6524
|
-
traceId,
|
|
6525
|
-
level,
|
|
6526
|
-
parentObservationId,
|
|
6527
|
-
environment,
|
|
6528
|
-
fromStartTime,
|
|
6529
|
-
toStartTime,
|
|
6530
|
-
version,
|
|
6531
|
-
filter
|
|
6532
|
-
} = request;
|
|
6533
|
-
const _queryParams = {};
|
|
6534
|
-
if (fields != null) {
|
|
6535
|
-
_queryParams["fields"] = fields;
|
|
6536
|
-
}
|
|
6537
|
-
if (expandMetadata != null) {
|
|
6538
|
-
_queryParams["expandMetadata"] = expandMetadata;
|
|
6539
|
-
}
|
|
6540
|
-
if (limit != null) {
|
|
6541
|
-
_queryParams["limit"] = limit.toString();
|
|
6542
|
-
}
|
|
6543
|
-
if (cursor != null) {
|
|
6544
|
-
_queryParams["cursor"] = cursor;
|
|
6545
|
-
}
|
|
6546
|
-
if (parseIoAsJson != null) {
|
|
6547
|
-
_queryParams["parseIoAsJson"] = parseIoAsJson.toString();
|
|
6548
|
-
}
|
|
6549
|
-
if (name != null) {
|
|
6550
|
-
_queryParams["name"] = name;
|
|
6551
|
-
}
|
|
6552
|
-
if (userId != null) {
|
|
6553
|
-
_queryParams["userId"] = userId;
|
|
6554
|
-
}
|
|
6555
|
-
if (type_ != null) {
|
|
6556
|
-
_queryParams["type"] = type_;
|
|
6557
|
-
}
|
|
6558
|
-
if (traceId != null) {
|
|
6559
|
-
_queryParams["traceId"] = traceId;
|
|
6560
|
-
}
|
|
6561
|
-
if (level != null) {
|
|
6562
|
-
_queryParams["level"] = level;
|
|
6563
|
-
}
|
|
6564
|
-
if (parentObservationId != null) {
|
|
6565
|
-
_queryParams["parentObservationId"] = parentObservationId;
|
|
6566
|
-
}
|
|
6567
|
-
if (environment != null) {
|
|
6568
|
-
if (Array.isArray(environment)) {
|
|
6569
|
-
_queryParams["environment"] = environment.map((item) => item);
|
|
6570
|
-
} else {
|
|
6571
|
-
_queryParams["environment"] = environment;
|
|
6572
|
-
}
|
|
6573
|
-
}
|
|
6574
|
-
if (fromStartTime != null) {
|
|
6575
|
-
_queryParams["fromStartTime"] = fromStartTime;
|
|
6576
|
-
}
|
|
6577
|
-
if (toStartTime != null) {
|
|
6578
|
-
_queryParams["toStartTime"] = toStartTime;
|
|
6579
|
-
}
|
|
6580
|
-
if (version != null) {
|
|
6581
|
-
_queryParams["version"] = version;
|
|
6582
|
-
}
|
|
6583
|
-
if (filter != null) {
|
|
6584
|
-
_queryParams["filter"] = filter;
|
|
6585
|
-
}
|
|
6586
6934
|
let _headers = mergeHeaders(
|
|
6587
6935
|
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
6588
6936
|
mergeOnlyDefinedHeaders({
|
|
@@ -6596,11 +6944,11 @@ var ObservationsV2 = class {
|
|
|
6596
6944
|
const _response = await fetcher({
|
|
6597
6945
|
url: url_exports.join(
|
|
6598
6946
|
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
6599
|
-
|
|
6947
|
+
`/api/public/models/${encodeURIComponent(id)}`
|
|
6600
6948
|
),
|
|
6601
6949
|
method: "GET",
|
|
6602
6950
|
headers: _headers,
|
|
6603
|
-
queryParameters:
|
|
6951
|
+
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
6604
6952
|
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
6605
6953
|
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
6606
6954
|
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
@@ -6655,7 +7003,7 @@ var ObservationsV2 = class {
|
|
|
6655
7003
|
});
|
|
6656
7004
|
case "timeout":
|
|
6657
7005
|
throw new LangfuseAPITimeoutError(
|
|
6658
|
-
"Timeout exceeded when calling GET /api/public/
|
|
7006
|
+
"Timeout exceeded when calling GET /api/public/models/{id}."
|
|
6659
7007
|
);
|
|
6660
7008
|
case "unknown":
|
|
6661
7009
|
throw new LangfuseAPIError({
|
|
@@ -6664,29 +7012,11 @@ var ObservationsV2 = class {
|
|
|
6664
7012
|
});
|
|
6665
7013
|
}
|
|
6666
7014
|
}
|
|
6667
|
-
async _getAuthorizationHeader() {
|
|
6668
|
-
const username = await Supplier.get(this._options.username);
|
|
6669
|
-
const password = await Supplier.get(this._options.password);
|
|
6670
|
-
if (username != null && password != null) {
|
|
6671
|
-
return BasicAuth.toAuthorizationHeader({
|
|
6672
|
-
username,
|
|
6673
|
-
password
|
|
6674
|
-
});
|
|
6675
|
-
}
|
|
6676
|
-
return void 0;
|
|
6677
|
-
}
|
|
6678
|
-
};
|
|
6679
|
-
|
|
6680
|
-
// src/api/api/resources/observations/client/Client.ts
|
|
6681
|
-
var Observations = class {
|
|
6682
|
-
constructor(_options) {
|
|
6683
|
-
this._options = _options;
|
|
6684
|
-
}
|
|
6685
7015
|
/**
|
|
6686
|
-
*
|
|
7016
|
+
* Delete a model. Cannot delete models managed by Langfuse. You can create your own definition with the same modelName to override the definition though.
|
|
6687
7017
|
*
|
|
6688
|
-
* @param {string}
|
|
6689
|
-
* @param {
|
|
7018
|
+
* @param {string} id
|
|
7019
|
+
* @param {Models.RequestOptions} requestOptions - Request-specific configuration.
|
|
6690
7020
|
*
|
|
6691
7021
|
* @throws {@link LangfuseAPI.Error}
|
|
6692
7022
|
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
@@ -6695,14 +7025,14 @@ var Observations = class {
|
|
|
6695
7025
|
* @throws {@link LangfuseAPI.NotFoundError}
|
|
6696
7026
|
*
|
|
6697
7027
|
* @example
|
|
6698
|
-
* await client.
|
|
7028
|
+
* await client.models.delete("id")
|
|
6699
7029
|
*/
|
|
6700
|
-
|
|
7030
|
+
delete(id, requestOptions) {
|
|
6701
7031
|
return HttpResponsePromise.fromPromise(
|
|
6702
|
-
this.
|
|
7032
|
+
this.__delete(id, requestOptions)
|
|
6703
7033
|
);
|
|
6704
7034
|
}
|
|
6705
|
-
async
|
|
7035
|
+
async __delete(id, requestOptions) {
|
|
6706
7036
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
6707
7037
|
let _headers = mergeHeaders(
|
|
6708
7038
|
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
@@ -6717,9 +7047,9 @@ var Observations = class {
|
|
|
6717
7047
|
const _response = await fetcher({
|
|
6718
7048
|
url: url_exports.join(
|
|
6719
7049
|
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
6720
|
-
`/api/public/
|
|
7050
|
+
`/api/public/models/${encodeURIComponent(id)}`
|
|
6721
7051
|
),
|
|
6722
|
-
method: "
|
|
7052
|
+
method: "DELETE",
|
|
6723
7053
|
headers: _headers,
|
|
6724
7054
|
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
6725
7055
|
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
@@ -6727,10 +7057,7 @@ var Observations = class {
|
|
|
6727
7057
|
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
6728
7058
|
});
|
|
6729
7059
|
if (_response.ok) {
|
|
6730
|
-
return {
|
|
6731
|
-
data: _response.body,
|
|
6732
|
-
rawResponse: _response.rawResponse
|
|
6733
|
-
};
|
|
7060
|
+
return { data: void 0, rawResponse: _response.rawResponse };
|
|
6734
7061
|
}
|
|
6735
7062
|
if (_response.error.reason === "status-code") {
|
|
6736
7063
|
switch (_response.error.statusCode) {
|
|
@@ -6776,7 +7103,7 @@ var Observations = class {
|
|
|
6776
7103
|
});
|
|
6777
7104
|
case "timeout":
|
|
6778
7105
|
throw new LangfuseAPITimeoutError(
|
|
6779
|
-
"Timeout exceeded when calling
|
|
7106
|
+
"Timeout exceeded when calling DELETE /api/public/models/{id}."
|
|
6780
7107
|
);
|
|
6781
7108
|
case "unknown":
|
|
6782
7109
|
throw new LangfuseAPIError({
|
|
@@ -6785,12 +7112,51 @@ var Observations = class {
|
|
|
6785
7112
|
});
|
|
6786
7113
|
}
|
|
6787
7114
|
}
|
|
7115
|
+
async _getAuthorizationHeader() {
|
|
7116
|
+
const username = await Supplier.get(this._options.username);
|
|
7117
|
+
const password = await Supplier.get(this._options.password);
|
|
7118
|
+
if (username != null && password != null) {
|
|
7119
|
+
return BasicAuth.toAuthorizationHeader({
|
|
7120
|
+
username,
|
|
7121
|
+
password
|
|
7122
|
+
});
|
|
7123
|
+
}
|
|
7124
|
+
return void 0;
|
|
7125
|
+
}
|
|
7126
|
+
};
|
|
7127
|
+
|
|
7128
|
+
// src/api/api/resources/observations/client/Client.ts
|
|
7129
|
+
var Observations = class {
|
|
7130
|
+
constructor(_options) {
|
|
7131
|
+
this._options = _options;
|
|
7132
|
+
}
|
|
6788
7133
|
/**
|
|
6789
|
-
* Get a list of observations.
|
|
7134
|
+
* Get a list of observations with cursor-based pagination and flexible field selection.
|
|
6790
7135
|
*
|
|
6791
|
-
*
|
|
7136
|
+
* ## Cursor-based Pagination
|
|
7137
|
+
* This endpoint uses cursor-based pagination for efficient traversal of large datasets.
|
|
7138
|
+
* The cursor is returned in the response metadata and should be passed in subsequent requests
|
|
7139
|
+
* to retrieve the next page of results.
|
|
7140
|
+
*
|
|
7141
|
+
* ## Field Selection
|
|
7142
|
+
* Use the `fields` parameter to control which observation fields are returned:
|
|
7143
|
+
* - `core` - Always included: id, traceId, startTime, endTime, projectId, parentObservationId, type
|
|
7144
|
+
* - `basic` - name, level, statusMessage, version, environment, bookmarked, public, userId, sessionId
|
|
7145
|
+
* - `time` - completionStartTime, createdAt, updatedAt
|
|
7146
|
+
* - `io` - input, output
|
|
7147
|
+
* - `metadata` - metadata (truncated to 200 chars by default, use `expandMetadata` to get full values)
|
|
7148
|
+
* - `model` - providedModelName, internalModelId, modelParameters
|
|
7149
|
+
* - `usage` - usageDetails, costDetails, totalCost
|
|
7150
|
+
* - `prompt` - promptId, promptName, promptVersion
|
|
7151
|
+
* - `metrics` - latency, timeToFirstToken
|
|
7152
|
+
*
|
|
7153
|
+
* If not specified, `core` and `basic` field groups are returned.
|
|
7154
|
+
*
|
|
7155
|
+
* ## Filters
|
|
7156
|
+
* Multiple filtering options are available via query parameters or the structured `filter` parameter.
|
|
7157
|
+
* When using the `filter` parameter, it takes precedence over individual query parameter filters.
|
|
6792
7158
|
*
|
|
6793
|
-
* @param {LangfuseAPI.
|
|
7159
|
+
* @param {LangfuseAPI.GetObservationsV2Request} request
|
|
6794
7160
|
* @param {Observations.RequestOptions} requestOptions - Request-specific configuration.
|
|
6795
7161
|
*
|
|
6796
7162
|
* @throws {@link LangfuseAPI.Error}
|
|
@@ -6810,8 +7176,11 @@ var Observations = class {
|
|
|
6810
7176
|
async __getMany(request = {}, requestOptions) {
|
|
6811
7177
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
6812
7178
|
const {
|
|
6813
|
-
|
|
7179
|
+
fields,
|
|
7180
|
+
expandMetadata,
|
|
6814
7181
|
limit,
|
|
7182
|
+
cursor,
|
|
7183
|
+
parseIoAsJson,
|
|
6815
7184
|
name,
|
|
6816
7185
|
userId,
|
|
6817
7186
|
type: type_,
|
|
@@ -6825,12 +7194,21 @@ var Observations = class {
|
|
|
6825
7194
|
filter
|
|
6826
7195
|
} = request;
|
|
6827
7196
|
const _queryParams = {};
|
|
6828
|
-
if (
|
|
6829
|
-
_queryParams["
|
|
7197
|
+
if (fields != null) {
|
|
7198
|
+
_queryParams["fields"] = fields;
|
|
7199
|
+
}
|
|
7200
|
+
if (expandMetadata != null) {
|
|
7201
|
+
_queryParams["expandMetadata"] = expandMetadata;
|
|
6830
7202
|
}
|
|
6831
7203
|
if (limit != null) {
|
|
6832
7204
|
_queryParams["limit"] = limit.toString();
|
|
6833
7205
|
}
|
|
7206
|
+
if (cursor != null) {
|
|
7207
|
+
_queryParams["cursor"] = cursor;
|
|
7208
|
+
}
|
|
7209
|
+
if (parseIoAsJson != null) {
|
|
7210
|
+
_queryParams["parseIoAsJson"] = parseIoAsJson.toString();
|
|
7211
|
+
}
|
|
6834
7212
|
if (name != null) {
|
|
6835
7213
|
_queryParams["name"] = name;
|
|
6836
7214
|
}
|
|
@@ -6881,7 +7259,7 @@ var Observations = class {
|
|
|
6881
7259
|
const _response = await fetcher({
|
|
6882
7260
|
url: url_exports.join(
|
|
6883
7261
|
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
6884
|
-
"/api/public/observations"
|
|
7262
|
+
"/api/public/v2/observations"
|
|
6885
7263
|
),
|
|
6886
7264
|
method: "GET",
|
|
6887
7265
|
headers: _headers,
|
|
@@ -6940,7 +7318,7 @@ var Observations = class {
|
|
|
6940
7318
|
});
|
|
6941
7319
|
case "timeout":
|
|
6942
7320
|
throw new LangfuseAPITimeoutError(
|
|
6943
|
-
"Timeout exceeded when calling GET /api/public/observations."
|
|
7321
|
+
"Timeout exceeded when calling GET /api/public/v2/observations."
|
|
6944
7322
|
);
|
|
6945
7323
|
case "unknown":
|
|
6946
7324
|
throw new LangfuseAPIError({
|
|
@@ -8919,7 +9297,7 @@ var Prompts = class {
|
|
|
8919
9297
|
}
|
|
8920
9298
|
async __get(promptName, request = {}, requestOptions) {
|
|
8921
9299
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
8922
|
-
const { version, label } = request;
|
|
9300
|
+
const { version, label, resolve } = request;
|
|
8923
9301
|
const _queryParams = {};
|
|
8924
9302
|
if (version != null) {
|
|
8925
9303
|
_queryParams["version"] = version.toString();
|
|
@@ -8927,6 +9305,9 @@ var Prompts = class {
|
|
|
8927
9305
|
if (label != null) {
|
|
8928
9306
|
_queryParams["label"] = label;
|
|
8929
9307
|
}
|
|
9308
|
+
if (resolve != null) {
|
|
9309
|
+
_queryParams["resolve"] = resolve.toString();
|
|
9310
|
+
}
|
|
8930
9311
|
let _headers = mergeHeaders(
|
|
8931
9312
|
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
8932
9313
|
mergeOnlyDefinedHeaders({
|
|
@@ -10595,8 +10976,8 @@ var ScoreConfigs = class {
|
|
|
10595
10976
|
}
|
|
10596
10977
|
};
|
|
10597
10978
|
|
|
10598
|
-
// src/api/api/resources/
|
|
10599
|
-
var
|
|
10979
|
+
// src/api/api/resources/scores/client/Client.ts
|
|
10980
|
+
var Scores = class {
|
|
10600
10981
|
constructor(_options) {
|
|
10601
10982
|
this._options = _options;
|
|
10602
10983
|
}
|
|
@@ -10604,7 +10985,7 @@ var ScoreV2 = class {
|
|
|
10604
10985
|
* Get a list of scores (supports both trace and session scores)
|
|
10605
10986
|
*
|
|
10606
10987
|
* @param {LangfuseAPI.GetScoresRequest} request
|
|
10607
|
-
* @param {
|
|
10988
|
+
* @param {Scores.RequestOptions} requestOptions - Request-specific configuration.
|
|
10608
10989
|
*
|
|
10609
10990
|
* @throws {@link LangfuseAPI.Error}
|
|
10610
10991
|
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
@@ -10613,14 +10994,14 @@ var ScoreV2 = class {
|
|
|
10613
10994
|
* @throws {@link LangfuseAPI.NotFoundError}
|
|
10614
10995
|
*
|
|
10615
10996
|
* @example
|
|
10616
|
-
* await client.
|
|
10997
|
+
* await client.scores.getMany()
|
|
10617
10998
|
*/
|
|
10618
|
-
|
|
10999
|
+
getMany(request = {}, requestOptions) {
|
|
10619
11000
|
return HttpResponsePromise.fromPromise(
|
|
10620
|
-
this.
|
|
11001
|
+
this.__getMany(request, requestOptions)
|
|
10621
11002
|
);
|
|
10622
11003
|
}
|
|
10623
|
-
async
|
|
11004
|
+
async __getMany(request = {}, requestOptions) {
|
|
10624
11005
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
10625
11006
|
const {
|
|
10626
11007
|
page,
|
|
@@ -10802,7 +11183,7 @@ var ScoreV2 = class {
|
|
|
10802
11183
|
* Get a score (supports both trace and session scores)
|
|
10803
11184
|
*
|
|
10804
11185
|
* @param {string} scoreId - The unique langfuse identifier of a score
|
|
10805
|
-
* @param {
|
|
11186
|
+
* @param {Scores.RequestOptions} requestOptions - Request-specific configuration.
|
|
10806
11187
|
*
|
|
10807
11188
|
* @throws {@link LangfuseAPI.Error}
|
|
10808
11189
|
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
@@ -10811,7 +11192,7 @@ var ScoreV2 = class {
|
|
|
10811
11192
|
* @throws {@link LangfuseAPI.NotFoundError}
|
|
10812
11193
|
*
|
|
10813
11194
|
* @example
|
|
10814
|
-
* await client.
|
|
11195
|
+
* await client.scores.getById("scoreId")
|
|
10815
11196
|
*/
|
|
10816
11197
|
getById(scoreId, requestOptions) {
|
|
10817
11198
|
return HttpResponsePromise.fromPromise(
|
|
@@ -10914,244 +11295,6 @@ var ScoreV2 = class {
|
|
|
10914
11295
|
}
|
|
10915
11296
|
};
|
|
10916
11297
|
|
|
10917
|
-
// src/api/api/resources/score/client/Client.ts
|
|
10918
|
-
var Score = class {
|
|
10919
|
-
constructor(_options) {
|
|
10920
|
-
this._options = _options;
|
|
10921
|
-
}
|
|
10922
|
-
/**
|
|
10923
|
-
* Create a score (supports both trace and session scores)
|
|
10924
|
-
*
|
|
10925
|
-
* @param {LangfuseAPI.CreateScoreRequest} request
|
|
10926
|
-
* @param {Score.RequestOptions} requestOptions - Request-specific configuration.
|
|
10927
|
-
*
|
|
10928
|
-
* @throws {@link LangfuseAPI.Error}
|
|
10929
|
-
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
10930
|
-
* @throws {@link LangfuseAPI.AccessDeniedError}
|
|
10931
|
-
* @throws {@link LangfuseAPI.MethodNotAllowedError}
|
|
10932
|
-
* @throws {@link LangfuseAPI.NotFoundError}
|
|
10933
|
-
*
|
|
10934
|
-
* @example
|
|
10935
|
-
* await client.score.create({
|
|
10936
|
-
* id: undefined,
|
|
10937
|
-
* traceId: undefined,
|
|
10938
|
-
* sessionId: undefined,
|
|
10939
|
-
* observationId: undefined,
|
|
10940
|
-
* datasetRunId: undefined,
|
|
10941
|
-
* name: "name",
|
|
10942
|
-
* value: 1.1,
|
|
10943
|
-
* comment: undefined,
|
|
10944
|
-
* metadata: undefined,
|
|
10945
|
-
* environment: undefined,
|
|
10946
|
-
* queueId: undefined,
|
|
10947
|
-
* dataType: undefined,
|
|
10948
|
-
* configId: undefined
|
|
10949
|
-
* })
|
|
10950
|
-
*/
|
|
10951
|
-
create(request, requestOptions) {
|
|
10952
|
-
return HttpResponsePromise.fromPromise(
|
|
10953
|
-
this.__create(request, requestOptions)
|
|
10954
|
-
);
|
|
10955
|
-
}
|
|
10956
|
-
async __create(request, requestOptions) {
|
|
10957
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
10958
|
-
let _headers = mergeHeaders(
|
|
10959
|
-
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
10960
|
-
mergeOnlyDefinedHeaders({
|
|
10961
|
-
Authorization: await this._getAuthorizationHeader(),
|
|
10962
|
-
"X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
|
|
10963
|
-
"X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
|
|
10964
|
-
"X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
|
|
10965
|
-
}),
|
|
10966
|
-
requestOptions == null ? void 0 : requestOptions.headers
|
|
10967
|
-
);
|
|
10968
|
-
const _response = await fetcher({
|
|
10969
|
-
url: url_exports.join(
|
|
10970
|
-
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
10971
|
-
"/api/public/scores"
|
|
10972
|
-
),
|
|
10973
|
-
method: "POST",
|
|
10974
|
-
headers: _headers,
|
|
10975
|
-
contentType: "application/json",
|
|
10976
|
-
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
10977
|
-
requestType: "json",
|
|
10978
|
-
body: request,
|
|
10979
|
-
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
10980
|
-
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
10981
|
-
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
10982
|
-
});
|
|
10983
|
-
if (_response.ok) {
|
|
10984
|
-
return {
|
|
10985
|
-
data: _response.body,
|
|
10986
|
-
rawResponse: _response.rawResponse
|
|
10987
|
-
};
|
|
10988
|
-
}
|
|
10989
|
-
if (_response.error.reason === "status-code") {
|
|
10990
|
-
switch (_response.error.statusCode) {
|
|
10991
|
-
case 400:
|
|
10992
|
-
throw new Error2(
|
|
10993
|
-
_response.error.body,
|
|
10994
|
-
_response.rawResponse
|
|
10995
|
-
);
|
|
10996
|
-
case 401:
|
|
10997
|
-
throw new UnauthorizedError(
|
|
10998
|
-
_response.error.body,
|
|
10999
|
-
_response.rawResponse
|
|
11000
|
-
);
|
|
11001
|
-
case 403:
|
|
11002
|
-
throw new AccessDeniedError(
|
|
11003
|
-
_response.error.body,
|
|
11004
|
-
_response.rawResponse
|
|
11005
|
-
);
|
|
11006
|
-
case 405:
|
|
11007
|
-
throw new MethodNotAllowedError(
|
|
11008
|
-
_response.error.body,
|
|
11009
|
-
_response.rawResponse
|
|
11010
|
-
);
|
|
11011
|
-
case 404:
|
|
11012
|
-
throw new NotFoundError(
|
|
11013
|
-
_response.error.body,
|
|
11014
|
-
_response.rawResponse
|
|
11015
|
-
);
|
|
11016
|
-
default:
|
|
11017
|
-
throw new LangfuseAPIError({
|
|
11018
|
-
statusCode: _response.error.statusCode,
|
|
11019
|
-
body: _response.error.body,
|
|
11020
|
-
rawResponse: _response.rawResponse
|
|
11021
|
-
});
|
|
11022
|
-
}
|
|
11023
|
-
}
|
|
11024
|
-
switch (_response.error.reason) {
|
|
11025
|
-
case "non-json":
|
|
11026
|
-
throw new LangfuseAPIError({
|
|
11027
|
-
statusCode: _response.error.statusCode,
|
|
11028
|
-
body: _response.error.rawBody,
|
|
11029
|
-
rawResponse: _response.rawResponse
|
|
11030
|
-
});
|
|
11031
|
-
case "timeout":
|
|
11032
|
-
throw new LangfuseAPITimeoutError(
|
|
11033
|
-
"Timeout exceeded when calling POST /api/public/scores."
|
|
11034
|
-
);
|
|
11035
|
-
case "unknown":
|
|
11036
|
-
throw new LangfuseAPIError({
|
|
11037
|
-
message: _response.error.errorMessage,
|
|
11038
|
-
rawResponse: _response.rawResponse
|
|
11039
|
-
});
|
|
11040
|
-
}
|
|
11041
|
-
}
|
|
11042
|
-
/**
|
|
11043
|
-
* Delete a score (supports both trace and session scores)
|
|
11044
|
-
*
|
|
11045
|
-
* @param {string} scoreId - The unique langfuse identifier of a score
|
|
11046
|
-
* @param {Score.RequestOptions} requestOptions - Request-specific configuration.
|
|
11047
|
-
*
|
|
11048
|
-
* @throws {@link LangfuseAPI.Error}
|
|
11049
|
-
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
11050
|
-
* @throws {@link LangfuseAPI.AccessDeniedError}
|
|
11051
|
-
* @throws {@link LangfuseAPI.MethodNotAllowedError}
|
|
11052
|
-
* @throws {@link LangfuseAPI.NotFoundError}
|
|
11053
|
-
*
|
|
11054
|
-
* @example
|
|
11055
|
-
* await client.score.delete("scoreId")
|
|
11056
|
-
*/
|
|
11057
|
-
delete(scoreId, requestOptions) {
|
|
11058
|
-
return HttpResponsePromise.fromPromise(
|
|
11059
|
-
this.__delete(scoreId, requestOptions)
|
|
11060
|
-
);
|
|
11061
|
-
}
|
|
11062
|
-
async __delete(scoreId, requestOptions) {
|
|
11063
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
11064
|
-
let _headers = mergeHeaders(
|
|
11065
|
-
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
11066
|
-
mergeOnlyDefinedHeaders({
|
|
11067
|
-
Authorization: await this._getAuthorizationHeader(),
|
|
11068
|
-
"X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
|
|
11069
|
-
"X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
|
|
11070
|
-
"X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
|
|
11071
|
-
}),
|
|
11072
|
-
requestOptions == null ? void 0 : requestOptions.headers
|
|
11073
|
-
);
|
|
11074
|
-
const _response = await fetcher({
|
|
11075
|
-
url: url_exports.join(
|
|
11076
|
-
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
11077
|
-
`/api/public/scores/${encodeURIComponent(scoreId)}`
|
|
11078
|
-
),
|
|
11079
|
-
method: "DELETE",
|
|
11080
|
-
headers: _headers,
|
|
11081
|
-
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
11082
|
-
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
11083
|
-
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
11084
|
-
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
11085
|
-
});
|
|
11086
|
-
if (_response.ok) {
|
|
11087
|
-
return { data: void 0, rawResponse: _response.rawResponse };
|
|
11088
|
-
}
|
|
11089
|
-
if (_response.error.reason === "status-code") {
|
|
11090
|
-
switch (_response.error.statusCode) {
|
|
11091
|
-
case 400:
|
|
11092
|
-
throw new Error2(
|
|
11093
|
-
_response.error.body,
|
|
11094
|
-
_response.rawResponse
|
|
11095
|
-
);
|
|
11096
|
-
case 401:
|
|
11097
|
-
throw new UnauthorizedError(
|
|
11098
|
-
_response.error.body,
|
|
11099
|
-
_response.rawResponse
|
|
11100
|
-
);
|
|
11101
|
-
case 403:
|
|
11102
|
-
throw new AccessDeniedError(
|
|
11103
|
-
_response.error.body,
|
|
11104
|
-
_response.rawResponse
|
|
11105
|
-
);
|
|
11106
|
-
case 405:
|
|
11107
|
-
throw new MethodNotAllowedError(
|
|
11108
|
-
_response.error.body,
|
|
11109
|
-
_response.rawResponse
|
|
11110
|
-
);
|
|
11111
|
-
case 404:
|
|
11112
|
-
throw new NotFoundError(
|
|
11113
|
-
_response.error.body,
|
|
11114
|
-
_response.rawResponse
|
|
11115
|
-
);
|
|
11116
|
-
default:
|
|
11117
|
-
throw new LangfuseAPIError({
|
|
11118
|
-
statusCode: _response.error.statusCode,
|
|
11119
|
-
body: _response.error.body,
|
|
11120
|
-
rawResponse: _response.rawResponse
|
|
11121
|
-
});
|
|
11122
|
-
}
|
|
11123
|
-
}
|
|
11124
|
-
switch (_response.error.reason) {
|
|
11125
|
-
case "non-json":
|
|
11126
|
-
throw new LangfuseAPIError({
|
|
11127
|
-
statusCode: _response.error.statusCode,
|
|
11128
|
-
body: _response.error.rawBody,
|
|
11129
|
-
rawResponse: _response.rawResponse
|
|
11130
|
-
});
|
|
11131
|
-
case "timeout":
|
|
11132
|
-
throw new LangfuseAPITimeoutError(
|
|
11133
|
-
"Timeout exceeded when calling DELETE /api/public/scores/{scoreId}."
|
|
11134
|
-
);
|
|
11135
|
-
case "unknown":
|
|
11136
|
-
throw new LangfuseAPIError({
|
|
11137
|
-
message: _response.error.errorMessage,
|
|
11138
|
-
rawResponse: _response.rawResponse
|
|
11139
|
-
});
|
|
11140
|
-
}
|
|
11141
|
-
}
|
|
11142
|
-
async _getAuthorizationHeader() {
|
|
11143
|
-
const username = await Supplier.get(this._options.username);
|
|
11144
|
-
const password = await Supplier.get(this._options.password);
|
|
11145
|
-
if (username != null && password != null) {
|
|
11146
|
-
return BasicAuth.toAuthorizationHeader({
|
|
11147
|
-
username,
|
|
11148
|
-
password
|
|
11149
|
-
});
|
|
11150
|
-
}
|
|
11151
|
-
return void 0;
|
|
11152
|
-
}
|
|
11153
|
-
};
|
|
11154
|
-
|
|
11155
11298
|
// src/api/api/resources/sessions/client/Client.ts
|
|
11156
11299
|
var Sessions = class {
|
|
11157
11300
|
constructor(_options) {
|
|
@@ -11948,6 +12091,10 @@ var LangfuseAPIClient = class {
|
|
|
11948
12091
|
var _a2;
|
|
11949
12092
|
return (_a2 = this._ingestion) != null ? _a2 : this._ingestion = new Ingestion(this._options);
|
|
11950
12093
|
}
|
|
12094
|
+
get legacy() {
|
|
12095
|
+
var _a2;
|
|
12096
|
+
return (_a2 = this._legacy) != null ? _a2 : this._legacy = new Legacy(this._options);
|
|
12097
|
+
}
|
|
11951
12098
|
get llmConnections() {
|
|
11952
12099
|
var _a2;
|
|
11953
12100
|
return (_a2 = this._llmConnections) != null ? _a2 : this._llmConnections = new LlmConnections(this._options);
|
|
@@ -11956,10 +12103,6 @@ var LangfuseAPIClient = class {
|
|
|
11956
12103
|
var _a2;
|
|
11957
12104
|
return (_a2 = this._media) != null ? _a2 : this._media = new Media(this._options);
|
|
11958
12105
|
}
|
|
11959
|
-
get metricsV2() {
|
|
11960
|
-
var _a2;
|
|
11961
|
-
return (_a2 = this._metricsV2) != null ? _a2 : this._metricsV2 = new MetricsV2(this._options);
|
|
11962
|
-
}
|
|
11963
12106
|
get metrics() {
|
|
11964
12107
|
var _a2;
|
|
11965
12108
|
return (_a2 = this._metrics) != null ? _a2 : this._metrics = new Metrics(this._options);
|
|
@@ -11968,10 +12111,6 @@ var LangfuseAPIClient = class {
|
|
|
11968
12111
|
var _a2;
|
|
11969
12112
|
return (_a2 = this._models) != null ? _a2 : this._models = new Models(this._options);
|
|
11970
12113
|
}
|
|
11971
|
-
get observationsV2() {
|
|
11972
|
-
var _a2;
|
|
11973
|
-
return (_a2 = this._observationsV2) != null ? _a2 : this._observationsV2 = new ObservationsV2(this._options);
|
|
11974
|
-
}
|
|
11975
12114
|
get observations() {
|
|
11976
12115
|
var _a2;
|
|
11977
12116
|
return (_a2 = this._observations) != null ? _a2 : this._observations = new Observations(this._options);
|
|
@@ -12004,13 +12143,9 @@ var LangfuseAPIClient = class {
|
|
|
12004
12143
|
var _a2;
|
|
12005
12144
|
return (_a2 = this._scoreConfigs) != null ? _a2 : this._scoreConfigs = new ScoreConfigs(this._options);
|
|
12006
12145
|
}
|
|
12007
|
-
get
|
|
12008
|
-
var _a2;
|
|
12009
|
-
return (_a2 = this._scoreV2) != null ? _a2 : this._scoreV2 = new ScoreV2(this._options);
|
|
12010
|
-
}
|
|
12011
|
-
get score() {
|
|
12146
|
+
get scores() {
|
|
12012
12147
|
var _a2;
|
|
12013
|
-
return (_a2 = this.
|
|
12148
|
+
return (_a2 = this._scores) != null ? _a2 : this._scores = new Scores(this._options);
|
|
12014
12149
|
}
|
|
12015
12150
|
get sessions() {
|
|
12016
12151
|
var _a2;
|
|
@@ -12593,6 +12728,7 @@ export {
|
|
|
12593
12728
|
BlobStorageExportMode,
|
|
12594
12729
|
BlobStorageIntegrationFileType,
|
|
12595
12730
|
BlobStorageIntegrationType,
|
|
12731
|
+
BlobStorageSyncStatus,
|
|
12596
12732
|
ChatMessageType,
|
|
12597
12733
|
CommentObjectType,
|
|
12598
12734
|
CreateChatPromptType,
|
|
@@ -12648,14 +12784,13 @@ export {
|
|
|
12648
12784
|
getPropagatedAttributesFromContext,
|
|
12649
12785
|
health_exports as health,
|
|
12650
12786
|
ingestion_exports as ingestion,
|
|
12787
|
+
legacy_exports as legacy,
|
|
12651
12788
|
llmConnections_exports as llmConnections,
|
|
12652
12789
|
LoggerSingleton as logger,
|
|
12653
12790
|
media_exports as media,
|
|
12654
12791
|
metrics_exports as metrics,
|
|
12655
|
-
metricsV2_exports as metricsV2,
|
|
12656
12792
|
models_exports as models,
|
|
12657
12793
|
observations_exports as observations,
|
|
12658
|
-
observationsV2_exports as observationsV2,
|
|
12659
12794
|
opentelemetry_exports as opentelemetry,
|
|
12660
12795
|
organizations_exports as organizations,
|
|
12661
12796
|
projects_exports as projects,
|
|
@@ -12665,9 +12800,8 @@ export {
|
|
|
12665
12800
|
resetGlobalLogger,
|
|
12666
12801
|
safeSetTimeout,
|
|
12667
12802
|
scim_exports as scim,
|
|
12668
|
-
score_exports as score,
|
|
12669
12803
|
scoreConfigs_exports as scoreConfigs,
|
|
12670
|
-
|
|
12804
|
+
scores_exports as scores,
|
|
12671
12805
|
serializeValue,
|
|
12672
12806
|
sessions_exports as sessions,
|
|
12673
12807
|
trace_exports as trace,
|