Support Openai structure output api (#feat 1214) (#1217)

Co-authored-by: Kent Dong <ch3cho@qq.com>
This commit is contained in:
Yang Beining
2024-08-22 12:33:35 +08:00
committed by GitHub
parent bdbfad8a8a
commit 0e58042fa6
4 changed files with 16 additions and 0 deletions

View File

@@ -89,6 +89,10 @@ func (m *openaiProvider) OnRequestBody(ctx wrapper.HttpContext, apiName ApiName,
if err := decodeChatCompletionRequest(body, request); err != nil {
return types.ActionContinue, err
}
if m.config.responseJsonSchema != nil {
log.Debugf("[ai-proxy] set response format to %s", m.config.responseJsonSchema)
request.ResponseFormat = m.config.responseJsonSchema
}
if request.Stream {
// For stream requests, we need to include usage in the response.
if request.StreamOptions == nil {