Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(pr-1863): complete Ollama provider routing and README docs
Re-bin447883842449
diff --git a/README.md b/README.mdindex f0e1a6b24..8dba2d746 100644--- a/README.md+++ b/README.md@@ -778,6 +778,7 @@ Config file: `~/.nanobot/config.json`| `dashscope` | LLM (Qwen) | [dashscope.console.aliyun.com](https://dashscope.console.aliyun.com) || `moonshot` | LLM (Moonshot/Kimi) | [platform.moonshot.cn](https://platform.moonshot.cn) || `zhipu` | LLM (Zhipu GLM) | [open.bigmodel.cn](https://open.bigmodel.cn) |+| `ollama` | LLM (local, Ollama) | — || `vllm` | LLM (local, any OpenAI-compatible server) | — || `openai_codex` | LLM (Codex, OAuth) | `nanobot provider login openai-codex` || `github_copilot` | LLM (GitHub Copilot, OAuth) | `nanobot provider login github-copilot` |@@ -843,6 +844,37 @@ Connects directly to any OpenAI-compatible endpoint — LM Studio, llama.cpp, To</details>+<details>+<summary><b>Ollama (local)</b></summary>++Run a local model with Ollama, then add to config:++**1. Start Ollama** (example):+```bash+ollama run llama3.2+```++**2. Add to config** (partial — merge into `~/.nanobot/config.json`):+```json+{+ "providers": {+ "ollama": {+ "apiBase": "http://localhost:11434"+ }+ },+ "agents": {+ "defaults": {+ "provider": "ollama",+ "model": "llama3.2"+ }+ }+}+```++> `provider: "auto"` also works when `providers.ollama.apiBase` is configured, but setting `"provider": "ollama"` is the clearest option.++</details>+<details><summary><b>vLLM (local / OpenAI-compatible)</b></summary>diff --git a/nano.2091796.save b/nano.2091796.savenew file mode 100644index 000000000..695316825--- /dev/null+++ b/nano.2091796.save@@ -0,0 +1,2 @@+da activate base+diff --git a/nano.2095802.save b/nano.2095802.savenew file mode 100644index 000000000..695316825--- /dev/null+++ b/nano.2095802.save@@ -0,0 +1,2 @@+da activate base+diff --git a/nanobot/config/schema.py b/nanobot/config/schema.pyindex d2ef71383..1b26dd793 100644--- a/nanobot/config/schema.py+++ b/nanobot/config/schema.py@@ -395,6 +395,15 @@ class Config(BaseSettings):if spec.is_oauth or spec.is_local or p.api_key:return p, spec.name+ # Fallback: configured local providers can route models without+ # provider-specific keywords (for example plain "llama3.2" on Ollama).+ for spec in PROVIDERS:+ if not spec.is_local:+ continue+ p = getattr(self.providers, spec.name, None)+ if p and p.api_base:+ return p, spec.name+# Fallback: gateways first, then others (follows registry order)# OAuth providers are NOT valid fallbacks — they require explicit model selectionfor spec in PROVIDERS:@@ -421,7 +430,7 @@ class Config(BaseSettings):return p.api_key if p else Nonedef get_api_base(self, model: str | None = None) -> str | None:- """Get API base URL for the given model. Applies default URLs for known gateways."""+ """Get API base URL for the given model. Applies default URLs for gateway/local providers."""from nanobot.providers.registry import find_by_namep, name = self._match_provider(model)@@ -432,7 +441,7 @@ class Config(BaseSettings):# to avoid polluting the global litellm.api_base.if name:spec = find_by_name(name)- if spec and spec.is_gateway and spec.default_api_base:+ if spec and (spec.is_gateway or spec.is_local) and spec.default_api_base:return spec.default_api_basereturn Nonediff --git a/tests/test_commands.py b/tests/test_commands.pyindex 1375a3a09..583ef6f53 100644--- a/tests/test_commands.py+++ b/tests/test_commands.py@@ -114,6 +114,35 @@ def test_config_matches_openai_codex_with_hyphen_prefix():assert config.get_provider_name() == "openai_codex"+def test_config_matches_explicit_ollama_prefix_without_api_key():+ config = Config()+ config.agents.defaults.model = "ollama/llama3.2"++ assert config.get_provider_name() == "ollama"+ assert config.get_api_base() == "http://localhost:11434"+++def test_config_explicit_ollama_provider_uses_default_localhost_api_base():+ config = Config()+ config.agents.defaults.provider = "ollama"+ config.agents.defaults.model = "llama3.2"++ assert config.get_provider_name() == "ollama"+ assert config.get_api_base() == "http://localhost:11434"+++def test_config_auto_detects_ollama_from_local_api_base():+ config = Config.model_validate(+ {+ "agents": {"defaults": {"provider": "auto", "model": "llama3.2"}},+ "providers": {"ollama": {"apiBase": "http://localhost:11434"}},+ }+ )++ assert config.get_provider_name() == "ollama"+ assert config.get_api_base() == "http://localhost:11434"++def test_find_by_model_prefers_explicit_prefix_over_generic_codex_keyword():spec = find_by_model("github-copilot/gpt-5.3-codex")