37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
|
|
"""供应商层 HTTP 错讯:DeepSeek / 智谱 品牌与文档链。"""
|
|||
|
|
|
|||
|
|
import httpx
|
|||
|
|
from openai import APIStatusError
|
|||
|
|
|
|||
|
|
from app.core.llm_errors import format_llm_http_error_message
|
|||
|
|
|
|||
|
|
|
|||
|
|
def _status_402() -> APIStatusError:
|
|||
|
|
req = httpx.Request("POST", "https://x/v1/chat/completions")
|
|||
|
|
resp = httpx.Response(402, request=req, json={"error": {"message": "x"}})
|
|||
|
|
return APIStatusError("u", response=resp, body=resp.json())
|
|||
|
|
|
|||
|
|
|
|||
|
|
def test_vendor_deepseek_includes_brand_and_doc() -> None:
|
|||
|
|
e = _status_402()
|
|||
|
|
m = format_llm_http_error_message(e, "deepseek")
|
|||
|
|
assert m is not None
|
|||
|
|
assert "DeepSeek" in m
|
|||
|
|
assert "api-docs.deepseek.com" in m
|
|||
|
|
|
|||
|
|
|
|||
|
|
def test_vendor_zhipu_includes_brand_and_doc() -> None:
|
|||
|
|
e = _status_402()
|
|||
|
|
m = format_llm_http_error_message(e, "zhipu")
|
|||
|
|
assert m is not None
|
|||
|
|
assert "智谱" in m
|
|||
|
|
assert "bigmodel" in m
|
|||
|
|
|
|||
|
|
|
|||
|
|
def test_vendor_none_is_transport_only() -> None:
|
|||
|
|
e = _status_402()
|
|||
|
|
m = format_llm_http_error_message(e, None)
|
|||
|
|
assert m is not None
|
|||
|
|
assert "【" not in m
|
|||
|
|
assert "402" in m
|