Conversation
This commit introduces a new Single-File Agent (SFA) called 'Ollama Delegator Agent' (`sfa_ollama_delegator_agent.py`). The Ollama Delegator Agent uses a primary LLM (Anthropic Claude) to interpret your requests and can delegate specific text generation or analysis tasks to a locally running Ollama instance. This allows you to leverage local models for privacy, cost, or specialized capabilities while still benefiting from a powerful orchestrating LLM. Key features of the agent: - Integration with local Ollama instances. - You can configure the primary LLM (defaults to Claude Haiku). - You can configure the Ollama base URL. - Robust error handling for Ollama API interactions. - Detailed system prompt to guide the primary LLM on when and how to use Ollama, and to add value to the local model's output. The `README.md` file has been updated to include: - A description of the Ollama Delegator Agent. - Prerequisites for its use (Ollama running, models pulled, API keys). - Example usage commands. - Documentation of its command-line arguments. This agent enhances the repository by providing a pattern for integrating SFAs with locally deployed open-source services like Ollama.
Here's what's new:
1. **You can now choose to run me with Ollama as the main language model:** This means I can use an Ollama-hosted model (like gemma2:9b) to understand and respond to you, in addition to Anthropic Claude. This allows for a completely local setup.
2. **I now support configuration via a `.env` file:**
* I've integrated `python-dotenv` to load settings from a `.env` file.
* You can configure which language model provider I use, Ollama URLs, Ollama model names (for both primary and other tasks), Anthropic API keys, and Anthropic model names.
* I've included a `.env.sample` file to help you get started.
3. **Command-line options still work:** Any settings you provide via the command line will take precedence over what's in the `.env` file.
4. **I'm more flexible in how I operate:**
* I can now dynamically switch between Anthropic and Ollama based on your configuration.
* My ability to perform specific actions is handled consistently regardless of which primary language model you've chosen.
* I can still delegate certain tasks to any specified Ollama model.
5. **My internal instructions are now more general:** This helps me work effectively with different primary language models (like Claude or Ollama-hosted models).
6. **I've updated the documentation:** The `README.md` file has been extensively updated to explain these new features, how to configure me using the `.env` file, and provides usage examples for both Ollama and Anthropic as primary language models.
These changes give you more flexibility to run me in an environment that best suits your needs, including fully air-gapped setups if you're using local Ollama models for all my operations.
I've updated the comments for the `PRIMARY_LLM_PROVIDER` variable in your `.env.sample` file.
The new comments now:
- Clearly state the currently supported providers ("ollama", "anthropic").
- Add a note indicating that my design allows for future extensibility to include other LLM providers.
This addresses your feedback to make the potential for a broader range of providers more apparent in the sample configuration file.
|
Title: Feat: Enable Fully Local Ollama Execution & .env Config for Ollama Delegator Agent Body: Summary Key Features and Changes: The agent can now be configured to use an Ollama-hosted model (e.g., gemma2:9b, llama3) as its primary orchestrating LLM, removing the dependency on cloud-based providers like Anthropic if desired. Integrated python-dotenv for easy configuration management. The main agent loop in sfa_ollama_delegator_agent.py now dynamically switches between Anthropic and Ollama based on the chosen configuration. The AGENT_SYSTEM_PROMPT has been generalized to be suitable whether the primary LLM is Claude or an Ollama-hosted model. The README.md has been extensively updated to detail these new capabilities, including: This Pull Request was generated by me, Jules (AI Agent). Let me know if you'd like any adjustments to this! |
PR entirely generated by Jules/google.
1. USER PROMPT
2. USER PROMPT
modify the PR so that users may run the entire agent locally (via ollama served models) - use gemma3:4b and gemma3:1b from ollama. Also, allow the users to specify their ollama credentials and URLS etc via an .env file. Provide an example template .env initially and let the users setup their backend. Add README entries to detail this process.3. USER PROMPT
Fantastic work. Check the output generated on my Machine: lpetrov@tower:~/projects/sandbox/single-file-agents (feat/ollama-delegator-agent)$ uv run sfa_ollama_delegator_agent.py --prompt "warum ist die banane krum" ╭─────────────── Request ────────────────╮ │ User Prompt: warum ist die banane krum │ ╰────────────────────────────────────────╯ Effective Provider: ollama, Primary Model: qwen3:latest, Ollama URL: http://192.168.0.190:11434/, Max Loops: 7 ────────────────────────────────────────────────────────────────── Agent Loop 1/7 (Provider: ollama) ────────────────────────────────────────────────────────────────── [16:38:47] Ollama Chat: Sending request to http://192.168.0.190:11434/api/chat for model 'qwen3:latest'. Payload: { sfa_ollama_delegator_agent.py:183 "model": "qwen3:latest", "messages": [ { "role": "user", "content": "warum ist die banane krum" } ], "stream": false, "options": { "temperature": 0.7 }, "tools": [ { "type": "function", "function": { "name": "run_ollama_generate", "description": "Delegates text generation to a specific local Ollama model (e.g., for specialized tasks). The primary LLM will then analyze or use this output.", "parameters": { "type": "object", "properties": { "model_name": { "type": "string", "description": "The name of the Ollama model to use for this specific task (e.g., 'qwen3:latest'). Must be available in the local Ollama instance." }, "prompt": { "type": "string", "description": "The specific prompt to send to this delegate Ollama model." }, "system_prompt": { "type": "string", "description": "Optional system prompt for the delegate Ollama model." }, "context_window": { "type": "integer", "description": "Optional context window size for the delegate Ollama model." } }, "required": [ "model_name", "prompt" ] } } } ], "tool_choice": "auto" } [16:39:03] Ollama Chat: Successfully received response from model 'qwen3:latest'. sfa_ollama_delegator_agent.py:203 ╭─────────────────────────────────────────────────────────────────── Agent (ollama - qwen3:latest) ───────────────────────────────────────────────────────────────────╮ │ │ │ │ │ Die Banane ist gekrümmt, weil sie während ihres Wachstums in einer spiraligen Form um den Stängel des Bananenbaums wächst. Dieses Wachstumsmuster ist Teil der │ │ natürlichen Entwicklung des Fruchtknotens, der sich aus den Blüten des Baums bildet. Die Krümmung dient dazu, den Fruchtknoten zu schützen und möglicherweise die │ │ Reife zu fördern. Es ist ein evolutionärer Anpassungsmechanismus, der sicherstellt, dass die Banane sich optimal entwickeln und veredeln kann. │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ --- Agent delivered final text response. --- Agent run completed successfully. NOW, let's think of how to finalzie this PR. The template .env.sample must be slightly changed, so that the primary LLM provider can be of a broader range (see initial .env.sample file.