feat: release v1.0.2 LeKiwi 语言控制与网站嵌入
web-platform-ci / Standalone decision service (no cloud credentials) (push) Has been cancelled
web-platform-ci / TypeScript, lint, unit, build (push) Has been cancelled
web-platform-ci / Playwright E2E (push) Has been cancelled
lekiwi-compatibility / cpu-compatibility (push) Has been cancelled
web-platform-ci / Standalone decision service (no cloud credentials) (push) Has been cancelled
web-platform-ci / TypeScript, lint, unit, build (push) Has been cancelled
web-platform-ci / Playwright E2E (push) Has been cancelled
lekiwi-compatibility / cpu-compatibility (push) Has been cancelled
集成服务器托管模型、自然语言移动与有界抓放、内置 LeKiwi URL 导入和双摄像头;同步部署契约与指定域名 iframe 白名单,保留原有物理安全、会话及调用预算防护。 更新 npm 包及锁文件版本、CHANGELOG 与发布文档。提交前 typecheck、120 项定向前端测试和 44 项后端测试通过(3 项可选跳过);真实 v2 云模型抓放仍待单独验收,不包含运行密钥或构建产物。
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Same-origin public BYOK gateway. Separate from the local Bearer application."""
|
||||
"""Same-origin gateway: hosted defaults or isolated BYOK; separate from local Bearer."""
|
||||
|
||||
import asyncio
|
||||
import hmac
|
||||
@@ -9,7 +9,7 @@ from pathlib import Path
|
||||
import aiohttp
|
||||
from aiohttp import web
|
||||
|
||||
from . import server
|
||||
from . import commands, server
|
||||
from .model_catalog import ModelCatalog
|
||||
from .protocol import DecisionError, fields
|
||||
from .web_config import COOKIE, configure, public_config, website_origin
|
||||
@@ -30,15 +30,27 @@ def view(visitor):
|
||||
"configuration": public_config(s.connections.values),
|
||||
"ready": bool(s.connections.values),
|
||||
"active": len(s.active),
|
||||
"keyStorage": "memory-only",
|
||||
"keyStorage": "server-managed" if visitor.hosted else "memory-only",
|
||||
"configurationManaged": visitor.hosted,
|
||||
}
|
||||
|
||||
|
||||
def create_website_app(
|
||||
origin, directory=None, *, development=False, limits=None, trusted_proxies=()
|
||||
origin,
|
||||
directory=None,
|
||||
*,
|
||||
development=False,
|
||||
limits=None,
|
||||
trusted_proxies=(),
|
||||
defaults=None,
|
||||
budget=None,
|
||||
):
|
||||
host = website_origin(origin, development=development)
|
||||
manager = Sessions(directory or Path("/tmp/cadworld-sessions"), origin, limits)
|
||||
if defaults and budget is None:
|
||||
raise ValueError("hosted_mode_requires_persistent_budget")
|
||||
manager = Sessions(
|
||||
directory or Path("/tmp/cadworld-sessions"), origin, limits, defaults=defaults
|
||||
)
|
||||
catalog = ModelCatalog()
|
||||
cookie = "cadworld-dev-session" if development else COOKIE
|
||||
trusted = set(trusted_proxies)
|
||||
@@ -101,6 +113,12 @@ def create_website_app(
|
||||
):
|
||||
raise DecisionError("configuration_changed", 409)
|
||||
visitor.touched = time.monotonic()
|
||||
if manager.defaults and (
|
||||
request.path.startswith(PREFIX + "/codex/")
|
||||
or request.path
|
||||
in (PREFIX + "/configuration", PREFIX + "/models", PREFIX + "/test")
|
||||
):
|
||||
raise DecisionError("hosted_configuration_locked", 403)
|
||||
request[VISITOR] = visitor
|
||||
request[server.WEB_SERVICE] = visitor.service
|
||||
request[CLIENT_IP] = client_ip(request)
|
||||
@@ -166,7 +184,7 @@ def create_website_app(
|
||||
visitor = request[VISITOR]
|
||||
operation = request.match_info["operation"]
|
||||
llm = visitor.service.connections.values.get("llm")
|
||||
is_llm = operation == "plan" or (
|
||||
is_llm = operation in ("plan", "command") or (
|
||||
operation == "test" and (await server.body(request)).get("role") == "llm"
|
||||
)
|
||||
if is_llm and llm and llm.protocol == "codex" and not visitor.codex_reserved:
|
||||
@@ -174,8 +192,14 @@ def create_website_app(
|
||||
manager.rate(request[CLIENT_IP], "calls", manager.limits.ip_calls)
|
||||
if manager.inference >= manager.limits.inference:
|
||||
raise DecisionError("server_busy", 429)
|
||||
if budget is not None:
|
||||
budget.reserve(2 if operation == "command" else 1)
|
||||
manager.inference += 1
|
||||
try:
|
||||
if operation == "command":
|
||||
return web.json_response(
|
||||
await commands.command(visitor.service, await server.body(request))
|
||||
)
|
||||
return await {
|
||||
"plan": server.plan,
|
||||
"decide": server.decide,
|
||||
@@ -226,7 +250,7 @@ def create_website_app(
|
||||
app.router.add_get(PREFIX + "/status", status)
|
||||
app.router.add_get(PREFIX + "/models", models)
|
||||
app.router.add_put(PREFIX + "/configuration", configuration)
|
||||
app.router.add_post(PREFIX + "/{operation:plan|decide|test}", inference)
|
||||
app.router.add_post(PREFIX + "/{operation:plan|decide|test|command}", inference)
|
||||
app.router.add_post(PREFIX + "/cancel", server.cancel)
|
||||
app.router.add_get(PREFIX + "/codex/{operation:status|models|limits}", codex)
|
||||
app.router.add_post(PREFIX + "/codex/{operation:login|cancel|logout}", codex)
|
||||
|
||||
Reference in New Issue
Block a user