feat: centralized environment handling, ensures ZEN_MCP_FORCE_ENV_OVERRIDE is honored correctly

fix: updated tests to override env variables they need instead of relying on the current values from .env
This commit is contained in:
Fahad
2025-10-04 14:28:56 +04:00
parent 4015e917ed
commit 2c534ac06e
24 changed files with 300 additions and 179 deletions

View File

@@ -1,9 +1,10 @@
"""Custom API provider implementation."""
import logging
import os
from typing import Optional
from utils.env import get_env
from .openai_compatible import OpenAICompatibleProvider
from .openrouter_registry import OpenRouterModelRegistry
from .shared import ModelCapabilities, ProviderType
@@ -56,9 +57,9 @@ class CustomProvider(OpenAICompatibleProvider):
"""
# Fall back to environment variables only if not provided
if not base_url:
base_url = os.getenv("CUSTOM_API_URL", "")
base_url = get_env("CUSTOM_API_URL", "") or ""
if not api_key:
api_key = os.getenv("CUSTOM_API_KEY", "")
api_key = get_env("CUSTOM_API_KEY", "") or ""
if not base_url:
raise ValueError(