Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/client/src/LangfuseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ export interface LangfuseClientParams {
* Additional HTTP headers to include with API requests.
*/
additionalHeaders?: Record<string, string>;

/**
* Custom fetch function to use for HTTP requests.
* Useful for testing, proxying, or customizing request behavior.
*
* @example
* ```typescript
* const customFetch = async (url, init) => {
* console.log('Making request to:', url);
* return fetch(url, init);
* };
*
* const langfuse = new LangfuseClient({
* fetch: customFetch
* });
* ```
*/
fetch?: typeof fetch;
}

/**
Expand Down Expand Up @@ -284,6 +302,7 @@ export class LangfuseClient {
xLangfuseSdkName: "javascript",
environment: "", // noop as baseUrl is set
headers: params?.additionalHeaders,
fetch: params?.fetch,
});

logger.debug("Initialized LangfuseClient with params:", {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/api/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export declare namespace LangfuseAPIClient {
string,
string | core.Supplier<string | null | undefined> | null | undefined
>;
/** Custom fetch function to use for HTTP requests */
fetch?: typeof fetch;
}

export interface RequestOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export declare namespace AnnotationQueues {
string,
string | core.Supplier<string | null | undefined> | null | undefined
>;
/** Custom fetch function to use for HTTP requests */
fetch?: typeof fetch;
}

export interface RequestOptions {
Expand Down Expand Up @@ -131,6 +133,7 @@ export class AnnotationQueues {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -259,6 +262,7 @@ export class AnnotationQueues {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -380,6 +384,7 @@ export class AnnotationQueues {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -521,6 +526,7 @@ export class AnnotationQueues {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -645,6 +651,7 @@ export class AnnotationQueues {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -776,6 +783,7 @@ export class AnnotationQueues {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -908,6 +916,7 @@ export class AnnotationQueues {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -1034,6 +1043,7 @@ export class AnnotationQueues {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -1165,6 +1175,7 @@ export class AnnotationQueues {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -1296,6 +1307,7 @@ export class AnnotationQueues {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export declare namespace BlobStorageIntegrations {
string,
string | core.Supplier<string | null | undefined> | null | undefined
>;
/** Custom fetch function to use for HTTP requests */
fetch?: typeof fetch;
}

export interface RequestOptions {
Expand Down Expand Up @@ -117,6 +119,7 @@ export class BlobStorageIntegrations {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -256,6 +259,7 @@ export class BlobStorageIntegrations {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -379,6 +383,7 @@ export class BlobStorageIntegrations {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/api/api/resources/comments/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export declare namespace Comments {
string,
string | core.Supplier<string | null | undefined> | null | undefined
>;
/** Custom fetch function to use for HTTP requests */
fetch?: typeof fetch;
}

export interface RequestOptions {
Expand Down Expand Up @@ -127,6 +129,7 @@ export class Comments {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -273,6 +276,7 @@ export class Comments {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -394,6 +398,7 @@ export class Comments {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export declare namespace DatasetItems {
string,
string | core.Supplier<string | null | undefined> | null | undefined
>;
/** Custom fetch function to use for HTTP requests */
fetch?: typeof fetch;
}

export interface RequestOptions {
Expand Down Expand Up @@ -130,6 +132,7 @@ export class DatasetItems {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -249,6 +252,7 @@ export class DatasetItems {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -396,6 +400,7 @@ export class DatasetItems {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -517,6 +522,7 @@ export class DatasetItems {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export declare namespace DatasetRunItems {
string,
string | core.Supplier<string | null | undefined> | null | undefined
>;
/** Custom fetch function to use for HTTP requests */
fetch?: typeof fetch;
}

export interface RequestOptions {
Expand Down Expand Up @@ -128,6 +130,7 @@ export class DatasetRunItems {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -267,6 +270,7 @@ export class DatasetRunItems {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/api/api/resources/datasets/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export declare namespace Datasets {
string,
string | core.Supplier<string | null | undefined> | null | undefined
>;
/** Custom fetch function to use for HTTP requests */
fetch?: typeof fetch;
}

export interface RequestOptions {
Expand Down Expand Up @@ -131,6 +133,7 @@ export class Datasets {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -252,6 +255,7 @@ export class Datasets {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -382,6 +386,7 @@ export class Datasets {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -506,6 +511,7 @@ export class Datasets {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -630,6 +636,7 @@ export class Datasets {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -767,6 +774,7 @@ export class Datasets {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/api/api/resources/health/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export declare namespace Health {
string,
string | core.Supplier<string | null | undefined> | null | undefined
>;
/** Custom fetch function to use for HTTP requests */
fetch?: typeof fetch;
}

export interface RequestOptions {
Expand Down Expand Up @@ -114,6 +116,7 @@ export class Health {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export declare namespace Ingestion {
string,
string | core.Supplier<string | null | undefined> | null | undefined
>;
/** Custom fetch function to use for HTTP requests */
fetch?: typeof fetch;
}

export interface RequestOptions {
Expand Down Expand Up @@ -187,6 +189,7 @@ export class Ingestion {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export declare namespace LlmConnections {
string,
string | core.Supplier<string | null | undefined> | null | undefined
>;
/** Custom fetch function to use for HTTP requests */
fetch?: typeof fetch;
}

export interface RequestOptions {
Expand Down Expand Up @@ -131,6 +133,7 @@ export class LlmConnections {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down Expand Up @@ -264,6 +267,7 @@ export class LlmConnections {
: 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
fetch: this._options.fetch,
});
if (_response.ok) {
return {
Expand Down
Loading