fix: AGNES 三个模型改走香港代理(实测延迟更低、更稳定)

This commit is contained in:
QihuAI Design committed 2026-07-15 20:17:44 +08:00
1 parent ccc5f799e1
commit fd2011b93e
2 files changed
+20 -9

No files matched your search

+14 -7
View File
@@ -138,21 +138,28 @@ def _outbound_proxy() -> str:
return os.environ.get("HTTPS_PROXY") or os.environ.get("HTTP_PROXY") or "http://172.18.0.1:7890"
# 香港出网代理(实测对 AGNES 延迟更低、更稳定,2026-07-15 用户实测)。
# 含 Basic 鉴权,与服务器 /opt/proxy-router/proxy.py 的 UPSTREAM_USER/PASS 一致。
# 注意:智能路由代理 172.18.0.1:7890 对 AGNES 按 DOMESTIC_OVERRIDE 强制直连(曾返 502),
# 故 AGNES 直接打 HK 代理,绕开智能路由代理。
_HK_PROXY = "http://qyyfw:XHR521yhf@103.242.14.208:11495"
def _proxy_for_url(url: str) -> str | None:
"""按目标域名选择是否走代理。
实测(2026-07-15):apihub.agnes-ai.com / platform-outputs.agnes-ai.space 为国内域名,
容器内直连稳定返回 200;而经智能路由代理 172.18.0.1:7890 当前返回 502,导致
httpx 报 "Server disconnected without sending a response"。
因此对 AGNES 等国内域名返回 None(直连),其余域名才走 _outbound_proxy()。
2026-07-15 调整:AGNES(apihub.agnes-ai.com / platform-outputs.agnes-ai.space)
经用户实测走香港代理 103.242.14.208:11495 延迟更低、更稳定,故改为走 HK 代理
(带鉴权),不再直连,也不经智能路由代理(172.18.0.1:7890 对 AGNES 返 502)。
其余国内/平台域名直连,真正的境外域名走 _outbound_proxy()。
注意:httpx 默认 trust_env=True 会忽略 proxy=None 而改用环境变量 HTTP_PROXY,
故调用方必须同时传 trust_env=False 才能真正直连。
注意:httpx 默认 trust_env=True 会忽略 proxy 参数而改用环境变量 HTTP_PROXY,
故调用方必须同时传 trust_env=False 才能真正走此处指定的代理。
"""
from urllib.parse import urlparse
host = (urlparse(url).hostname or "").lower()
if "agnes-ai.com" in host or "agnes-ai.space" in host:
return None
return _HK_PROXY
# 平台自有域名(含自建 Dify/n8n 等)必须直连,不经出网代理。
if "qihuyun.com" in host:
return None