Skip to content

Commit

Permalink
add scheme, host, and port for buildURL
Browse files Browse the repository at this point in the history
  • Loading branch information
JavadFaghih committed Mar 9, 2024
1 parent f1c05f5 commit 71f7ca1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Sources/OpenAI/OpenAI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ 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 scheme: String
/// 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", port: Int = 443, scheme: String = "https", timeoutInterval: TimeInterval = 60.0) {
self.token = token
self.organizationIdentifier = organizationIdentifier
self.host = host
self.port = port
self.scheme = scheme
self.timeoutInterval = timeoutInterval
}
}
Expand Down Expand Up @@ -196,8 +199,9 @@ extension OpenAI {

func buildURL(path: String) -> URL {
var components = URLComponents()
components.scheme = "https"
components.scheme = configuration.scheme
components.host = configuration.host
components.port = configuration.port
components.path = path
return components.url!
}
Expand Down

0 comments on commit 71f7ca1

Please sign in to comment.