update 1. GTP-6 Astra, оптимизация кода и фикс

This commit is contained in:
2026-09-26 21:19:09 +03:00
parent 70fce14772
commit 22e10b53b7
31 changed files with 2211 additions and 162 deletions

51
app.py
View File

@@ -30,7 +30,7 @@ from ui_builder import install_ui_builder
from khl_site.khl_data_center import APP as khl_site_app
BASE_DIR = Path(__file__).resolve().parent
BUILD_VERSION = "2026.09.24.4"
BUILD_VERSION = "2026.09.26.1"
# compatibility: BUILD_VERSION = "2026.09.24.2"
# compatibility: BUILD_VERSION = "2026.09.23.8"
# compatibility: BUILD_VERSION = "2026.09.23.7"
@@ -218,45 +218,10 @@ def vmix_demo_data() -> dict[str, Any]:
}
@app.get("/api/vmix/command")
async def vmix_command(
function: str = Query(..., min_length=1),
input_value: str | None = Query(default=None),
) -> dict[str, Any]:
"""Send a shortcut command to the local vMix HTTP API.
The browser calls this same-origin FastAPI route. FastAPI then calls vMix,
so browser CORS restrictions do not block the command.
"""
params: dict[str, str] = {"Function": function}
if input_value not in (None, ""):
params["Input"] = input_value
try:
async with httpx.AsyncClient(timeout=5.0) as client:
response = await client.get(VMIX_API_URL, params=params)
except httpx.RequestError as error:
raise HTTPException(
status_code=502,
detail=f"Не удалось подключиться к vMix по адресу {VMIX_API_URL}: {error}",
) from error
if response.status_code != 200:
raise HTTPException(
status_code=502,
detail={
"message": "vMix вернул ошибку",
"status": response.status_code,
"response": response.text[:1000],
},
)
return {
"ok": True,
"vmix_url": str(response.request.url),
"function": function,
"input": input_value,
}
@app.get("/api/vmix/command", dependencies=[Depends(hockey_auth.require_user)])
async def vmix_command() -> dict[str, Any]:
"""Legacy server-wide command proxy is deliberately disabled."""
raise HTTPException(status_code=410, detail="Используйте команды выбранного Agent через /api/hockey/vmix/sequence")
install_ui_builder(
@@ -273,6 +238,7 @@ install_ui_builder(
},
editor_url="/editor",
runtime_url="/",
custom_early_script_urls=[f"/hockey-assets/match-access.js?v={BUILD_VERSION}"],
custom_script_urls=[
f"/hockey-assets/tournament-menu.js?v={BUILD_VERSION}",
f"/hockey-assets/admin-directories.js?v={BUILD_VERSION}",
@@ -281,6 +247,7 @@ install_ui_builder(
f"/hockey-assets/agent-diagnostics.js?v={BUILD_VERSION}",
],
custom_style_urls=[
f"/hockey-assets/match-access.css?v={BUILD_VERSION}",
"/hockey-assets/tournament-menu.css",
f"/hockey-assets/admin-directories.css?v={BUILD_VERSION}",
"/hockey-assets/match-status-header.css",
@@ -292,7 +259,7 @@ install_ui_builder(
@app.post(
"/api/hockey/ui/prematch-buttons",
dependencies=[Depends(hockey_auth.require_user)],
dependencies=[Depends(hockey_auth.require_admin)],
tags=["Hockey UI"],
)
async def save_hockey_prematch_buttons(payload: dict[str, Any]) -> dict[str, Any]:
@@ -339,7 +306,7 @@ async def save_hockey_prematch_buttons(payload: dict[str, Any]) -> dict[str, Any
@app.post(
"/api/hockey/ui/triggers",
dependencies=[Depends(hockey_auth.require_user)],
dependencies=[Depends(hockey_auth.require_admin)],
tags=["Hockey UI"],
)
async def save_hockey_ui_triggers(payload: dict[str, Any]) -> dict[str, Any]: