Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added support for cacheNamespace header #76

Merged
merged 1 commit into from
Jun 18, 2024
Merged
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
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
Loading