Skip to content

Missing response struct types for batch requests #951

Open
@pjuhasz

Description

@pjuhasz

The support for batch requests is incomplete. Specifically, the OpenAI API reference specifies that the output files containing the results of the batched operations contain request output objects in the format described here: https://platform.openai.com/docs/api-reference/batch/request-output

However, the struct types corresponding to these objects are missing from this library.

Draft solution

type BatchRequestOutputError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type BatchRequestChatCompletionResponse struct {
	StatusCode int                     `json:"status_code"`
	RequestId  string                  `json:"request_id"`
	Body       ChatCompletionResponse  `json:"body"`
}

type BatchRequestChatCompletionOutput {
	Id       string                               `json:"id"`
	CustomId string                               `json:"custom_id"`
	Response *BatchRequestChatCompletionResponse  `json:"response"`
	Error    *BatchRequestOutputError             `json:"error"` 
}

and similarly for any other supported batch request types.

Alternatively, these wrapper types could be implemented with generics (they were invented for this, after all), but AFAIK generics are not used elsewhere in the project, so you may not want to introduce them for such a trivial addition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions