Skip to content

Commit

Permalink
🐛 FIX: [bugfix] portkey sdk drops customhost header to ollama
Browse files Browse the repository at this point in the history
  • Loading branch information
Saif-Shines committed May 2, 2024
1 parent 64299e8 commit 1541269
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/_types/generalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ export interface ApiClientInterface {
Authorization?: string | null | undefined;
cacheForceRefresh?: boolean | null | undefined;
debug?: boolean | null | undefined;
customHost?: string | null | undefined
}

export interface APIResponseType {
getHeaders: () => Record<string, string> | null | undefined
}
}
6 changes: 3 additions & 3 deletions src/baseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ export abstract class ApiClient {
portkeyHeaders: Record<string, string>

private fetch: Fetch;
constructor({ apiKey, baseURL, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug }: ApiClientInterface) {
constructor({ apiKey, baseURL, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost }: ApiClientInterface) {
this.apiKey = apiKey ?? "";
this.baseURL = baseURL ?? "";
this.customHeaders = createHeaders({ apiKey, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug })
this.customHeaders = createHeaders({ apiKey, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost })
this.portkeyHeaders = this.defaultHeaders()
this.fetch = fetch;
this.responseHeaders = {}
Expand Down Expand Up @@ -200,4 +200,4 @@ export abstract class ApiClient {
methodRequest<Rsp>(method: HTTPMethod, path: string, opts?: RequestOptions): APIPromise<Rsp> {
return new APIPromise(this.request({ method, path, ...opts }))
}
}
}
6 changes: 5 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class Portkey extends ApiClient {
Authorization?: string;
cacheForceRefresh?: boolean | null | undefined;
debug?: boolean | null | undefined;
customHost?: string | null | undefined;
constructor({
apiKey = readEnv("PORTKEY_API_KEY") ?? null,
baseURL = readEnv("PORTKEY_BASE_URL") ?? null,
Expand All @@ -27,6 +28,7 @@ export class Portkey extends ApiClient {
Authorization,
cacheForceRefresh,
debug,
customHost,
}: ApiClientInterface) {

super({
Expand All @@ -40,6 +42,7 @@ export class Portkey extends ApiClient {
Authorization,
cacheForceRefresh,
debug,
customHost
});

this.apiKey = apiKey;
Expand All @@ -54,6 +57,7 @@ export class Portkey extends ApiClient {
this.metadata = metadata
this.cacheForceRefresh = cacheForceRefresh;
this.debug = debug;
this.customHost = customHost
}

completions: API.Completions = new API.Completions(this);
Expand All @@ -80,4 +84,4 @@ export class Portkey extends ApiClient {
return new API.postMethod(this).create(url, _body, params, opts)
};

}
}

0 comments on commit 1541269

Please sign in to comment.