Merged
Conversation
There was a problem hiding this comment.
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. |
6 tasks
codingmoh
commented
Apr 30, 2025
| 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) |
Owner
Author
There was a problem hiding this comment.
The host URL for Ollama is hardcoded as http://localhost:11434.!
codewithdark-git
left a comment
There was a problem hiding this comment.
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.
Owner
Author
|
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
Owner
Author
|
Thanks again! - I added proper error handling and merged it |
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.
🚀 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:
OllamaAgentimplemented using the officialollamaPython client:system_prompt, configurablemodel_name, andtemperatureollama.chatwith a one-shot response interfaceAgentBuilder Enhancements:
get_ollama_agent()for easy instantiationget_system_prompt()extracted for reuseCLI Extensions (
main.py):--ollamaflag to enable Ollama mode--modelflag 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>