refactor: use a single agent model path
This commit is contained in:
@@ -9,6 +9,10 @@ import httpx
|
||||
|
||||
from agent_platform.models import MODEL_SPECS
|
||||
|
||||
LEGACY_MODEL_IDS = {
|
||||
f"{mode}-{strength}" for mode in ("chat", "work") for strength in ("light", "medium", "high", "extreme")
|
||||
}
|
||||
|
||||
|
||||
def _required(name: str) -> str:
|
||||
value = os.getenv(name, "").strip()
|
||||
@@ -33,27 +37,24 @@ def _model_payload() -> list[dict[str, Any]]:
|
||||
public_read = [{"principal_type": "user", "principal_id": "*", "permission": "read"}]
|
||||
items = []
|
||||
for spec in MODEL_SPECS.values():
|
||||
is_chat = spec.mode == "chat"
|
||||
items.append(
|
||||
{
|
||||
"id": spec.public_id,
|
||||
"base_model_id": None,
|
||||
"name": spec.display_name,
|
||||
"params": {"function_calling": "native"} if is_chat else {},
|
||||
"params": {},
|
||||
"meta": {
|
||||
"description": (
|
||||
"快速问答,使用原生工具循环。" if is_chat else "长链路工作,使用 K1412 Work Agent。"
|
||||
),
|
||||
"toolIds": ["server:workspace"] if is_chat else [],
|
||||
"description": (f"K1412 Agent;思考:{spec.thinking_label}。"),
|
||||
"toolIds": [],
|
||||
"capabilities": {
|
||||
"tool_calling": is_chat,
|
||||
"tool_calling": False,
|
||||
"builtin_tools": False,
|
||||
"file_context": False,
|
||||
"citations": False,
|
||||
"vision": False,
|
||||
"file_upload": False,
|
||||
},
|
||||
"tags": [{"name": "Chat" if is_chat else "Work"}],
|
||||
"tags": [{"name": "Agent"}],
|
||||
},
|
||||
"access_grants": public_read,
|
||||
"is_active": True,
|
||||
@@ -151,6 +152,22 @@ async def bootstrap() -> None:
|
||||
)
|
||||
tool_server_response.raise_for_status()
|
||||
|
||||
for model_id in sorted(LEGACY_MODEL_IDS):
|
||||
existing = await client.get(
|
||||
f"{base_url}/api/v1/models/model",
|
||||
headers=headers,
|
||||
params={"id": model_id},
|
||||
)
|
||||
if existing.status_code == 404:
|
||||
continue
|
||||
existing.raise_for_status()
|
||||
delete_response = await client.post(
|
||||
f"{base_url}/api/v1/models/model/delete",
|
||||
headers=headers,
|
||||
json={"id": model_id},
|
||||
)
|
||||
delete_response.raise_for_status()
|
||||
|
||||
model_response = await client.post(
|
||||
f"{base_url}/api/v1/models/import",
|
||||
headers=headers,
|
||||
@@ -158,7 +175,7 @@ async def bootstrap() -> None:
|
||||
)
|
||||
model_response.raise_for_status()
|
||||
|
||||
print("Open WebUI bootstrap complete: auth policy, workspace tools, and eight fixed Agent entries are ready.")
|
||||
print("Open WebUI bootstrap complete: auth policy, workspace tools, and four Agent models are ready.")
|
||||
|
||||
|
||||
def run() -> None:
|
||||
|
||||
Reference in New Issue
Block a user