Skip to content

Commit

Permalink
Fixed a bug where streaming would not be enabled where needed
Browse files Browse the repository at this point in the history
  • Loading branch information
SwiftedMind committed May 11, 2023
1 parent 534b178 commit c90d3fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/ChatGPT/ChatGPT+StreamedAnswer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ extension ChatGPT {
/// - Throws: A `GPTSwiftError`.
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
public func ask(request chatRequest: ChatRequest) async throws -> AsyncThrowingStream<String, Swift.Error> {

var chatRequest = chatRequest
chatRequest.stream = true

let request = Request(path: API.v1ChatCompletion, method: .post, body: chatRequest)
var urlRequest = try await client.makeURLRequest(for: request)
_addHeaders(to: &urlRequest, apiKey: apiKey)
Expand Down
4 changes: 4 additions & 0 deletions Sources/GPT/GPT+StreamedAnswer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ extension GPT {
/// - Throws: A `Swift.Error` if the request fails or the server returns an unauthorized status code.
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
public func complete(request completionRequest: CompletionRequest) async throws -> AsyncThrowingStream<String, Swift.Error> {

var completionRequest = completionRequest
completionRequest.stream = true

let request = Request(path: API.v1Completion, method: .post, body: completionRequest)
var urlRequest = try await client.makeURLRequest(for: request)
_addHeaders(to: &urlRequest, apiKey: apiKey)
Expand Down

0 comments on commit c90d3fc

Please sign in to comment.