-
-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add explicit codable implementation to ChatMessage and new OpenAIEndpointModelType #107
base: main
Are you sure you want to change the base?
Conversation
Fixes adamrushy#100 `sendChat is failing because ChatMessage has extra property`
@adamrushy any idea when you may get the opportunity to review and merge this? 😄 |
The current model enum and methods that have models as parameters could easily cause errors as any model could be chosen for any of those methods. By adding the new `OpenAIEndpointModel` type that corresponds to the compatibility list in the OpenAI docs, it’s much easier to select the fitting model. The new type does contain duplicate model strings, which is intended to make it easier to maintain. Backward compatibility is assured by marking the previous methods as deprecated. https://platform.openai.com/docs/models/model-endpoint-compatibility
case content | ||
} | ||
|
||
public init(from decoder: Decoder) throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marcoboerner I may be missing something, but I don't think this is needed. Specifying CodingKeys
should be sufficient. I have a fork with a commit here that fixes this issue.
(Same goes for encode()
method below.)
For what it's worth I'll open up a PR with the "one line" solution that only solves the reported problem (maybe that'll get merged sooner?).
That said the other changes you made are also useful...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...nevermind, I won't open a PR because I see there are several already. :)
Fixes #100
Add explicit codable implementation to ChatMessage
without removing theIdentifiable
conformance by implementing an explicit codable implementation that ignores theid
property when encoding, and creates a new UUID when decoding.This should fix the regular chat and streaming chat as both have not been working with the encoded
id
.I've also added a new
OpenAIEndpointModelType
with the currently available OpenAI models, to replace theOpenAIModelType
. The currentOpenAIModelType
model enum and methods that have models as parameters could easily cause errors as any model could be chosen for any of those methods. By adding the newOpenAIEndpointModel
type that corresponds to the compatibility list in the OpenAI docs, it’s much easier to select the fitting model.The new type does contain duplicate model strings, which is intended to make it easier to maintain.
Backward compatibility is assured by marking the previous methods as deprecated. and using the old methods as wrappers around the new methods.