From f14c17a87cdc2c328970319eda6076e4ca3e426b Mon Sep 17 00:00:00 2001 From: Dmitrii Medvedev Date: Tue, 2 Apr 2024 15:39:52 +0300 Subject: [PATCH] Add pathPrefix to Configuration --- Sources/OpenAI/OpenAI.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/OpenAI/OpenAI.swift b/Sources/OpenAI/OpenAI.swift index 5ff52833..21015735 100644 --- a/Sources/OpenAI/OpenAI.swift +++ b/Sources/OpenAI/OpenAI.swift @@ -23,16 +23,18 @@ final public class OpenAI: OpenAIProtocol { /// API host. Set this property if you use some kind of proxy or your own server. Default is api.openai.com public let host: String public let port: Int + public let pathPrefix: String public let scheme: String /// Default request timeout public let timeoutInterval: TimeInterval - public init(token: String, organizationIdentifier: String? = nil, host: String = "api.openai.com", port: Int = 443, scheme: String = "https", timeoutInterval: TimeInterval = 60.0) { + public init(token: String, organizationIdentifier: String? = nil, host: String = "api.openai.com", port: Int = 443, pathPrefix: String = "", scheme: String = "https", timeoutInterval: TimeInterval = 60.0) { self.token = token self.organizationIdentifier = organizationIdentifier self.host = host self.port = port self.scheme = scheme + self.pathPrefix = pathPrefix self.timeoutInterval = timeoutInterval } } @@ -202,7 +204,7 @@ extension OpenAI { components.scheme = configuration.scheme components.host = configuration.host components.port = configuration.port - components.path = path + components.path = configuration.pathPrefix + path return components.url! } }