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(basePath): enable base path for configuration #69

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

/// Optional base path if you set up OpenAI API proxy on a custom path on your own host. Default is ""
public let basePath: String?
metrue marked this conversation as resolved.
Show resolved Hide resolved

/// Default request timeout
public let timeoutInterval: TimeInterval

public init(token: String, organizationIdentifier: String? = nil, host: String = "api.openai.com", timeoutInterval: TimeInterval = 60.0) {
public init(token: String, organizationIdentifier: String? = nil, host: String = "api.openai.com", basePath: String? = nil, timeoutInterval: TimeInterval = 60.0) {
metrue marked this conversation as resolved.
Show resolved Hide resolved
self.token = token
self.organizationIdentifier = organizationIdentifier
self.host = host
self.basePath = basePath
self.timeoutInterval = timeoutInterval
}
}
Expand Down Expand Up @@ -171,7 +175,7 @@ extension OpenAI {
var components = URLComponents()
components.scheme = "https"
components.host = configuration.host
components.path = path
components.path = (configuration.basePath ?? "") + path
metrue marked this conversation as resolved.
Show resolved Hide resolved
return components.url!
}
}
Expand Down