Fix #1721: Add support for Ollama with third-party URL wrappers #1735
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.
Features
Fixed issue #1721: Unable to configure Ollama via third-party URL wrapper
Added support for three different ways to configure Ollama with third-party wrappers:
Base URL with /api at the end
Base URL without /api (automatically handled)
Proxy configuration option
Added comprehensive documentation and example configurations
Added test scripts to verify URL construction
Feature Docs
Added new tutorial: docs/tutorial/ollama_third_party_wrapper.md
Added example config: config/examples/ollama-third-party-wrapper.yaml
Added test scripts:
examples/ollama_url_test.py
examples/ollama_wrapper_test.py
Influence
This fix enables users to:
Use MetaGPT with Ollama through third-party URL wrappers
Configure the base URL in multiple ways to suit different wrapper setups
Easily verify their configuration with provided test scripts
Follow clear documentation for setup and troubleshooting
Result
Testing Ollama URL construction...
Test: Direct Ollama URL
Base URL: http://localhost:11434
Suffix: /chat
Result URL: http://localhost:11434/api/chat
Expected: http://localhost:11434/api/chat
✅ PASS
Test: Wrapper URL with /api at end
Base URL: http://localhost:8989/ollama/api
Suffix: /chat
Result URL: http://localhost:8989/ollama/api/chat
Expected: http://localhost:8989/ollama/api/chat
✅ PASS
Test: Wrapper URL without /api
Base URL: http://localhost:8989/ollama
Suffix: /chat
Result URL: http://localhost:8989/ollama/api/chat
Expected: http://localhost:8989/ollama/api/chat
✅ PASS
Test: Wrapper URL with /api/ in middle
Base URL: http://localhost:8989/api/ollama
Suffix: /chat
Result URL: http://localhost:8989/api/ollama/chat
Expected: http://localhost:8989/api/ollama/chat
✅ PASS
Other
The changes maintain backward compatibility with existing Ollama configurations while adding support for third-party URL wrappers. The solution is flexible enough to handle various wrapper URL patterns and includes comprehensive documentation to help users set up their preferred configuration.