Add Pollinations.AI image description + global max-tokens + language-aware default prompt#76
Merged
Merged
Conversation
- New provider: Pollinations.AI (gen.pollinations.ai/v1/chat/completions)
with bundled default key encrypted via existing PBKDF2-HMAC scheme.
Four selectable models with user-friendly labels: claude-fast (Claude
Haiku 4.5), openai (GPT-5.4 Nano), openai-fast (GPT-5 Nano),
openai-large (GPT-5.4). User-Agent set to curl/8.4.0 to avoid 403
from Pollinations edge layer.
- Default prompt changed to the AI Content Describer standard English
prompt. A language hint ("Respond in <Language>.") is automatically
appended based on NVDA's UI language when using the default prompt,
covering zh_TW/zh_HK → Chinese Traditional, ja → Japanese, and
many other locales.
- New global max-tokens setting (50–4000, default 700) exposed as a
SpinCtrl in the settings panel and honoured by all backends:
Google (generationConfig.maxOutputTokens), NVIDIA, and Pollinations
(max_tokens). NVIDIA previously used a hardcoded 512.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Previously adding generationConfig.maxOutputTokens with a default of 700 would silently truncate Gemini responses for users who never touched the setting. Only pass the field when getUserImageMaxTokens() returns non-None (i.e. the user has explicitly stored a custom value). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gen.pollinations.ai/v1/chat/completions(OpenAI-compatible, authenticated tier). Bundled API key is encrypted with the existing PBKDF2-HMAC scheme. Four models with friendly labels:claude-fast→ Claude Haiku 4.5,openai→ GPT-5.4 Nano,openai-fast→ GPT-5 Nano,openai-large→ GPT-5.4. Requests useUser-Agent: curl/8.4.0to avoid the 403 the Pollinations edge layer returns for Python's default UA.Respond in <Language>.) is automatically appended based on NVDA's UI language (zh_TW/zh_HK → Chinese Traditional, zh_CN → Chinese Simplified, ja → Japanese, and 20+ other locales).generationConfig.maxOutputTokens), NVIDIA, and Pollinations (max_tokens). NVIDIA previously had this hardcoded at 512.Technical notes
text.pollinations.ai/openaiis the legacy API — it only exposes one text-only model and returns 404/routing errors for authenticated users requesting models likeclaude-fast. The correct authenticated endpoint isgen.pollinations.ai/v1/chat/completions(confirmed working with live vision test).line_desktop_pollinations_api_key.dat,line_desktop_pollinations_model.txt,line_desktop_image_max_tokens.txt._nvdaLanguageHint()reads NVDA'slanguageHandler.getLanguage()and maps locale codes to English language names. Language hint is only appended when the user has not customised the prompt.Test plan
🤖 Generated with Claude Code
Greptile Summary
此 PR 新增 Pollinations.AI 圖片描述後端(OpenAI 相容端點),引入全域使用者可設定的 max-tokens SpinCtrl(50–4000,預設 700),並將預設提示語從中文改為英文加上基於 NVDA UI 語言的自動語言提示(
_nvdaLanguageHint)。User-Agent: curl/8.4.0繞過邊緣層 403 的機制。_getEffectiveImageMaxTokens()(預設 700);Google 後端沿用getUserImageMaxTokens(),僅在使用者明確設定時才送出maxOutputTokens;Ollama 後端目前未套用此設定。_getRuntimeImagePrompt()僅對預設提示語附加Respond in <Language>.,自訂提示保持不變。Confidence Score: 5/5
所有新功能均有完善的例外處理與回退機制,滞次 PR 可安全合併。
新後端遵循現有的金鑰加密與快取模式,
_geminiContentsToPollinationsMessages的 OpenAI 格式轉換邏輯正確,_nvdaLanguageHint對未知語言回傳 None 不會影響既有行為;唯一發現的小問題為_loadCurrentMaxTokens例外分支使用硬編碼常數,不影響執行期正確性。無需特別關注的檔案。
Important Files Changed
_nvdaLanguageHint()、_getRuntimeImagePrompt(),並將 Google/NVIDIA 套用全域 max-tokens 設定_loadCurrentMaxTokensexcept 分支有硬編碼 700 的細微問題Comments Outside Diff (1)
addon/appModules/line.py, line 3276-3277 (link)_callOllamaImageDescriptionApi的請求 body 未包含max_tokens欄位,但其他三個後端(Google、NVIDIA、Pollinations)都已套用_getEffectiveImageMaxTokens()。使用者在設定面板調整最大 Token 後切換到 Ollama,輸出長度不受控制。Ollama/api/chat支援options.num_predict來限制輸出,或可在 body 最上層傳入num_predict,視服務端版本而定。Prompt To Fix With AI
Prompt To Fix All With AI
Reviews (2): Last reviewed commit: "Fix Google backend: only send maxOutputT..." | Re-trigger Greptile