-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add Ollama provider support #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add LMMEngineOllama class to support local Ollama models. Ollama uses OpenAI-compatible API with default endpoint http://localhost:11434/v1. Closes simular-ai#44 Signed-off-by: majiayu000 <[email protected]>
📝 WalkthroughWalkthroughAdded two new concrete LLM engines (DeepSeek, Qwen) and extended LMMAgent to support Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant LMMAgent
participant Engine (DeepSeek/Qwen/Ollama)
participant ExternalAPI
User->>LMMAgent: instantiate (engine_type="deepseek"/"qwen"/"ollama", params)
LMMAgent->>LMMAgent: resolve engine_type, env vars, engine_params
LMMAgent->>Engine: instantiate engine with engine_params
User->>LMMAgent: add_message / request
LMMAgent->>Engine: forward messages to generate(...)
Engine->>ExternalAPI: HTTP/SDK call to provider endpoint (with api_key)
ExternalAPI-->>Engine: response
Engine-->>LMMAgent: generated reply
LMMAgent-->>User: deliver output
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧹 Recent nitpick comments
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🧰 Additional context used🧬 Code graph analysis (1)gui_agents/s3/core/mllm.py (1)
🪛 Ruff (0.14.11)gui_agents/s3/core/mllm.py52-54: Avoid specifying long messages outside the exception class (TRY003) gui_agents/s3/core/engine.py450-450: Unused method argument: (ARG002) 465-467: Avoid specifying long messages outside the exception class (TRY003) 492-492: Unused method argument: (ARG002) 507-509: Avoid specifying long messages outside the exception class (TRY003) 🔇 Additional comments (6)
✏️ Tip: You can disable this entire section by setting 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
gui_agents/s3/core/engine.py (1)
448-464: Initialization looks correct.The
__init__method follows the pattern of other engine implementations. Note thatrequest_intervalis calculated but not used in thegeneratemethod—this is consistent with several other engine classes in the file (e.g.,LMMEngineGemini,LMMEngineOpenRouter), suggesting it may be used externally or reserved for future rate limiting.The
**kwargsparameter is unused but matches the pattern across all engine classes for forward compatibility.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
gui_agents/s3/core/engine.pygui_agents/s3/core/mllm.py
🧰 Additional context used
🧬 Code graph analysis (1)
gui_agents/s3/core/mllm.py (1)
gui_agents/s3/core/engine.py (1)
LMMEngineOllama(448-491)
🪛 Ruff (0.14.10)
gui_agents/s3/core/engine.py
456-456: Unused method argument: kwargs
(ARG002)
474-474: Unused method argument: kwargs
(ARG002)
🔇 Additional comments (4)
gui_agents/s3/core/mllm.py (3)
9-9: LGTM!The import is correctly added and follows the existing pattern.
39-40: LGTM!The engine initialization follows the established pattern and is correctly integrated into the engine selection logic.
135-135: LGTM!Correctly includes
LMMEngineOllamain the API-style inference type check, consistent with Ollama's OpenAI-compatible API.gui_agents/s3/core/engine.py (1)
476-480: Base URL handling is well-designed.The fallback chain (instance attribute →
OLLAMA_HOSTenv var → localhost default) and automatic/v1suffix normalization provide good flexibility and user convenience.
This ensures consistency with other engine implementations (OpenAI, Gemini, OpenRouter, etc.) and allows callers to pass additional parameters like stop, top_p, etc. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Hi, thanks for the contribution! I believe for any OpenAI-compatible provider you can just init a LMMEngineOpenAI with a custom base_url: Can you try if this works for your use case? If so, I'd prefer to avoid adding additional boilerplate code |
| import os | ||
| base_url = os.getenv("OLLAMA_HOST") | ||
| if base_url: | ||
| if not base_url.endswith("/v1"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Instead of defaulting to localhost, raising an actionable error is better and easier for devs to debug.
Would you mind including DeepSeek and Qwen into this PR and close #164?
I think we can check in after the change and some test
Summary
LMMEngineOllamaclass toengine.pyfor local Ollama model supporthttp://localhost:11434/v1OLLAMA_HOSTenvironment variable for custom endpointUsage
agent_s \ --provider ollama \ --model llama3.2-vision \ --ground_provider ollama \ --ground_url http://localhost:11434 \ --ground_model llama3.2-vision \ --grounding_width 1920 \ --grounding_height 1080Closes #44
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.