mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
The legacy `google-generativeai` 0.8.5 SDK (pinned by xinnan-tech) has a fixed GenerationConfig dataclass that rejects `thinking_config` both as a kwarg and inside a dict. Gemini 2.5/3.x Flash default to thinking=ON, adding 3-6 seconds of TTFT on top of the model's natural latency — fatal for voice-assistant pipelines. This rewrite swaps the engine to `google-genai` 1.67+ (already installed in the docker image alongside the legacy SDK). New API exposes `types.ThinkingConfig(thinking_budget=N)` on `GenerateContentConfig`. New cfg knob: `thinking_budget` (default 0 = off). Set to -1 for dynamic. Verified end-to-end on a live xiaozhi device (gemini-2.5-flash through this server pipeline): thinking ON -> p50 3738 ms (range 1534-6989, high variance) thinking OFF -> p50 1457 ms (range 1124-1839, tight) Caveat: gemini-2.5-flash-lite gets *worse* with thinking_budget=0 (p50 1625 -> 3048 ms, 2/9 fallbacks). The Lite variant already minimizes thinking by default; forcing 0 destabilizes it. Leave Lite at the default config. |
||
|---|---|---|
| .. | ||
| config | ||
| core | ||
| models | ||
| music | ||
| performance_tester | ||
| plugins_func | ||
| agent-base-prompt.txt | ||
| app.py | ||
| config.yaml | ||
| config_from_api.yaml | ||
| docker-compose.yml | ||
| docker-compose_all.yml | ||
| mcp_server_settings.json | ||
| performance_tester.py | ||
| requirements.txt | ||