Skip to content

Error on streamComletions if configuration has maxTokens #1

Description

@DobbyWanKenoby

Next code will be throw when configuration has maxTokens

let chat = OpenAI.Chat(model: \.gpt_4o_mini,
                               apiKey: .apiKey(Config.apiKey))
var configuration = chat.ConfigurationType.init()
configuration.maxTokens = 5
let stream = try await chat.streamCompletions(promt: "Please tell me about Space!", configuration: configuration)
for try await line in stream {
    print(line)
}

The reason because answer is [DONE], not valid JSON, and

.asDecodedServerSentEventsWithJSONData(
    of: Components.Schemas.CreateChatCompletionStreamResponse.self
)

cant decode it correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions