Skip to content

Commit

Permalink
feat: added support for cacheNamespace header
Browse files Browse the repository at this point in the history
  • Loading branch information
csgulati09 committed May 14, 2024
1 parent 2ad6b09 commit 5bce85d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/_types/generalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface ApiClientInterface {
cacheForceRefresh?: boolean | null | undefined;
debug?: boolean | null | undefined;
customHost?: string | null | undefined
cacheNamespace?: string | null | undefined;
}

export interface APIResponseType {
Expand Down
4 changes: 2 additions & 2 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, customHost }: ApiClientInterface) {
constructor({ apiKey, baseURL, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost, cacheNamespace }: ApiClientInterface) {
this.apiKey = apiKey ?? "";
this.baseURL = baseURL ?? "";
this.customHeaders = createHeaders({ apiKey, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost })
this.customHeaders = createHeaders({ apiKey, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost, cacheNamespace })
this.portkeyHeaders = this.defaultHeaders()
this.fetch = fetch;
this.responseHeaders = {}
Expand Down
8 changes: 6 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class Portkey extends ApiClient {
cacheForceRefresh?: boolean | null | undefined;
debug?: boolean | null | undefined;
customHost?: string | null | undefined;
cacheNamespace?: string | null | undefined;
constructor({
apiKey = readEnv("PORTKEY_API_KEY") ?? null,
baseURL = readEnv("PORTKEY_BASE_URL") ?? null,
Expand All @@ -29,6 +30,7 @@ export class Portkey extends ApiClient {
cacheForceRefresh,
debug,
customHost,
cacheNamespace,
}: ApiClientInterface) {

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

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

completions: API.Completions = new API.Completions(this);
Expand Down

0 comments on commit 5bce85d

Please sign in to comment.