Closed nallwhy closed 4 days ago
Looks like they changed the format slightly, there’s now a OneOf type for 2 different components 😅
Need to add handling for that
Culprit:
ChatCompletionRequestMessageContentPart:
oneOf:
- $ref: "#/components/schemas/ChatCompletionRequestMessageContentPartText"
- $ref: "#/components/schemas/ChatCompletionRequestMessageContentPartImage"
x-oaiExpandable: true
and
ChatCompletionRequestMessage:
oneOf:
- $ref: "#/components/schemas/ChatCompletionRequestSystemMessage"
- $ref: "#/components/schemas/ChatCompletionRequestUserMessage"
- $ref: "#/components/schemas/ChatCompletionRequestAssistantMessage"
- $ref: "#/components/schemas/ChatCompletionRequestToolMessage"
- $ref: "#/components/schemas/ChatCompletionRequestFunctionMessage"
x-oaiExpandable: true
So this is a component that can be oneOf many different components. Need to figure out a good way to represent those
Hrrmmm so the issue here is that those new components aren't representable as structs in Elixir. Previously each of those had properties so it was easy. What we could do is, represent them as empty structs (%{}
), but then use the @type to map them to the others, like this:
iex(3)> t ExOpenAI.Components.ChatCompletionRequestMessage
@type t() ::
ExOpenAI.Components.ChatCompletionRequestFunctionMessage.t()
| ExOpenAI.Components.ChatCompletionRequestToolMessage.t()
| ExOpenAI.Components.ChatCompletionRequestAssistantMessage.t()
| ExOpenAI.Components.ChatCompletionRequestUserMessage.t()
| ExOpenAI.Components.ChatCompletionRequestSystemMessage.t()
Then when a function references them, it would do ExOpenAI.Components.ChatCompletionRequestMessage.t()
which maps to the others
Done, please give latest HEAD a try. It changes component handling a bit so I don't want to release it immediately, need to test a bit
https://github.com/openai/openai-openapi/blob/master/openapi.yaml