feat: LLM重评接入OCG路由代理(:19878)主通道——老莫修复router bug后配置,通道顺序ocg_router→sensenova→key池→gateway,支持pro升级+多key自动选key+并发16
This commit is contained in:
@@ -32,6 +32,10 @@ FALLBACK_MODEL = "deepseek-v4-pro"
|
||||
# 主通道:OCG 上游直连(与 hermes providers.ocg-key6 同源)
|
||||
# key 运行时从 hermes config 读取(SSOT,不落盘到代码库)
|
||||
OCG_URL = "https://opencode.ai/zen/go/v1/chat/completions"
|
||||
# 本地 OCG 路由代理(2026-08-13 老莫修复bug后启用):池化多key自动选最空闲+故障冷却
|
||||
# 与 hermes ocg-router provider 同源,MoFin 重评主通道
|
||||
OCG_ROUTER = "http://127.0.0.1:19878/v1/chat/completions"
|
||||
OCG_ROUTER_AUTH = "Bearer ocg-router-local"
|
||||
_HERMES_CONFIG = "/home/hmo/.hermes/profiles/position-analyst/config.yaml"
|
||||
|
||||
|
||||
@@ -176,15 +180,24 @@ def _post(url, headers, payload, timeout):
|
||||
|
||||
|
||||
def ocg_alive(timeout=8):
|
||||
"""OCG 上游可达性快检(极小请求)。key 缺失直接 False。"""
|
||||
"""OCG 可达性快检(极小请求)。优先本地路由代理,回退直连。"""
|
||||
payload = json.dumps({
|
||||
"model": REASSESS_MODEL,
|
||||
"messages": [{"role": "user", "content": "ping"}],
|
||||
"max_tokens": 1,
|
||||
}).encode()
|
||||
# 本地路由代理
|
||||
try:
|
||||
_post(OCG_ROUTER, {"Content-Type": "application/json",
|
||||
"Authorization": OCG_ROUTER_AUTH,
|
||||
"User-Agent": "curl/8.5.0"}, payload, timeout)
|
||||
return True
|
||||
except Exception:
|
||||
pass
|
||||
# 直连兜底
|
||||
if not OCG_HEADERS:
|
||||
return False
|
||||
try:
|
||||
payload = json.dumps({
|
||||
"model": REASSESS_MODEL,
|
||||
"messages": [{"role": "user", "content": "ping"}],
|
||||
"max_tokens": 1,
|
||||
}).encode()
|
||||
_post(OCG_URL, OCG_HEADERS, payload, timeout)
|
||||
return True
|
||||
except Exception:
|
||||
@@ -233,9 +246,17 @@ def call_llm(prompt, model=None, max_tokens=4096, timeout=150,
|
||||
"max_tokens": max_tokens,
|
||||
}).encode()
|
||||
|
||||
# ── 构建通道列表:SenseNova(快,同款model) → key池(OCG直连) → gateway 兜底 ──
|
||||
# 2026-07-24:OCG开盘高峰45s+/call且空输出高发,SenseNova托管同款deepseek-v4-flash实测3.2s
|
||||
# ── 构建通道列表:SenseNova(快,同款model) → OCG路由代理(本地,自动选key) → key池直连 → gateway 兜底 ──
|
||||
# 2026-08-13 老莫修复 ocg_router bug 后,路由代理作为 OCG 主通道(自动选最空闲key+故障冷却)。
|
||||
# key池直连保留为 fallback(router 不可达时回退)。
|
||||
channels = []
|
||||
# OCG 路由代理第一(2026-08-13 老莫:重评配置到 OCG 路由代理,支持pro升级+多key池)
|
||||
channels.append(("ocg_router", OCG_ROUTER, {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": OCG_ROUTER_AUTH,
|
||||
"User-Agent": "curl/8.5.0",
|
||||
}))
|
||||
# SenseNova 快通道(并发应急,不支持 pro 升级)
|
||||
if SN_HEADERS:
|
||||
channels.append(("sensenova", SN_URL, SN_HEADERS))
|
||||
pool = _get_key_pool()
|
||||
|
||||
Reference in New Issue
Block a user