From d52f0865e3ec0a8e7e15c5a4ff3f3bfffa578f36 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Tue, 18 Jun 2024 17:15:21 +0530 Subject: [PATCH] feat: request-timeout header supported --- src/_types/generalTypes.ts | 1 + src/baseClient.ts | 4 ++-- src/client.ts | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/_types/generalTypes.ts b/src/_types/generalTypes.ts index 6e2683f..b2359bc 100644 --- a/src/_types/generalTypes.ts +++ b/src/_types/generalTypes.ts @@ -26,6 +26,7 @@ export interface ApiClientInterface { azureApiVersion?: string | null | undefined; forwardHeaders?: Array | null | undefined; cacheNamespace?: string | null | undefined; + requestTimeout?: number | null | undefined; } export interface APIResponseType { diff --git a/src/baseClient.ts b/src/baseClient.ts index ef4f0d9..bf1630d 100644 --- a/src/baseClient.ts +++ b/src/baseClient.ts @@ -120,10 +120,10 @@ export abstract class ApiClient { portkeyHeaders: Record 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, forwardHeaders, cacheNamespace }: 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, forwardHeaders, cacheNamespace, requestTimeout }: 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, forwardHeaders }) + 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, forwardHeaders, requestTimeout }) this.portkeyHeaders = this.defaultHeaders() this.fetch = fetch; this.responseHeaders = {} diff --git a/src/client.ts b/src/client.ts index b8221fa..5d8dfa6 100644 --- a/src/client.ts +++ b/src/client.ts @@ -30,6 +30,7 @@ export class Portkey extends ApiClient { azureDeploymentId?: string | null | undefined; azureApiVersion?: string | null | undefined; forwardHeaders?: Array | null | undefined; + requestTimeout? : number | null | undefined; cacheNamespace?: string | null | undefined; constructor({ @@ -58,6 +59,7 @@ export class Portkey extends ApiClient { azureApiVersion, forwardHeaders, cacheNamespace, + requestTimeout, }: ApiClientInterface) { super({ @@ -86,6 +88,7 @@ export class Portkey extends ApiClient { azureDeploymentId, azureApiVersion, forwardHeaders, + requestTimeout, }); this.apiKey = apiKey; @@ -115,6 +118,7 @@ export class Portkey extends ApiClient { this.azureDeploymentId = azureDeploymentId; this.azureApiVersion = azureApiVersion; this.forwardHeaders = forwardHeaders; + this.requestTimeout = requestTimeout; } completions: API.Completions = new API.Completions(this);