feat: DIAL provider implementation (#112)
## Description This PR implements a new [DIAL](https://dialx.ai/dial_api) (Data & AI Layer) provider for the Zen MCP Server, enabling unified access to multiple AI models through the DIAL API platform. DIAL provides enterprise-grade AI model access with deployment-specific routing similar to Azure OpenAI. ## Changes Made - [x] Added support of atexit: - Ensures automatic cleanup of provider resources (HTTP clients, connection pools) on server shutdown - Fixed bug using ModelProviderRegistry.get_available_providers() instead of accessing private _providers - Works with SIGTERM/Ctrl+C for graceful shutdown in both development and containerized environments - [x] Added new DIAL provider (`providers/dial.py`) inheriting from `OpenAICompatibleProvider` - [x] Updated server.py to register DIAL provider during initialization - [x] Updated provider registry to include DIAL provider type - [x] Implemented deployment-specific routing for DIAL's Azure OpenAI-style endpoints - [x] Implemented performance optimizations: - Connection pooling with httpx for better performance - Thread-safe client caching with double-check locking pattern - Proper resource cleanup with `close()` method - [x] Added comprehensive unit tests with 16 test cases (`tests/test_dial_provider.py`) - [x] Added DIAL configuration to `.env.example` with documentation - [x] Added support for configurable API version via `DIAL_API_VERSION` environment variable - [x] Added DIAL model restrictions support via `DIAL_ALLOWED_MODELS` environment variable ### Supported DIAL Models: - OpenAI models: o3, o4-mini (and their dated versions) - Google models: gemini-2.5-pro, gemini-2.5-flash (including search variant) - Anthropic models: Claude 4 Opus/Sonnet (with and without thinking mode) ### Environment Variables: - `DIAL_API_KEY`: Required API key for DIAL authentication - `DIAL_API_HOST`: Optional base URL (defaults to https://core.dialx.ai) - `DIAL_API_VERSION`: Optional API version header (defaults to 2025-01-01-preview) - `DIAL_ALLOWED_MODELS`: Optional comma-separated list of allowed models ### Breaking Changes: - None ### Dependencies: - No new dependencies added (uses existing OpenAI SDK with custom routing)
This commit is contained in:
committed by
GitHub
parent
4ae0344b14
commit
0623ce3546
@@ -883,6 +883,7 @@ setup_env_file() {
|
||||
"GEMINI_API_KEY:your_gemini_api_key_here"
|
||||
"OPENAI_API_KEY:your_openai_api_key_here"
|
||||
"XAI_API_KEY:your_xai_api_key_here"
|
||||
"DIAL_API_KEY:your_dial_api_key_here"
|
||||
"OPENROUTER_API_KEY:your_openrouter_api_key_here"
|
||||
)
|
||||
|
||||
@@ -934,6 +935,7 @@ validate_api_keys() {
|
||||
"GEMINI_API_KEY:your_gemini_api_key_here"
|
||||
"OPENAI_API_KEY:your_openai_api_key_here"
|
||||
"XAI_API_KEY:your_xai_api_key_here"
|
||||
"DIAL_API_KEY:your_dial_api_key_here"
|
||||
"OPENROUTER_API_KEY:your_openrouter_api_key_here"
|
||||
)
|
||||
|
||||
@@ -961,6 +963,7 @@ validate_api_keys() {
|
||||
echo " GEMINI_API_KEY=your-actual-key" >&2
|
||||
echo " OPENAI_API_KEY=your-actual-key" >&2
|
||||
echo " XAI_API_KEY=your-actual-key" >&2
|
||||
echo " DIAL_API_KEY=your-actual-key" >&2
|
||||
echo " OPENROUTER_API_KEY=your-actual-key" >&2
|
||||
echo "" >&2
|
||||
print_info "After adding your API keys, run ./run-server.sh again" >&2
|
||||
|
||||
Reference in New Issue
Block a user