Add multi-LLM fallback support (Pixtral / Mistral / Groq) and UI settings#4
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3857a1a79a
ℹ️ 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) | ||
| { |
There was a problem hiding this comment.
Skip local Pixtral fallback unless user configured it
BuildLlmCredentials() currently adds the local Pixtral endpoint whenever cmbModel_Pixtral.SelectedItem is set, and Form1_Load always selects an item by default, so an unconfigured http://127.0.0.1:8000/v1 provider is injected for all users. In the common setup without a local vLLM server, this implicit step fails before later providers are reached, which can prevent configured Mistral/Groq fallbacks from being attempted after a Gemini quota/rate-limit event.
Useful? React with 👍 / 👎.
| catch (Exception ex) | ||
| { | ||
| return new GeminiResult | ||
| { | ||
| HttpStatus = 0, |
There was a problem hiding this comment.
Let network errors bubble so fallback can try next provider
PostChatCompletion() swallows transport exceptions and returns a synthetic GeminiResult (HttpStatus = 0) instead of throwing. The fallback orchestration in TranslateTextWithFallbackAsync()/TranslateImageWithFallbackAsync() only switches providers for network failures in their catch (Exception) branch, so these wrapped errors are treated as terminal non-quota failures and the chain stops early. A transient connection failure on one OpenAI-compatible provider can therefore block trying later configured providers.
Useful? React with 👍 / 👎.
Motivation
Description
ApiKey_Pixtral,ModelName_Pixtral,ApiKey_MistralPixtral,ModelName_MistralPixtral,ApiKey_Llama4, andModelName_Llama4and updatedApp.config,Settings.settings, andSettings.Designer.csto persist them.Form1to add model combo boxes and API key textboxes for Pixtral / Mistral / Llama4, initialize option lists, update link labels, and read/save those settings on load/close.Form1_FormClosingto prompt the user to exit, minimize to tray, or cancel.Form1usingBuildLlmCredentials(),TranslateTextWithFallbackAsync(), andTranslateImageWithFallbackAsync()to attempt multiple configured providers in order and switch on quota/rate-limit or retryable network errors.LlmClients.csimplementingLlmProvider,LlmCredential,LlmErrorPolicy, andOpenAiCompatibleClientwith helpers to call OpenAI-compatible chat endpoints and to post image data as data-URI for OCR+translation.HandleCapturedImageto call the new fallback methods and update UI/token usage handling accordingly.LlmClients.csin the project file (ScreenOCRTranslator.csproj).Testing
Codex Task