圖片描述功能調整:Token 無限制預設、API Key 遮蔽、新增 Pollinations 模型#77
Merged
Conversation
1. Token 限制改為預設無限制:新增「限制圖片描述最大 Token」checkbox, 未勾選時不向 API 傳送 max_tokens(Google/NVIDIA/Pollinations 三個 backend 皆適用)。移除已無用的 _getEffectiveImageMaxTokens 快取函式。 2. API Key 欄位改為密碼模式:預設以 wx.TE_PASSWORD 遮蔽,旁邊新增 「顯示 API 金鑰」checkbox,勾選後透過 sizer.Replace() 換成明文控制項。 3. Pollinations.AI 新增 10 個模型: mistral / llama-scout / gemini-fast / qwen-vision / gemini-search / grok / kimi / mistral-large / qwen-large / kimi-k2.6 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Check sizer.Replace() return value; destroy orphaned newCtrl and bail if the replacement fails, so the existing field is never lost. - Rename _userMaxTokens -> userMaxTokens in all three API backends (Google, NVIDIA, Pollinations) — underscore prefix implies module-private in Python convention, not appropriate for a local variable. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Owner
Author
|
Re: sizer.Replace() return value (P1) — Fixed: check the return value; if False, destroy the orphaned newCtrl and return early so the existing field is never lost. Re: _userMaxTokens naming (P2) — Fixed: renamed to userMaxTokens in all three backends (Google, NVIDIA, Pollinations). |
The sizer.Replace approach caused the field to move and lose its label.
Replace with Win32 EM_SETPASSWORDCHAR message: wParam=0 shows plain text,
wParam=ord('*') re-enables masking. The TextCtrl stays in its original
position and retains its label — no sizer manipulation needed.
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
Token 限制改為預設無限制:新增「限制圖片描述最大 Token (&L)」checkbox。預設不勾選時,三個 backend(Google / NVIDIA / Pollinations)皆不向 API 傳送
max_tokens/maxOutputTokens參數,讓模型自由輸出。勾選後 SpinCtrl 啟用可自行調整數值。同步移除已無用的_getEffectiveImageMaxTokens快取函式與相關_cachedEffectiveImageMaxTokens全域變數。API Key 欄位改為密碼模式:
wx.TextCtrl預設加上wx.TE_PASSWORD樣式遮蔽內容,避免旁人窺視。旁邊新增「顯示 API 金鑰 (&S)」checkbox,勾選後透過sizer.Replace()將控制項換成不帶遮罩的新wx.TextCtrl(wxPython 無法熱切換 TE_PASSWORD 旗標),並保留游標位置與焦點。Pollinations.AI 新增 10 個模型:
mistralllama-scoutgemini-fastqwen-visiongemini-searchgrokkimimistral-largeqwen-largekimi-k2.6Test plan
pytest確認全部測試通過🤖 Generated with Claude Code
Greptile Summary
此 PR 在圖片描述功能上做了三項獨立調整:Token 上限預設改為無限制(需勾選 checkbox 才啟用)、API Key 欄位預設遮蔽並以 Win32
EM_SETPASSWORDCHAR實作顯示切換、以及新增 10 個 Pollinations.AI 模型。_getEffectiveImageMaxTokens快取函式與_cachedEffectiveImageMaxTokens全域變數,改由各後端直接呼叫getUserImageMaxTokens()並在回傳None時省略max_tokens參數;UI 端以 checkbox 控制是否傳送限制值,邏輯一致。ctypes.windll.user32.SendMessageW傳送EM_SETPASSWORDCHAR訊息切換遮蔽狀態,避免 sizer 重排;ctypes已在檔案頂部 import,Win32 常數值正確(0x00CC)。_IMAGE_DESCRIPTION_POLLINATIONS_AVAILABLE_MODELStuple 與_IMAGE_DESCRIPTION_POLLINATIONS_MODEL_LABELSdict,且下拉選單的 label 產生邏輯(.get(mid, mid))能正確 fallback,無遺漏。Confidence Score: 5/5
此 PR 三項改動邏輯均正確且一致,無資料遺失或邊界條件問題,可安全合併。
Token 限制的 checkbox 邏輯、None 判斷與 setUserImageMaxTokens 的行為完全匹配;EM_SETPASSWORDCHAR 透過 ctypes 切換遮蔽狀態的實作方式在 Windows 上正確可靠;新增的 10 個 Pollinations 模型已同步更新 tuple 與 labels dict,下拉選單 fallback 邏輯也能處理潛在缺漏。整體變更範圍明確,未破壞既有功能。
兩個檔案均無需特別關注。
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[使用者開啟設定面板] --> B[API Key TextCtrl\nwx.TE_PASSWORD 建立] B --> C{勾選「顯示 API 金鑰」?} C -- 是 --> D[SendMessageW\nEM_SETPASSWORDCHAR wParam=0\n顯示明文] C -- 否 --> E[SendMessageW\nEM_SETPASSWORDCHAR wParam=ord★\n遮蔽顯示] D --> F[Refresh 重繪] E --> F G[使用者開啟設定面板] --> H{勾選「限制最大 Token」?} H -- 是 --> I[SpinCtrl 啟用\n讀取 getUserImageMaxTokens] H -- 否 --> J[SpinCtrl 停用\nnewMaxTokens = None] K[onSave] --> L{_limitTokensCheck?} L -- 勾選 --> M[newMaxTokens = SpinCtrl.GetValue\nsetUserImageMaxTokens n] L -- 未勾選 --> N[setUserImageMaxTokens None\n清除 max_tokens 檔案] O[API 呼叫] --> P[getUserImageMaxTokens] P --> Q{回傳值?} Q -- None --> R[不傳送 max_tokens\n讓模型自由輸出] Q -- 整數 --> S[加入 max_tokens / maxOutputTokens\n至 request body]Reviews (3): Last reviewed commit: "Fix API key show/hide: use EM_SETPASSWOR..." | Re-trigger Greptile