What's Changed
- Making properties on Chat completions optionals. by @jamesrochabrun in #122
Following suggestions from API's that handles many providers, SwiftOpenAI makes now all properties for completions optional. This will make this library more friendly to different providers.
_> Decodables should all have optional properties. Why? We don't want to fail decoding in live apps if the provider changes something out from under us (which can happen purposefully due to deprecations, or by accident due to regressions). If we use non-optionals in decodable definitions, then a provider removing a field, changing the type of a field, or removing an enum case would cause decoding to fail.
You may think this isn't too bad, since the JSONDecoder throws anyway, and therefore client code will already be wrapped in a do/catch. However, we always want to give the best chance that decodable succeeds for the properties that the client actually uses. That is, if the provider changes out the enum case of a property unused by the client, we want the client application to continue functioning correctly, not to throw an error and enter the catch branch of the client's call site._
Full Changelog: v4.0.2...v4.0.3