From 543f91b5b26a1c90aec9c25c02c043b8669b72e2 Mon Sep 17 00:00:00 2001 From: Francesc Leveque Date: Sat, 16 May 2026 23:27:23 +0200 Subject: [PATCH] Log wikidata misses + default to gemini-flash-lite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two changes to debug + sustain non-US logo discovery. ## Observability Wikidata's "provider miss" was at Debug, hidden in production's info-level logs. After yesterday's deploy of the wikidata layer, prod traces still showed the chain jumping straight from "cache miss" to "LLM provider miss" with no signal whether wikidata was being skipped (no company_name?), failing to find a Q-entity, missing a P154 claim, or 404-ing on the Commons download. Bumping the miss log to Info with the company_name field included makes the cause visible per request. ## Free-tier quota The Gemini free tier is 20 req/day per project on flash-2.5; we exhausted it on the first day of cache misses (shared quota with dividend-portfolio). Switch the default to gemini-2.5-flash-lite which has a 1000-req/day free quota. Wikidata is supposed to cover most named companies anyway, so the LLM layer is mostly long-tail fallback now — flash-lite is plenty. Co-Authored-By: Claude Opus 4.7 (1M context) --- config.example.yaml | 2 +- internal/config/config.go | 4 +++- internal/service/logo_service.go | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/config.example.yaml b/config.example.yaml index 296a859..bfd84ab 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -30,7 +30,7 @@ llm: - "openai" gemini: api_key: "" # or set LOGO_LLM_GEMINI_API_KEY env var - model: "gemini-2.5-flash" # free tier — 15 req/min + model: "gemini-2.5-flash-lite" # free tier — 1000 req/day vs flash's 20/day anthropic: api_key: "" # or set LOGO_LLM_ANTHROPIC_API_KEY env var model: "claude-sonnet-4-5-20250929" diff --git a/internal/config/config.go b/internal/config/config.go index 668c183..01972dd 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -96,7 +96,9 @@ func Load(configPath string) (*Config, error) { v.SetDefault("llm.provider_order", []string{"gemini", "anthropic", "openai"}) v.SetDefault("llm.anthropic.model", "claude-sonnet-4-5-20250929") v.SetDefault("llm.openai.model", "gpt-4o") - v.SetDefault("llm.gemini.model", "gemini-2.5-flash") + // flash-lite gets 1000 free req/day vs flash's 20 — and Wikidata covers + // the major-company case now, so LLM is mostly a long-tail fallback. + v.SetDefault("llm.gemini.model", "gemini-2.5-flash-lite") v.SetDefault("llm.rate_per_minute", 10) v.SetDefault("github.repos", []string{ "davidepalazzo/ticker-logos", diff --git a/internal/service/logo_service.go b/internal/service/logo_service.go index 5821388..89d679e 100644 --- a/internal/service/logo_service.go +++ b/internal/service/logo_service.go @@ -145,8 +145,12 @@ func (s *LogoService) acquire(ctx context.Context, symbol, companyName string) ( ) return result, nil } - s.logger.Debug("wikidata provider miss", + // Info (not Debug) so we can see in production whether Wikidata was + // even reachable for a given ticker and why it bailed (missing + // company_name vs no Q-entity vs no P154 vs download fail). + s.logger.Info("wikidata provider miss", zap.String("symbol", symbol), + zap.String("company_name", companyName), zap.Error(err), ) }