Skip to content

Commit

Permalink
Path prefix to proxy config added (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
ftp27 committed Jun 15, 2023
1 parent b26111a commit bf4e816
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Sources/OpenAIKit/API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import Foundation
public struct API {
public let scheme: Scheme
public let host: String
public let path: String?

public init(
scheme: API.Scheme,
host: String
host: String,
pathPrefix path: String? = nil
) {
self.scheme = scheme
self.host = host
self.path = path
}
}

Expand Down
4 changes: 3 additions & 1 deletion Sources/OpenAIKit/RequestHandler/RequestHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ extension RequestHandler {
var components = URLComponents()
components.scheme = configuration.api?.scheme.value ?? request.scheme.value
components.host = configuration.api?.host ?? request.host
components.path = request.path
components.path = [configuration.api?.path, request.path]
.compactMap { $0 }
.joined()

guard let url = components.url else {
throw RequestHandlerError.invalidURLGenerated
Expand Down

0 comments on commit bf4e816

Please sign in to comment.