-
Notifications
You must be signed in to change notification settings - Fork 231
Closed
Description
Hey OpenAI team!
We're working on an OpenAI API-compatible proxy. Roughly:
user -> proxy -> openai api
To ease the maintainance burden, we'd like to import the request and response structs from this library into our proxy, specifically structs like:
type ChatCompletionNewParams struct {
// A list of messages comprising the conversation so far. Depending on the
// [model](https://platform.openai.com/docs/models) you use, different message
// types (modalities) are supported, like
// [text](https://platform.openai.com/docs/guides/text-generation),
// [images](https://platform.openai.com/docs/guides/vision), and
// [audio](https://platform.openai.com/docs/guides/audio).
Messages param.Field[[]ChatCompletionMessageParamUnion] `json:"messages,required"`
// ID of the model to use. See the
// [model endpoint compatibility](https://platform.openai.com/docs/models#model-endpoint-compatibility)
// table for details on which models work with the Chat API.
Model param.Field[ChatModel] `json:"model,required"`
// ...
}This is possible today, however when we try to unmarshal the request into those structs, we get the following error:
json: cannot unmarshal string into Go struct field ChatCompletionNewParams.model of type param.Field[string]
I believe this is because param.Field doesn't implement a json.Unmarshaler.
Would it be possible to support unmarshaling on all the request structs:
var chatRequest openai.ChatCompletionNewParams
_ := json.Unmarshal(body, &chatRequest)We'd also need marshaling on all the response structs, but I believe that's supported already!
lithammer, alejandrojnm, xunleii, akazwz, dlo and 8 more
Metadata
Metadata
Assignees
Labels
No labels