diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-03 10:55:52 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-03 10:55:52 +0300 |
| commit | 642373f59b2bf4c650267eacba8043464f77397e (patch) | |
| tree | fb0e916693871a038c9686a0ea44761e6fc62795 | |
| parent | 387ced77126db28ed205868543119768be2e61b3 (diff) | |
fix: disable Gemini thinking for phonetic IPA lookup
Gemini 2.5 Flash runs internal reasoning by default. Those thinking tokens
count against MaxOutputTokens, leaving almost no budget for the actual IPA
output — hence the truncated [ˈɡlɛdɐm with no closing bracket.
Set ThinkingBudget=0 in ThinkingConfig so all 200 output tokens are reserved
for the IPA transcription itself. A simple dictionary-style lookup needs no
chain-of-thought reasoning.
Also included: audio_player layout fix (NewBorder center + TextWrapWord) so
long IPA strings are not clipped in the GUI bar.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rw-r--r-- | internal/phonetic/fetcher.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/internal/phonetic/fetcher.go b/internal/phonetic/fetcher.go index 04db171..7856ac7 100644 --- a/internal/phonetic/fetcher.go +++ b/internal/phonetic/fetcher.go @@ -91,6 +91,8 @@ var fetchOpenAIPhonetic = func(ctx context.Context, client *openai.Client, word var fetchGeminiPhonetic = func(ctx context.Context, client *genai.Client, word string) (string, error) { temp := float32(phoneticTemperature) + thinkingBudget := int32(0) // IPA lookup needs no reasoning; disable thinking so + // it doesn't consume MaxOutputTokens before any visible text is emitted. resp, err := client.Models.GenerateContent(ctx, defaultGeminiModel, []*genai.Content{ genai.NewContentFromText(buildGeminiPhoneticPrompt(word), genai.RoleUser), }, &genai.GenerateContentConfig{ @@ -99,6 +101,7 @@ var fetchGeminiPhonetic = func(ctx context.Context, client *genai.Client, word s }, Temperature: &temp, MaxOutputTokens: phoneticMaxTokens, + ThinkingConfig: &genai.ThinkingConfig{ThinkingBudget: &thinkingBudget}, }) if err != nil { return "", fmt.Errorf("gemini API error: %w", err) |
