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

Add pathPrefix to Configuration #190

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions Sources/OpenAI/OpenAI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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!
}
}
Expand Down