feat(plugins): Ollama support#352
Open
Dialvive wants to merge 3 commits into
Open
Conversation
Adds docstring for the Ollama plugin.
Add unit tests for the Ollama plugin model type handler, covering various scenarios including custom endpoints, environment variables, and model creation.
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.
Summary
Adds a new plugin that lets Code Puppy connect to local inference servers — Ollama, LM Studio, vLLM, llama.cpp, and any other OpenAI Chat Completions-compatible endpoint — without sending requests to remote model providers.
The plugin is auto-discovered by the existing plugin loader. Zero existing files were modified.
User Story
As a user, I want to run Code Puppy with local models through Ollama (or any OpenAI Chat Completions-compatible endpoint), so that I don't connect with remote model providers, use the hardware on my machine to process requests, and reduce costs.
Acceptance Criteria
code_puppy/plugins/ollama/is created following the plugin architecture"ollama"model type via theregister_model_typecallback hook~/.code_puppy/extra_models.jsonusing the existingcustom_endpointconfig formatcustom_endpointis provided, the plugin defaults tohttp://localhost:11434/v1with api_key"ollama"OLLAMA_HOSTenvironment variable overrides the default base URLOpenAIChatModel(Chat Completions API), NOTOpenAIResponsesModel(Responses API)ruff formatandruff checkTest Plan
custom_endpointconfigget_custom_config()custom_endpointhttp://localhost:11434/v1, api_key"ollama"OLLAMA_HOSTenv var set/v1if missingOpenAIChatModelOpenAIResponsesModel— verified via isinstance checkNone, does not raiseget_ollama_model_types()return structure[{"type": "ollama", "handler": callable}]ModelFactory.get_modelintegration"ollama"routes to the handler via callbackregister_callbacks.pyis found by plugin loaderHow to Use
1 — Install Ollama
2 — Pull a model with tool calling support
3 — Start the Ollama server
4 — Configure the model in Code Puppy
Create or edit ~/.code_puppy/extra_models.json:
{ "ollama-qwen3": { "type": "ollama", "name": "qwen3:8b", "context_length": 32768 } }Multiple models can be registered at once:
{ "ollama-qwen3-8b": { "type": "ollama", "name": "qwen3:8b", "context_length": 32768 }, "ollama-qwen3-30b": { "type": "ollama", "name": "qwen3:30b", "context_length": 131072 } }Custom host (different port, remote machine, LM Studio):
{ "lmstudio-codellama": { "type": "ollama", "name": "codellama:34b", "context_length": 16384, "custom_endpoint": { "url": "http://192.168.1.50:1234/v1", "api_key": "lm-studio" } } }Alternatively, set OLLAMA_HOST to override the default endpoint without editing the config:
export OLLAMA_HOST=http://myserver:114345 — Run Code Puppy and switch to the local model
Inside the session:
Or start directly on the model:
Testing
Unit tests (no Ollama required — fully mocked)
Coverage: 100% on plugin files across 15 test cases covering:
Verified End-to-End