diff --git a/.env.example b/.env.example index 454713d..cba2ef7 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,5 @@ OLLAMA_HOST=http://localhost:11434 +OLLAMA_API_KEY= OLLAMA_DEFAULT_MODEL=gemma4:e4b-it-q_8 OPENAI_API_KEY= diff --git a/README.md b/README.md index a32a207..ec36d0f 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,7 @@ ```dotenv # LLM OLLAMA_HOST=http://localhost:11434 +OLLAMA_API_KEY= OLLAMA_DEFAULT_MODEL=gemma4:e4b-it-q8_0 OLLAMA_NUM_CTX=65536 OLLAMA_THINK=true @@ -153,3 +154,12 @@ # Персона NAVI_PERSONA_FILE=persona.txt ``` + +Для прямого доступа к Ollama Cloud: + +```dotenv +OLLAMA_HOST=https://ollama.com +OLLAMA_API_KEY=your_api_key +``` + +Также укажи cloud-модель в `navi/profiles/*/config.json`, потому что профили могут переопределять `OLLAMA_DEFAULT_MODEL`. diff --git a/docs/config.md b/docs/config.md index 86bdc31..9dabc4c 100644 --- a/docs/config.md +++ b/docs/config.md @@ -7,12 +7,18 @@ | Variable | Type | Default | Description | |---|---|---|---| | `OLLAMA_HOST` | str | `http://localhost:11434` | Ollama server URL | +| `OLLAMA_API_KEY` | str | `""` | Ollama Cloud API key for direct `https://ollama.com` access | | `OLLAMA_DEFAULT_MODEL` | str | `gemma4:e2b-it-q8_0` | Default model (can be overridden per profile) | | `OLLAMA_NUM_CTX` | int | `65536` | Context window size in tokens | | `OLLAMA_THINK` | bool | `true` | Enable extended reasoning (thinking) | | `OPENAI_API_KEY` | str | `""` | OpenAI API key (if using OpenAI backend) | | `ANTHROPIC_API_KEY` | str | `""` | Anthropic API key (if using Anthropic backend) | +For direct Ollama Cloud access, set `OLLAMA_HOST=https://ollama.com` and +`OLLAMA_API_KEY=`. Built-in profiles may override `OLLAMA_DEFAULT_MODEL`, +so update the `model` field in `navi/profiles/*/config.json` to a cloud model +when switching away from local Ollama models. + ## Security / Sandboxing | Variable | Type | Default | Description | @@ -73,6 +79,7 @@ ```dotenv OLLAMA_HOST=http://localhost:11434 +OLLAMA_API_KEY= OLLAMA_DEFAULT_MODEL=gemma4:e2b-it-q8_0 OLLAMA_NUM_CTX=65536 OLLAMA_THINK=true diff --git a/navi/config.py b/navi/config.py index 05a3a63..65f9f4a 100644 --- a/navi/config.py +++ b/navi/config.py @@ -8,6 +8,7 @@ model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore") ollama_host: str = "http://localhost:11434" + ollama_api_key: str = "" ollama_default_model: str = "gemma4:e4b-it-q8_0" ollama_num_ctx: int = 65536 ollama_think: bool = True diff --git a/navi/core/registry.py b/navi/core/registry.py index a768eee..56d377f 100644 --- a/navi/core/registry.py +++ b/navi/core/registry.py @@ -112,6 +112,7 @@ ollama_backend = OllamaBackend( model=settings.ollama_default_model, host=settings.ollama_host, + api_key=settings.ollama_api_key, ) ai_helper = AIHelper( backend=ollama_backend, diff --git a/navi/llm/ollama.py b/navi/llm/ollama.py index cee4e8d..6f6bfef 100644 --- a/navi/llm/ollama.py +++ b/navi/llm/ollama.py @@ -46,9 +46,10 @@ class OllamaBackend(LLMBackend): - def __init__(self, model: str, host: str = "http://localhost:11434"): + def __init__(self, model: str, host: str = "http://localhost:11434", api_key: str = ""): self.model = model - self._client = ollama_client.AsyncClient(host=host) + headers = {"Authorization": f"Bearer {api_key}"} if api_key else None + self._client = ollama_client.AsyncClient(host=host, headers=headers) async def complete( self, diff --git a/navi/profiles/developer/config.json b/navi/profiles/developer/config.json index cb115dc..a320cf5 100644 --- a/navi/profiles/developer/config.json +++ b/navi/profiles/developer/config.json @@ -9,7 +9,7 @@ "key_tools": "filesystem, code_exec, terminal, web_search, web_view, spawn_agent" }, "llm_backend": "ollama", - "model": "gemma4:26b-a4b-it-q4_K_M", + "model": "gemma4:31b", "temperature": 0.2, "max_iterations": 35, "planning_enabled": true, diff --git a/navi/profiles/secretary/config.json b/navi/profiles/secretary/config.json index 5ee8e98..fef7db3 100644 --- a/navi/profiles/secretary/config.json +++ b/navi/profiles/secretary/config.json @@ -9,7 +9,7 @@ "key_tools": "web_search, web_view, filesystem, code_exec, gmail, todo, scratchpad, spawn_agent, memory" }, "llm_backend": "ollama", - "model": "gemma4:26b-a4b-it-q4_K_M", + "model": "gemma4:31b", "temperature": 0.5, "max_iterations": 25, "planning_enabled": true, diff --git a/navi/profiles/server_admin/config.json b/navi/profiles/server_admin/config.json index f37228c..e6ff0ce 100644 --- a/navi/profiles/server_admin/config.json +++ b/navi/profiles/server_admin/config.json @@ -9,7 +9,7 @@ "key_tools": "ssh_exec, terminal, filesystem, code_exec, web_search, spawn_agent, memory" }, "llm_backend": "ollama", - "model": "gemma4:26b-a4b-it-q4_K_M", + "model": "gemma4:31b", "temperature": 0.2, "max_iterations": 20, "planning_enabled": true, diff --git a/navi/profiles/tool_developer/config.json b/navi/profiles/tool_developer/config.json index 75e0375..b89c274 100644 --- a/navi/profiles/tool_developer/config.json +++ b/navi/profiles/tool_developer/config.json @@ -9,7 +9,7 @@ "key_tools": "write_tool, reload_tools, delete_tool, test_tool, filesystem, terminal, code_exec, memory" }, "llm_backend": "ollama", - "model": "gemma4:26b-a4b-it-q4_K_M", + "model": "gemma4:31b", "temperature": 0.2, "max_iterations": 35, "planning_enabled": true,