Repository navigation
Conversation
The wizard only knew about Ollama: with FO_PROVIDER=openai (e.g. LM Studio) it still picked an Ollama model and failed validation because Ollama wasn't running. Since every non-bootstrap command is gated on setup completion, this blocked the CLI entirely for non-Ollama users. - Detect the active provider from FO_PROVIDER and take model names from the FO_* env vars; skip Ollama checks and guidance for other providers. - Probe OpenAI-compatible endpoints via GET /models and report missing or rejected API keys, unreachable hosts, and models the endpoint doesn't serve. - Power-user mode offers the endpoint's models instead of Ollama's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This branch has not been deployed
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.
Description
With a non-Ollama provider configured via environment variables,
fo setupcannot succeed — and since every command outside_SETUP_GATE_ALLOWLISTis gated onsetup_completed, the CLI is unusable for those users (fo analyze,fo organize, ...).Reproduction (LM Studio, Ollama installed but not running):
No existing issue.
Root cause
SetupWizardonly knows about Ollama.detect_capabilities()probes Ollama alone,generate_config()always picks an Ollama model withframework="ollama", andvalidate_config()requires the Ollama service. It never consultsconfig.provider_env, even thoughget_model_configs()givesFO_PROVIDERprecedence over the saved profile at runtime — so the wizard validates a backend the CLI won't even use. Power-user mode only offersollama/llama_cpp/mlx.What changed
src/file_organizer/core/backend_detector.py: newEndpointStatus+detect_openai_endpoint(base_url, api_key), which probesGET {base_url}/models(stdliburllib, no new dependency;openaistays optional). Distinguishes missing API key (401/403 without key → "set FO_OPENAI_API_KEY"), rejected key, other HTTP errors, and unreachable hosts.src/file_organizer/core/setup_wizard.py:SystemCapabilitiesgainsprovider,provider_text_model,provider_vision_model,endpoint_status.detect_capabilities()reads the active provider viaget_current_provider(); for non-Ollama providers it takes model names fromget_model_configs_from_env(), and foropenaiprobes the endpoint (falling back toOPENAI_API_KEY, matching the SDK).generate_config()applies the env provider through a small_apply_env_provider()helper (kept separate to stay under the C901 limit).validate_config()only applies Ollama checks whenframework == "ollama"(the "model not installed" check previously ran whenever Ollama happened to be running, regardless of framework), and foropenaifails on an unreachable endpoint or a model the endpoint doesn't serve, listing the available ones.run()only emits Ollama next-step warnings for the Ollama provider.src/file_organizer/cli/setup.py: shows the active provider/model and endpoint status instead of Ollama status and install hints; quick-start uses the env model; power-user mode offers the endpoint's model list instead of the framework/Ollama-model prompts.TestDetectOpenAIEndpoint(real local HTTP server: valid key, missing key, wrong key, unreachable host) andTestEnvProvider(openai provider doesn't require Ollama; unreachable endpoint fails with the key hint and no Ollama error; unserved model fails listing alternatives).test_setup_ollama_guidance.py'sSimpleNamespacestub gainsprovider="ollama".Ollama-only behavior is unchanged when
FO_PROVIDERis unset orollama.Notes / out of scope
api_base_url/api_key(ModelPresethas no such fields), so non-Ollama users still need theFO_*env vars at runtime — which matches howget_model_configs()already resolves providers. Persisting provider settings in profiles would be a separate change.openaionly;llama_cpp/mlx/claudeget the env-driven framework and model names without a reachability check.mainalso requires the circular-import fix in fix(core): break circular import between organize_options and config #1804, sincefocurrently fails at startup; the two changes are otherwise independent and the test suite passes on this branch alone.Type of change
How Has This Been Tested?
fo setup run --dry-runwith the env vars above against a mock OpenAI-compatible server — valid key + served model → "Configuration is valid" withFramework openai,Text Model qwen3-14b-mlx; unserved model → validation error listing available models. Against real LM Studio with auth enabled and no key → "endpoint requires an API key; set FO_OPENAI_API_KEY".tests/core,tests/cli,tests/config,tests/integration/test_setup_wizard_core.py,tests/integration/test_cli_setup.py: 1948 passed, 2 skipped. Also rantests/tuiandtests/webon the combined change: passing.ruff check/ruff format --checkon changed files: clean.mypycould not be run locally: it aborts on a syntax error inside the installed PyQt6 stubs (QtGui.pyi) before reaching project files — environment issue, unrelated to this change.Checklist:
FO_*vars; can add a setup note to the provider docs if wanted)🤖 Generated with Claude Code