Add LLM fallback clients, daily quota tracker and quota-board UI#6
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f567fd966e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (cmbModel_Pixtral.SelectedItem != null) | ||
| { | ||
| list.Add(new LlmCredential | ||
| { | ||
| Provider = LlmProvider.Pixtral12BLocalVllm, |
There was a problem hiding this comment.
Skip implicit local vLLM credential when not configured
This block always adds the local Pixtral credential whenever a model is selected, and Form1_Load always selects one by default, so users who only configured Mistral/Groq still hit http://127.0.0.1:8000/v1 first. If local vLLM is not running, the first request fails with a non-quota error and TranslateTextWithFallbackAsync/TranslateImageWithFallbackAsync return immediately instead of reaching later configured providers, causing translation to fail despite valid remote API keys.
Useful? React with 👍 / 👎.
|
|
||
| InitializeTrayIcon(); | ||
|
|
||
| _quotaTracker = DailyQuotaTracker.LoadOrCreate(Path.Combine(Application.StartupPath, "usage_daily.json")); |
There was a problem hiding this comment.
Persist quota data in a user-writable directory
The quota tracker file is created under Application.StartupPath, which is commonly read-only for normal users when the app is installed under Program Files. Because DailyQuotaTracker.Save() suppresses IO exceptions, quota history silently fails to persist in that environment. Using a per-user data path (for example %LocalAppData%) would avoid silent data loss.
Useful? React with 👍 / 👎.
Motivation
Description
DailyQuotaTracker.csthat records per-provider/model request counts, token usage, last error, and default daily/RPM limits and persists tousage_daily.jsonviaDailyQuotaTracker.LoadOrCreateandSave.LlmClients.cswithOpenAiCompatibleClient,LlmCredential,LlmProvider, and error policy helpers; addedTranslateTextWithFallbackAsyncandTranslateImageWithFallbackAsyncinForm1.csto try configured credentials sequentially and record results to the quota tracker.ApiKey_Pixtral,ModelName_Pixtral,ApiKey_MistralPixtral,ModelName_MistralPixtral,ApiKey_Llama4, andModelName_Llama4inForm1.Designer.cs,Properties/Settings.*, andApp.configdefaults, and wired them intoForm1load/save logic.QuotaBoardForminsideForm1.csand abtnQuotaBoardbutton to show the current day’s usage snapshot returned byDailyQuotaTracker.GetSnapshot, and added logic to persist usage on exit and on each recorded request.Form1_FormClosingnow prompts the user with choices to exit or minimize to tray before saving settings and usage.Testing
Codex Task