Stabilize Whisper transcription requests
Some checks failed
CI / test (push) Failing after 9s
Build and Deploy / build-and-deploy (push) Successful in 21s

This commit is contained in:
Grendgi
2026-06-11 10:16:34 +03:00
parent bc71caa762
commit b536877181
2 changed files with 8 additions and 1 deletions

View File

@@ -245,6 +245,9 @@ func (c *Client) doOpenAIAudioTranscription(ctx context.Context, provider Provid
if err := mw.WriteField("response_format", responseFormat); err != nil { if err := mw.WriteField("response_format", responseFormat); err != nil {
return nil, 0, fmt.Errorf("audio transcription response_format field: %w", err) return nil, 0, fmt.Errorf("audio transcription response_format field: %w", err)
} }
if err := mw.WriteField("temperature", "0"); err != nil {
return nil, 0, fmt.Errorf("audio transcription temperature field: %w", err)
}
if responseFormat == "verbose_json" { if responseFormat == "verbose_json" {
if err := mw.WriteField("timestamp_granularities[]", "segment"); err != nil { if err := mw.WriteField("timestamp_granularities[]", "segment"); err != nil {
return nil, 0, fmt.Errorf("audio transcription timestamp field: %w", err) return nil, 0, fmt.Errorf("audio transcription timestamp field: %w", err)

View File

@@ -28,7 +28,7 @@ func TestWhisperUsesAudioTranscriptionsEndpoint(t *testing.T) {
})) }))
defer audioSrv.Close() defer audioSrv.Close()
var gotPath, gotModel, gotResponseFormat, gotPrompt string var gotPath, gotModel, gotResponseFormat, gotPrompt, gotTemperature string
providerSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { providerSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
gotPath = r.URL.Path gotPath = r.URL.Path
if err := r.ParseMultipartForm(16 << 20); err != nil { if err := r.ParseMultipartForm(16 << 20); err != nil {
@@ -37,6 +37,7 @@ func TestWhisperUsesAudioTranscriptionsEndpoint(t *testing.T) {
gotModel = r.FormValue("model") gotModel = r.FormValue("model")
gotResponseFormat = r.FormValue("response_format") gotResponseFormat = r.FormValue("response_format")
gotPrompt = r.FormValue("prompt") gotPrompt = r.FormValue("prompt")
gotTemperature = r.FormValue("temperature")
if _, _, err := r.FormFile("file"); err != nil { if _, _, err := r.FormFile("file"); err != nil {
t.Fatalf("FormFile: %v", err) t.Fatalf("FormFile: %v", err)
} }
@@ -70,6 +71,9 @@ func TestWhisperUsesAudioTranscriptionsEndpoint(t *testing.T) {
if gotResponseFormat != "json" { if gotResponseFormat != "json" {
t.Fatalf("response_format = %q, want json", gotResponseFormat) t.Fatalf("response_format = %q, want json", gotResponseFormat)
} }
if gotTemperature != "0" {
t.Fatalf("temperature = %q, want 0", gotTemperature)
}
if gotPrompt != "" { if gotPrompt != "" {
t.Fatalf("prompt = %q, want empty", gotPrompt) t.Fatalf("prompt = %q, want empty", gotPrompt)
} }