feat(providers): add OpenMythos local-model provider#15
Open
baseflux wants to merge 2 commits intoGPT-AGI:mainfrom
Open
feat(providers): add OpenMythos local-model provider#15baseflux wants to merge 2 commits intoGPT-AGI:mainfrom
baseflux wants to merge 2 commits intoGPT-AGI:mainfrom
Conversation
added 2 commits
April 21, 2026 23:37
Wires OpenMythos (a local PyTorch Recurrent-Depth Transformer) behind the Clawd BaseProvider interface so Clawd-Code can drive a local model instead of a remote API. - src/providers/openmythos_provider.py: new OpenMythosProvider class. Implements chat() and chat_stream() by calling OpenMythos's forward() in a decode loop with KV cache reuse. Streams token-by-token, with BPE-partial-piece buffering so gpt-oss-20b tokens render cleanly. Heavy imports (torch, open_mythos) deferred to __init__ so Clawd users without PyTorch are unaffected at package-import time. - src/providers/__init__.py: register 'openmythos' in PROVIDER_INFO with the 7 mythos_* variants; wire get_provider_class. - pyproject.toml: add [openmythos] extra pinning open-mythos>=0.4.0 and torch>=2.4,<3. Does not affect base install. - tests/test_openmythos_provider.py: smoke tests for registration, class resolution, transcript formatting. Full wire test skipped if torch/open_mythos not installed so CI stays light. - docs/openmythos-provider.md: install, env vars, streaming model, knobs, known limitations (no tool calling, no pretrained weights). The 'no pretrained weights' caveat is documented prominently — this provider is for integration-dev, research eval, and post-training use, not for out-of-box chat.
Adds support for running any local Ollama model (including refusal- removed Qwen 3.5 abliterated) through Clawd-Code. Why not OpenAI-compat? Ollama's OpenAI facade does not forward the `think` parameter, which means reasoning models (Qwen 3.5, DeepSeek-R1) burn their entire token budget inside <think>...</think> blocks and return an empty content string. Hitting /api/chat directly with think=false (or letting the user opt into think=true) fixes this and gives us access to the model's reasoning trace via ChatResponse.reasoning_content. - src/providers/ollama_provider.py: OllamaProvider class. Uses stdlib urllib (zero extra deps). Implements chat / chat_stream / chat_stream_response and get_available_models (via /api/tags). - src/providers/__init__.py: register 'ollama' with default model llama3.2:3b and abliterated Qwen in the available list. - tests/test_ollama_provider.py: 4 hermetic tests, 2 live tests that skip if Ollama is not running. Env knobs: OLLAMA_BASE_URL, OLLAMA_THINK.
Author
|
Update: pushed a 2nd commit adding an `OllamaProvider` (native `/api/chat`, supports `think=false`). Rationale: Ollama's OpenAI-compatible facade does not forward the `think` parameter, which means reasoning models like Qwen 3.5, DeepSeek-R1, and `huihui_ai/qwen3.5-abliterated` burn the entire token budget inside `...` before emitting any content, and return an empty string. Hitting `/api/chat` directly with `think=false` fixes this; `think=true` gives access to the model's reasoning trace via `ChatResponse.reasoning_content`. Zero extra deps (stdlib `urllib`). 4 hermetic tests + 2 live tests that skip if Ollama is not running. Works seamlessly with the existing OpenMythos provider for a "local chat + local training" workflow. |
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.
Adds OpenMythos (Recurrent-Depth Transformer) as a seventh provider so Clawd-Code can drive a local PyTorch model instead of a remote API.
Scope
Why
Three workflows benefit:
Caveat (documented)
OpenMythos does not ship pretrained weights. Without `OPENMYTHOS_CHECKPOINT` the model is random-init and produces noise. The provider docs flag this prominently. Useful for wiring checks and post-training use, not out-of-box chat.
Not included
Env
```
export OPENMYTHOS_VARIANT=mythos_3b # or any mythos_
export OPENMYTHOS_CHECKPOINT=/path/state.pt # optional
export OPENMYTHOS_N_LOOPS=16 # inference-time depth
export OPENMYTHOS_DEVICE=cuda # auto-detected if unset
export OPENMYTHOS_TOKENIZER=openai/gpt-oss-20b
```
Verification
```
pytest tests/test_openmythos_provider.py
3 passed, 1 skipped in 0.01s
```
(Skipped case loads torch + open_mythos end-to-end; runs when the `[openmythos]` extra is installed.)