adamrushy / OpenAISwift

This is a wrapper library around the ChatGPT and OpenAI HTTP API
MIT License
1.6k stars 242 forks source link

Make completionTokens optional #68

Closed Matt54 closed 1 year ago

Matt54 commented 1 year ago

In the case where the completion returns an empty string, no completion tokens are used.

This results in a decoding error from the missing key for completion_tokens: keyNotFound(CodingKeys(stringValue: "completion_tokens", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "usage", intValue: nil)], debugDescription: "No value associated with key CodingKeys(stringValue: \"completion_tokens\", intValue: nil) (\"completion_tokens\").", underlyingError: nil))

adamrushy commented 1 year ago

Thanks for contributing 💪🏼