-
Notifications
You must be signed in to change notification settings - Fork 39
added ollama support #10
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
Conversation
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.
Pull Request Overview
This PR adds native support for Ollama as an LLM backend alongside the existing Phi-4-mini integration. Key changes include:
- Introducing a new OllamaAgent to interface with the official Ollama Python client.
- Enhancing the AgentBuilder and CLI to support an --ollama flag and a configurable model name.
- Refactoring the prompt reading and repositioning the download_model function in phi_4_mini.py.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/open_codex/main.py | Added argparse enhancements for choosing agent backend and CLI improvements. |
src/open_codex/agents/phi_4_mini.py | Repositioned and re-added download_model to improve code structure. |
src/open_codex/agents/ollama_restapi.py | Introduces the new OllamaAgent with proper error handling and API integration. |
src/open_codex/agent_builder.py | Added get_system_prompt and get_ollama_agent for improved agent instantiation. |
Args: | ||
system_prompt: The system prompt to use for generating responses | ||
model_name: The name of the model to use (default: "llama3") | ||
host: The host URL of the Ollama API (default: None, uses OLLAMA_HOST env var or http://localhost:11434) |
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.
The host URL for Ollama is hardcoded as http://localhost:11434.!
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.
The issue occurs when I try to load the Ollama model without running Ollama locally. When I run the command open-codex --ollama --model llama3 "create a tarball of the src dir"
, it loads the default model and checks if Ollama is running.
thanks @codewithdark-git - I'll check |
9db6c9f
to
db581c7
Compare
- Added full support for Ollama via official Python client (`ollama>=0.4.8`) - New agent class `OllamaAgent` for local LLMs like LLaMA3 via Ollama - Refactored `AgentBuilder` to support multiple backends (phi, ollama) - Improved CLI with: - `--ollama` and `--model` flags - Host configuration via `--ollama-host` - Structured prompt help and error handling - Updated README with new usage examples, clearer feature list, and Ollama setup instructions - Renamed `phi_4_mini.py` → `phi_4_mini_agent.py` for consistency - Enhanced logging and feedback for model loading and errors - Improved UX: response formatting, keypress actions (copy/execute/abort) with better feedback
Thanks again! - I added proper error handling and merged it |
🚀 Add Ollama Support to Open Codex
Summary
This PR introduces native support for Ollama as an alternative LLM backend alongside the existing Phi-4-mini integration.
✨ Key Changes
New Agent:
OllamaAgent
implemented using the officialollama
Python client:system_prompt
, configurablemodel_name
, andtemperature
ollama.chat
with a one-shot response interfaceAgentBuilder Enhancements:
get_ollama_agent()
for easy instantiationget_system_prompt()
extracted for reuseCLI Extensions (
main.py
):--ollama
flag to enable Ollama mode--model
flag to specify the model (e.g.,llama3
)one_shot_mode()
to dynamically select the agent backendRefactored
phi_4_mini.py
:download_model()
below__init__
for better structure (functionality unchanged)🔪 Example Usage
📝 Notes
http://localhost:11434
)ollama pull <model_name>