Skip to content

Commit

Permalink
Merge pull request #117 from Portkey-AI/feat/providerHeaders
Browse files Browse the repository at this point in the history
Provider Headers (azure, anthropic and mistral)
  • Loading branch information
VisargD authored Oct 9, 2024
2 parents 6546f47 + 461aecb commit 0f1c976
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
Binary file removed speech.mp3
Binary file not shown.
3 changes: 3 additions & 0 deletions src/_types/generalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ export interface ApiClientInterface {
azureResourceName?: string | null | undefined;
azureDeploymentId?: string | null | undefined;
azureApiVersion?: string | null | undefined;
azureEndpointName?: string | null | undefined;
huggingfaceBaseUrl?: string | null | undefined;
forwardHeaders?: Array<string> | null | undefined;
cacheNamespace?: string | null | undefined;
requestTimeout?: number | null | undefined;
strictOpenAiCompliance?: boolean | null | undefined;
anthropicBeta?: string | null | undefined;
anthropicVersion?: string | null | undefined;
mistralFimCompletion?: 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, openaiProject, openaiOrganization, awsSecretAccessKey, awsAccessKeyId, awsSessionToken, awsRegion, vertexProjectId, vertexRegion, workersAiAccountId, azureResourceName, azureDeploymentId, azureApiVersion, huggingfaceBaseUrl, forwardHeaders, cacheNamespace, requestTimeout, strictOpenAiCompliance, anthropicBeta }: ApiClientInterface) {
constructor({ apiKey, baseURL, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost, openaiProject, openaiOrganization, awsSecretAccessKey, awsAccessKeyId, awsSessionToken, awsRegion, vertexProjectId, vertexRegion, workersAiAccountId, azureResourceName, azureDeploymentId, azureApiVersion, azureEndpointName, huggingfaceBaseUrl, forwardHeaders, cacheNamespace, requestTimeout, strictOpenAiCompliance, anthropicBeta, anthropicVersion, mistralFimCompletion }: ApiClientInterface) {
this.apiKey = apiKey ?? "";
this.baseURL = baseURL ?? "";
this.customHeaders = createHeaders({ apiKey, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost, cacheNamespace, openaiProject, openaiOrganization, awsSecretAccessKey, awsAccessKeyId, awsSessionToken, awsRegion, vertexProjectId, vertexRegion, workersAiAccountId, azureResourceName, azureDeploymentId, azureApiVersion, huggingfaceBaseUrl, forwardHeaders, requestTimeout, strictOpenAiCompliance, anthropicBeta })
this.customHeaders = createHeaders({ apiKey, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost, cacheNamespace, openaiProject, openaiOrganization, awsSecretAccessKey, awsAccessKeyId, awsSessionToken, awsRegion, vertexProjectId, vertexRegion, workersAiAccountId, azureResourceName, azureDeploymentId, azureApiVersion, azureEndpointName, huggingfaceBaseUrl, forwardHeaders, requestTimeout, strictOpenAiCompliance, anthropicBeta, anthropicVersion, mistralFimCompletion })
this.portkeyHeaders = this.defaultHeaders()
this.fetch = fetch;
this.responseHeaders = {}
Expand Down
12 changes: 12 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ export class Portkey extends ApiClient {
azureResourceName?: string | null | undefined;
azureDeploymentId?: string | null | undefined;
azureApiVersion?: string | null | undefined;
azureEndpointName?: string | null | undefined;
huggingfaceBaseUrl?: string | null | undefined;
forwardHeaders?: Array<string> | null | undefined;
requestTimeout?: number | null | undefined;
cacheNamespace?: string | null | undefined;
strictOpenAiCompliance?: boolean | null | undefined;
anthropicBeta?: string | null | undefined;
anthropicVersion?: string | null | undefined;
mistralFimCompletion?: string | null | undefined;
constructor({
apiKey = readEnv("PORTKEY_API_KEY") ?? null,
baseURL = readEnv("PORTKEY_BASE_URL") ?? null,
Expand All @@ -60,12 +63,15 @@ export class Portkey extends ApiClient {
azureResourceName,
azureDeploymentId,
azureApiVersion,
azureEndpointName,
huggingfaceBaseUrl,
forwardHeaders,
cacheNamespace,
requestTimeout,
strictOpenAiCompliance,
anthropicBeta,
anthropicVersion,
mistralFimCompletion
}: ApiClientInterface) {

super({
Expand Down Expand Up @@ -93,11 +99,14 @@ export class Portkey extends ApiClient {
azureResourceName,
azureDeploymentId,
azureApiVersion,
azureEndpointName,
huggingfaceBaseUrl,
forwardHeaders,
requestTimeout,
strictOpenAiCompliance,
anthropicBeta,
anthropicVersion,
mistralFimCompletion
});

this.apiKey = apiKey;
Expand Down Expand Up @@ -126,11 +135,14 @@ export class Portkey extends ApiClient {
this.azureResourceName = azureResourceName;
this.azureDeploymentId = azureDeploymentId;
this.azureApiVersion = azureApiVersion;
this.azureEndpointName = azureEndpointName;
this.huggingfaceBaseUrl = huggingfaceBaseUrl;
this.forwardHeaders = forwardHeaders;
this.requestTimeout = requestTimeout;
this.strictOpenAiCompliance = strictOpenAiCompliance;
this.anthropicBeta = anthropicBeta;
this.anthropicVersion = anthropicVersion;
this.mistralFimCompletion = mistralFimCompletion;
}

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

0 comments on commit 0f1c976

Please sign in to comment.