fix: 支持 HTTP 协议和内网地址访问,修复聊天 URL 缺协议前缀问题

- validate_public_url 默认允许 http 和 https 协议
- 移除 _is_forbidden_ip_address 中 is_private 和 is_site_local 拦截,允许内网 IP
- validate_public_url 中无 scheme 时自动补全 http://
- normalize_openai_base_url 中无协议前缀时自动补全 http://
- pyproject.toml 添加 httpx[socks] 依赖以支持 SOCKS 代理
This commit is contained in:
hsd221
2026-05-03 14:36:45 +08:00
committed by SengokuCola
parent ccabcf5e36
commit e962326f93
3 changed files with 10 additions and 5 deletions

View File

@@ -26,12 +26,17 @@ class OpenAICompatibleRequestOverrides:
def normalize_openai_base_url(base_url: str) -> str:
"""规范化 OpenAI 兼容接口的基础地址。
去掉尾部斜杠,且如果缺少协议前缀则自动补全 http://。
Args:
base_url: 原始基础地址。
Returns:
str: 去掉尾部斜杠后的地址。
str: 规范化后的地址。
"""
base_url = base_url.strip()
if base_url and "://" not in base_url:
base_url = "http://" + base_url
return base_url.rstrip("/")