Feat Add headers to openai responses (#506)

* feat: add headers to http response

* chore: add test

* fix: rename to httpHeader
This commit is contained in:
Simone Vellei
2023-10-09 17:41:54 +02:00
committed by GitHub
parent 533935e4fc
commit 8e165dc9aa
14 changed files with 107 additions and 2 deletions

View File

@@ -63,6 +63,21 @@ type AudioResponse struct {
Transient bool `json:"transient"`
} `json:"segments"`
Text string `json:"text"`
httpHeader
}
type audioTextResponse struct {
Text string `json:"text"`
httpHeader
}
func (r *audioTextResponse) ToAudioResponse() AudioResponse {
return AudioResponse{
Text: r.Text,
httpHeader: r.httpHeader,
}
}
// CreateTranscription — API call to create a transcription. Returns transcribed text.
@@ -104,7 +119,9 @@ func (c *Client) callAudioAPI(
if request.HasJSONResponse() {
err = c.sendRequest(req, &response)
} else {
err = c.sendRequest(req, &response.Text)
var textResponse audioTextResponse
err = c.sendRequest(req, &textResponse)
response = textResponse.ToAudioResponse()
}
if err != nil {
return AudioResponse{}, err