feat(compute): 用户端算力中心 base 地址支持公网配置(PINEAGENTS_COMPUTE_PUBLIC_BASE)
- config 加 COMPUTE_PUBLIC_BASE; /opc/compute/base 优先用公网, 回落 request.base_url - 避免经代理显示 127.0.0.1 内部地址; 用户可获真实可用的 /v1 接入地址
This commit is contained in:
@@ -14,6 +14,7 @@ from ..schemas.opc import BidRequest, ProfileUpdate, FinanceRecordCreate
|
||||
from ...rbac import require_roles, write_audit
|
||||
from ...infrastructure.repositories import Database, new_id, utcnow_iso
|
||||
from ...infrastructure.models import FinanceRecord
|
||||
from ... import config
|
||||
from ...services import compute_client, compute_catalog
|
||||
|
||||
router = APIRouter(prefix="/opc", tags=["opc"])
|
||||
@@ -221,14 +222,15 @@ async def opc_compute_base(
|
||||
request: Request,
|
||||
user: dict = Depends(require_roles("opc_member")),
|
||||
):
|
||||
"""用户接入地址:经 server-core /v1 中继(OpenAI 兼容)。"""
|
||||
base = request.base_url.rstrip("/")
|
||||
"""用户接入地址:经 server-core /v1 中继(OpenAI 兼容)。优先用公网配置,回落请求 host。"""
|
||||
base = config.COMPUTE_PUBLIC_BASE or request.base_url.rstrip("/")
|
||||
base = base.rstrip("/")
|
||||
return {
|
||||
"base_url": f"{base}/v1",
|
||||
"relay_path": "/v1/chat/completions",
|
||||
"models_path": "/v1/models",
|
||||
"username": user.get("username"),
|
||||
"hint": "将 base_url 与下方令牌填入 OpenAI 兼容客户端(如 request_url/base)即可调用本平台模型",
|
||||
"hint": "将 base_url 与下方令牌填入 OpenAI 兼容客户端(如 base_url/api_key)即可调用本平台模型",
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user