Salvaged fixes from community PRs: - fix(model_switch): _read_auth_store → _load_auth_store + fix auth store key lookup (was checking top-level dict instead of store['providers']). OAuth providers now correctly detected in /model picker. Cherry-picked from PR #5911 by Xule Lin (linxule). - fix(ollama): pass num_ctx to override 2048 default context window. Ollama defaults to 2048 context regardless of model capabilities. Now auto-detects from /api/show metadata and injects num_ctx into every request. Config override via model.ollama_num_ctx. Fixes #2708. Cherry-picked from PR #5929 by kshitij (kshitijk4poor). - fix(aux): normalize provider aliases for vision/auxiliary routing. Adds _normalize_aux_provider() with 17 aliases (google→gemini, claude→anthropic, glm→zai, etc). Fixes vision routing failure when provider is set to 'google' instead of 'gemini'. Cherry-picked from PR #5793 by e11i (Elizabeth1979). - fix(aux): rewrite MiniMax /anthropic base URLs to /v1 for OpenAI SDK. MiniMax's inference_base_url ends in /anthropic (Anthropic Messages API), but auxiliary client uses OpenAI SDK which appends /chat/completions → 404 at /anthropic/chat/completions. Generic _to_openai_base_url() helper rewrites terminal /anthropic to /v1 for OpenAI-compatible endpoint. Inspired by PR #5786 by Lempkey. Added debug logging to silent exception blocks across all fixes. Co-authored-by: Hermes Agent <hermes@nousresearch.com>
43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
"""Tests for MiniMax auxiliary client URL normalization.
|
|
|
|
MiniMax and MiniMax-CN set inference_base_url to the /anthropic path.
|
|
The auxiliary client uses the OpenAI SDK, which needs /v1 instead.
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))
|
|
|
|
from agent.auxiliary_client import _to_openai_base_url
|
|
|
|
|
|
class TestToOpenaiBaseUrl:
|
|
def test_minimax_global_anthropic_suffix_replaced(self):
|
|
assert _to_openai_base_url("https://api.minimax.io/anthropic") == "https://api.minimax.io/v1"
|
|
|
|
def test_minimax_cn_anthropic_suffix_replaced(self):
|
|
assert _to_openai_base_url("https://api.minimaxi.com/anthropic") == "https://api.minimaxi.com/v1"
|
|
|
|
def test_trailing_slash_stripped_before_replace(self):
|
|
assert _to_openai_base_url("https://api.minimax.io/anthropic/") == "https://api.minimax.io/v1"
|
|
|
|
def test_v1_url_unchanged(self):
|
|
assert _to_openai_base_url("https://api.openai.com/v1") == "https://api.openai.com/v1"
|
|
|
|
def test_openrouter_url_unchanged(self):
|
|
assert _to_openai_base_url("https://openrouter.ai/api/v1") == "https://openrouter.ai/api/v1"
|
|
|
|
def test_anthropic_domain_unchanged(self):
|
|
"""api.anthropic.com doesn't end with /anthropic — should be untouched."""
|
|
assert _to_openai_base_url("https://api.anthropic.com") == "https://api.anthropic.com"
|
|
|
|
def test_anthropic_in_subpath_unchanged(self):
|
|
assert _to_openai_base_url("https://example.com/anthropic/extra") == "https://example.com/anthropic/extra"
|
|
|
|
def test_empty_string(self):
|
|
assert _to_openai_base_url("") == ""
|
|
|
|
def test_none(self):
|
|
assert _to_openai_base_url(None) == ""
|