From b53687718168901c2b72b04e0524261c70e89450 Mon Sep 17 00:00:00 2001 From: Grendgi Date: Thu, 11 Jun 2026 10:16:34 +0300 Subject: [PATCH] Stabilize Whisper transcription requests --- internal/transcription/client.go | 3 +++ internal/transcription/client_test.go | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/transcription/client.go b/internal/transcription/client.go index 82e9a13..0e84a9c 100644 --- a/internal/transcription/client.go +++ b/internal/transcription/client.go @@ -245,6 +245,9 @@ func (c *Client) doOpenAIAudioTranscription(ctx context.Context, provider Provid if err := mw.WriteField("response_format", responseFormat); err != nil { 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 err := mw.WriteField("timestamp_granularities[]", "segment"); err != nil { return nil, 0, fmt.Errorf("audio transcription timestamp field: %w", err) diff --git a/internal/transcription/client_test.go b/internal/transcription/client_test.go index 9a2f6d0..e6bd8d2 100644 --- a/internal/transcription/client_test.go +++ b/internal/transcription/client_test.go @@ -28,7 +28,7 @@ func TestWhisperUsesAudioTranscriptionsEndpoint(t *testing.T) { })) 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) { gotPath = r.URL.Path if err := r.ParseMultipartForm(16 << 20); err != nil { @@ -37,6 +37,7 @@ func TestWhisperUsesAudioTranscriptionsEndpoint(t *testing.T) { gotModel = r.FormValue("model") gotResponseFormat = r.FormValue("response_format") gotPrompt = r.FormValue("prompt") + gotTemperature = r.FormValue("temperature") if _, _, err := r.FormFile("file"); err != nil { t.Fatalf("FormFile: %v", err) } @@ -70,6 +71,9 @@ func TestWhisperUsesAudioTranscriptionsEndpoint(t *testing.T) { if gotResponseFormat != "json" { t.Fatalf("response_format = %q, want json", gotResponseFormat) } + if gotTemperature != "0" { + t.Fatalf("temperature = %q, want 0", gotTemperature) + } if gotPrompt != "" { t.Fatalf("prompt = %q, want empty", gotPrompt) }