Skip to content

Commit

Permalink
Merge pull request #54 from DJBen/public-session
Browse files Browse the repository at this point in the history
#50 Make a few session-related types and initializers public
  • Loading branch information
Krivoblotsky authored Apr 20, 2023
2 parents 9808943 + 8d7cd66 commit eb7f440
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Sources/OpenAI/OpenAI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ final public class OpenAI: OpenAIProtocol {
public convenience init(configuration: Configuration) {
self.init(configuration: configuration, session: URLSession.shared)
}
init(configuration: Configuration, session: URLSessionProtocol = URLSession.shared) {

init(configuration: Configuration, session: URLSessionProtocol) {
self.configuration = configuration
self.session = session
}

public convenience init(configuration: Configuration, session: URLSession = URLSession.shared) {
self.init(configuration: configuration, session: session as URLSessionProtocol)
}

public func completions(query: CompletionsQuery, completion: @escaping (Result<CompletionsResult, Error>) -> Void) {
performRequest(request: JSONRequest<CompletionsResult>(body: query, url: buildURL(path: .completions)), completion: completion)
Expand Down

0 comments on commit eb7f440

Please sign in to comment.