You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for multiple LLM backends (local vLLM Pixtral, Mistral Pixtral, Groq Llama4 and Gemini) and allow automatic fallback between configured credentials.
Track and persist daily usage and simple rate limits so users can view per-engine consumption and identify quota/rate-limit failures.
Description
Introduce LlmClients.cs with LlmProvider, LlmCredential, OpenAiCompatibleClient, and LlmErrorPolicy to call OpenAI-compatible endpoints and unify text/image requests.
Add DailyQuotaTracker.cs to persist daily usage to usage_daily.json, provide defaults for common models, and expose snapshot/recording APIs.
Extend the main form (Form1.cs and Form1.Designer.cs) to add API key/model fields for Pixtral, Mistral Pixtral and Llama4, implement BuildLlmCredentials(), fallback methods TranslateTextWithFallbackAsync() and TranslateImageWithFallbackAsync(), and wire quota recording and saving.
Add a simple QuotaBoardForm embedded in Form1.cs to visualize today's per-engine usage and a toolbar button btnQuotaBoard to open it.
Persist new settings by adding properties in Properties/Settings.* and update App.config defaults for the new keys.
Update project file to include the new source files (LlmClients.cs, DailyQuotaTracker.cs) and include UI/behaviour changes like a close-confirmation dialog.
Testing
No automated tests were added or executed for this change.
Skip local Pixtral credential unless explicitly configured
BuildLlmCredentials() unconditionally adds the local vLLM Pixtral endpoint whenever cmbModel_Pixtral has a selected item, and Form1_Load always selects one by default. That means users who only configured cloud keys still get http://127.0.0.1:8000/v1 inserted into the fallback chain; when that local server is absent, Translate*WithFallbackAsync() returns this non-quota failure immediately and never reaches later configured providers. Gate this credential behind explicit user intent/configuration so fallback can reach actually configured backends.
Let transport errors trigger fallback to the next credential
OpenAiCompatibleClient.PostChatCompletion() catches network/transport exceptions and returns a normal GeminiResult (HttpStatus = 0) instead of throwing. In the fallback methods, retry-to-next-provider on network problems is only implemented in the exception path (catch + IsRetryableNetworkError), so these wrapped failures are treated as terminal errors and stop fallback. This breaks multi-provider resilience during transient connection issues; either rethrow retryable exceptions here or classify HttpStatus == 0 as retryable in fallback.
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".
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
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.
Motivation
Description
LlmClients.cswithLlmProvider,LlmCredential,OpenAiCompatibleClient, andLlmErrorPolicyto call OpenAI-compatible endpoints and unify text/image requests.DailyQuotaTracker.csto persist daily usage tousage_daily.json, provide defaults for common models, and expose snapshot/recording APIs.Form1.csandForm1.Designer.cs) to add API key/model fields for Pixtral, Mistral Pixtral and Llama4, implementBuildLlmCredentials(), fallback methodsTranslateTextWithFallbackAsync()andTranslateImageWithFallbackAsync(), and wire quota recording and saving.QuotaBoardFormembedded inForm1.csto visualize today's per-engine usage and a toolbar buttonbtnQuotaBoardto open it.Properties/Settings.*and updateApp.configdefaults for the new keys.LlmClients.cs,DailyQuotaTracker.cs) and include UI/behaviour changes like a close-confirmation dialog.Testing
Codex Task