Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: let the Decision API use TypeSafe, Liquid AI, OpenRouter and other System One servers (#12373)
Nilay193c8da03c93
diff --git a/studio/backend/core/inference/external_provider.py b/studio/backend/core/inference/external_provider.pyindex 717049e0ff1..0efc50bbf12 100644--- a/studio/backend/core/inference/external_provider.py+++ b/studio/backend/core/inference/external_provider.py@@ -6896,6 +6896,53 @@ class ExternalProviderClient:media_type = "text/plain" if response_format == "text" else "application/json"return response.content, media_type+ async def create_decision(+ self, model: str, state: Any, questions: dict[str, dict[str, Any]]+ ) -> dict[str, Any]:+ def as_text(value: Any) -> Any:+ return (+ _json.dumps(value, ensure_ascii = False) if isinstance(value, (dict, list)) else value+ )++ sent = {}+ for name, question in questions.items():+ question = dict(question)+ if "instructions" in question:+ question["instructions"] = as_text(question["instructions"])+ criteria = question.get("criteria")+ if isinstance(criteria, dict):+ question["criteria"] = {key: as_text(value) for key, value in criteria.items()}+ elif isinstance(criteria, list):+ question["criteria"] = [as_text(value) for value in criteria]+ sent[name] = question+ response = await _client().post(+ re.sub(r"/systemone$", "", self.base_url.rstrip("/")) + "/systemone",+ headers = self._auth_headers(),+ json = {"model": model, "state": state, "questions": sent},+ timeout = self._timeout,+ )+ response.raise_for_status()+ return response.json()++ async def list_decision_models(self) -> list[str]:+ response = await _client().get(+ re.sub(r"/systemone$", "", self.base_url.rstrip("/")) + "/models",+ params = {"output_modalities": "decisions"},+ headers = self._auth_headers(),+ timeout = self._timeout,+ )+ response.raise_for_status()+ data = response.json()+ models = data.get("data") if isinstance(data, dict) else None+ return [+ model["id"]+ for model in (models if isinstance(models, list) else [])+ if isinstance(model, dict)+ and isinstance(model.get("id"), str)+ and isinstance(model.get("architecture"), dict)+ and "decisions" in (model["architecture"].get("output_modalities") or [])+ ]+async def list_models(self) -> list[dict[str, Any]]:"""GET /models to discover available models. Returns dicts with at least 'id'. All providersexpose /models with the OpenAI {"data": [...]} shape, Anthropic included."""diff --git a/studio/backend/core/inference/mcp_client.py b/studio/backend/core/inference/mcp_client.pyindex fc81d06b266..8b9088a54f1 100644--- a/studio/backend/core/inference/mcp_client.py+++ b/studio/backend/core/inference/mcp_client.py@@ -90,8 +90,8 @@ def _public_mcp_address(url: str) -> str:def validate_mcp_address(url: str) -> None:- # Studio's own Decisions server is answered in process, so no request leaves this machine.- if not _managed_mcp_restricted() or is_studio_decisions(url):+ # Studio's own Decisions server is answered in process; with a local model no request leaves this machine.+ if not _managed_mcp_restricted() or (is_studio_decisions(url) and _local_decisions()):returnif is_stdio(url):from fastapi import HTTPException@@ -556,6 +556,12 @@ def _stdio_argv(parts: list, env: Optional[dict]) -> list:return [executable, *parts[1:]]+def _local_decisions() -> bool:+ from core.systemone.catalog import parse_connection+ from utils.systemone_settings import get_model+ return parse_connection(get_model()) is None++def is_studio_decisions(url: str) -> bool:from routes.systemone import MCP_PATHfrom utils.host_policy import is_loopback_hostdiff --git a/studio/backend/core/inference/providers.py b/studio/backend/core/inference/providers.pyindex e03a94e205f..73a2bfa9355 100644--- a/studio/backend/core/inference/providers.py+++ b/studio/backend/core/inference/providers.py@@ -464,6 +464,28 @@ PROVIDER_REGISTRY: dict[str, dict[str, Any]] = {"notes": "Unified gateway to 300+ models across all major providers. HTTP-Referer and X-Title headers sent for attribution.","model_list_mode": "curated",},+ "typesafe": {+ "display_name": "TypeSafe",+ "base_url": "https://api.typesafe.ai/v1",+ "default_models": ["jev-latest", "jev-1.13"],+ "supports_streaming": False,+ "auth_header": "Authorization",+ "auth_prefix": "Bearer ",+ "notes": "System One decision models. Used by the Decision API, never by chat.",+ "model_list_mode": "curated",+ "decisions_only": True,+ },+ "liquid": {+ "display_name": "Liquid AI",+ "base_url": "https://api.liquid.ai/decisions/v1",+ "default_models": ["d1:free"],+ "supports_streaming": False,+ "auth_header": "Authorization",+ "auth_prefix": "Bearer ",+ "notes": "System One decision models. Used by the Decision API, never by chat.",+ "model_list_mode": "curated",+ "decisions_only": True,+ },}@@ -477,6 +499,13 @@ def get_connectable_provider_info(provider_type: str) -> dict[str, Any] | None:return None if info is None or info.get("managed") else info+def answers_decisions_only(provider_type: str | None, api_type: str | None = None) -> bool:+ info = PROVIDER_REGISTRY.get(provider_type) if isinstance(provider_type, str) else None+ return bool(info and info.get("decisions_only")) or (+ provider_type == "custom" and api_type == "systemone"+ )++def get_base_url(provider_type: str) -> str | None:info = PROVIDER_REGISTRY.get(provider_type)return info["base_url"] if info else Nonediff --git a/studio/backend/core/systemone/catalog.py b/studio/backend/core/systemone/catalog.pyindex 85cd1c96510..11e3e0f3742 100644--- a/studio/backend/core/systemone/catalog.py+++ b/studio/backend/core/systemone/catalog.py@@ -55,23 +55,67 @@ CHECKPOINTS = {# Names TypeSafe's and OpenJev's SDKs send by default, so an unmodified client reaches the configured model.DEFAULT_ALIASES = frozenset({"default", "laya", "jev-latest", "jev-preview", "openjev-latest"})LOCAL_NAME = "laya-local"+CONNECTION_PREFIX = "connection:"-def default_checkpoint() -> Checkpoint:+@dataclass(frozen = True)+class Connection:+ provider_id: str+ model: str++ @property+ def name(self) -> str:+ return f"{CONNECTION_PREFIX}{self.provider_id}:{self.model}"+++def parse_connection(value: object) -> Connection | None:+ if not isinstance(value, str) or not value.startswith(CONNECTION_PREFIX):+ return None+ provider_id, _, model = value[len(CONNECTION_PREFIX) :].partition(":")+ return Connection(provider_id, model) if provider_id and model else None+++LISTED_DECISION_MODELS: dict[tuple[str, str], tuple[float, list[str]]] = {}+++def decision_models(row: dict) -> list[str] | None:+ from core.inference.providers import answers_decisions_only++ if answers_decisions_only(row["provider_type"], row.get("api_type")):+ return row["models"]+ if row["provider_type"] == "openrouter":+ return LISTED_DECISION_MODELS.get((row["id"], row["updated_at"]), (0.0, []))[1]+ return None+++def decision_connections() -> list[tuple[dict, list[str]]]:+ # Connections are per account, the Decision API is installation-wide: read the owner's.+ from storage.providers_db import list_providers+ from utils.account_context import OWNER, run_as+ return [+ (row, models)+ for row in run_as(OWNER, list_providers)+ if row["is_enabled"] and (models := decision_models(row))+ ]+++def default_checkpoint() -> Checkpoint | Connection:from utils.systemone_settings import get_modelconfigured = get_model()if configured in CHECKPOINTS:return CHECKPOINTS[configured]+ if connection := parse_connection(configured):+ return connectionsubfolder = os.environ.get("UNSLOTH_SYSTEMONE_SUBFOLDER", "").strip() or Nonereturn Checkpoint(LOCAL_NAME, configured, subfolder, "Local Laya checkpoint.")-def resolve(model: str) -> Checkpoint | None:+def resolve(model: str) -> Checkpoint | Connection | None:name = (model or "").strip()if name in DEFAULT_ALIASES:return default_checkpoint()- if name == LOCAL_NAME:+ if name == LOCAL_NAME or name.startswith(CONNECTION_PREFIX):checkpoint = default_checkpoint()- return checkpoint if checkpoint.name == LOCAL_NAME else None+ return checkpoint if checkpoint.name == name else Nonereturn CHECKPOINTS.get(name)diff --git a/studio/backend/models/providers.py b/studio/backend/models/providers.pyindex 2e6b6c47951..779220dba3d 100644--- a/studio/backend/models/providers.py+++ b/studio/backend/models/providers.py@@ -7,7 +7,7 @@ from typing import Literal, Optionalfrom pydantic import BaseModel, Field-ProviderApiType = Literal["chat_completions", "responses"]+ProviderApiType = Literal["chat_completions", "responses", "systemone"]MAX_JSON_SAFE_INTEGER = 9_007_199_254_740_991diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.pyindex 038aafb3694..5b8bb33f46d 100644--- a/studio/backend/routes/inference.py+++ b/studio/backend/routes/inference.py@@ -3877,6 +3877,7 @@ from core.inference.passthrough_healing import ()from core.inference.providers import (HOSTED_TOOL_NAMES,+ answers_decisions_only,get_base_url,get_provider_info,hosted_only_tools,@@ -20995,6 +20996,14 @@ async def generate_audio()+def _refuse_decision_connection(provider_type: Optional[str], api_type: Optional[str]) -> None:+ if answers_decisions_only(provider_type, api_type):+ raise HTTPException(+ status_code = 400,+ detail = "This connection answers decisions only. Use it from Settings > API > Decision API.",+ )++async def _external_tts_speech(body: AudioSpeechRequest, request: Request) -> Response:"""Proxy CreateSpeech to a saved connection, so read-aloud skips the local model slot."""provider_id = (body.provider_id or "").strip()@@ -21014,6 +21023,7 @@ async def _external_tts_speech(body: AudioSpeechRequest, request: Request) -> Reconfig = await asyncio.to_thread(providers_db.get_provider, provider_id)if config is None:raise HTTPException(status_code = 404, detail = f"Provider config not found: {provider_id}")+ _refuse_decision_connection(config["provider_type"], config.get("api_type"))if not config["is_enabled"]:raise HTTPException(status_code = 400, detail = f"Provider '{config['display_name']}' is disabled."@@ -21214,6 +21224,7 @@ async def _external_stt_transcription(config = await asyncio.to_thread(providers_db.get_provider, provider_id)if config is None:raise HTTPException(status_code = 404, detail = f"Provider config not found: {provider_id}")+ _refuse_decision_connection(config["provider_type"], config.get("api_type"))if not config["is_enabled"]:raise HTTPException(status_code = 400,@@ -24610,6 +24621,7 @@ async def _proxy_to_external_provider(status_code = 400,detail = "Either provider_id or provider_type is required for external provider routing.",)+ _refuse_decision_connection(provider_type, api_type)# Unsloth's tools run on this host, so any provider whose wire format can# carry a tool schema out and a result back can use them. The capability is@@ -32198,7 +32210,9 @@ async def loaded_inference_models(current_subject: str = Depends(get_current_sub# compatibility alias for the canonical OpenAI path.@router.get("/models/", include_in_schema = False)@router.get("/models")-async def openai_list_models(current_subject: str = Depends(get_current_subject)):+async def openai_list_models(+ output_modalities: Optional[str] = None, current_subject: str = Depends(get_current_subject)+):"""OpenAI-compatible model listing endpoint (``GET /v1/models``).@@ -32206,7 +32220,14 @@ async def openai_list_models(current_subject: str = Depends(get_current_subject)locally available (downloaded/cached) models -- not only what is resident inmemory. Each entry carries a clean public id and a ``loaded`` flag."""- return {"object": "list", "data": await _openai_catalog_objects()}+ wanted = {m.strip() for m in (output_modalities or "").split(",")}+ if not wanted & {"all", "decisions"}:+ return {"object": "list", "data": await _openai_catalog_objects()}+ from routes.systemone import decision_model_objects++ data = [] if wanted == {"decisions"} else await _openai_catalog_objects()+ data += await asyncio.to_thread(decision_model_objects)+ return {"object": "list", "data": data}@router.get("/models/{model_id:path}")diff --git a/studio/backend/routes/providers.py b/studio/backend/routes/providers.pyindex 5f5a50b9533..6d097900b9b 100644--- a/studio/backend/routes/providers.py+++ b/studio/backend/routes/providers.py@@ -12,6 +12,7 @@ import timeimport uuidfrom typing import Optional+import httpximport structlogfrom fastapi import APIRouter, Depends, HTTPException@@ -32,6 +33,7 @@ from core.inference.key_exchange import (get_public_key_pem,)from core.inference.providers import (+ answers_decisions_only,get_base_url,get_connectable_provider_info,get_provider_info,@@ -750,6 +752,41 @@ async def _test_custom_provider_connectivity()+async def _test_decision_connectivity(client, model_id: str) -> ProviderTestResult:+ if not model_id:+ return ProviderTestResult(+ success = False, message = "Connection failed: add a model ID to test with."+ )+ try:+ result = await client.create_decision(+ model_id,+ "The ticket says the checkout page is down.",+ {"outage": {"type": "noul", "instructions": "Is something broken?"}},+ )+ answer = result["answers"]["outage"]+ speaks_system_one = answer["type"] == "noul" and isinstance(answer["noul"], (int, float))+ except httpx.HTTPStatusError as exc:+ if exc.response.status_code not in (404, 405):+ return ProviderTestResult(+ success = False, message = f"Connection failed: {safe_curated_detail(exc)}"+ )+ speaks_system_one = False+ except httpx.HTTPError as exc:+ return ProviderTestResult(+ success = False, message = f"Connection failed: {safe_curated_detail(exc)}"+ )+ except (ValueError, TypeError, KeyError):+ speaks_system_one = False+ if not speaks_system_one:+ return ProviderTestResult(+ success = False,+ message = "Connection failed: this endpoint does not speak the System One API.",+ )+ return ProviderTestResult(+ success = True, message = "Connected successfully. It answered a decision."+ )++@router.post("/test", response_model = ProviderTestResult)async def test_provider(payload: ProviderTestRequest,@@ -805,6 +842,8 @@ async def test_provider()try:+ if answers_decisions_only(payload.provider_type, payload.api_type):+ return await _test_decision_connectivity(client, (payload.model_id or "").strip())if payload.provider_type == "custom":return await _test_custom_provider_connectivity(client, payload.model_id or "", payload.api_type@@ -1014,6 +1053,31 @@ async def list_provider_models(timeout = 15.0,)+ if answers_decisions_only(payload.provider_type, payload.api_type):+ try:+ ids = await client.list_decision_models()+ except httpx.HTTPStatusError as exc:+ status = exc.response.status_code+ if status in (401, 403):+ raise HTTPException(+ status_code = 502, detail = f"The server refused the API key (HTTP {status})."+ ) from None+ if status not in (404, 405):+ raise HTTPException(+ status_code = 502,+ detail = f"The server answered HTTP {status} when asked for its models.",+ ) from None+ ids = []+ except httpx.HTTPError:+ raise HTTPException(+ status_code = 502, detail = "Couldn't reach the server. Check the base URL."+ ) from None+ except ValueError:+ ids = []+ return [+ ProviderModelInfo(id = m, display_name = m, context_length = None, owned_by = None) for m in ids+ ]+try:models = await client.list_models()# Registry model-id filters describe one vendor's own catalog, so they only apply on that vendor's host. Adiff --git a/studio/backend/routes/research_runs.py b/studio/backend/routes/research_runs.pyindex 68515556f02..b4c96c99424 100644--- a/studio/backend/routes/research_runs.py+++ b/studio/backend/routes/research_runs.py@@ -22,7 +22,7 @@ from auth.authentication import get_current_subjectfrom core.inference.message_content import message_text_with_pastesfrom core.inference.web_access_policy import normalize_website_policyfrom storage import research_runs_db as db-from core.inference.providers import provider_runs_local_tools+from core.inference.providers import answers_decisions_only, provider_runs_local_toolsfrom models.providers import MAX_JSON_SAFE_INTEGERfrom storage import providers_dbfrom storage.studio_db import get_chat_message, get_chat_thread, upsert_chat_message@@ -258,7 +258,11 @@ def _sanitize_config(# sent: a self-hosted connection is stored under the backend "openai" type but surfaced as "custom" / "vllm" /# "ollama" / "llama_cpp", so comparing the two for equality 400s exactly the connections this path serves.saved_provider_type = provider["provider_type"]- if not provider_runs_local_tools(saved_provider_type) or not provider["is_enabled"]:+ if (+ not provider_runs_local_tools(saved_provider_type)+ or not provider["is_enabled"]+ or answers_decisions_only(saved_provider_type, provider.get("api_type"))+ ):raise HTTPException(status_code = 400,detail = "Durable research requires an enabled connection whose provider supports Unsloth tools",diff --git a/studio/backend/routes/settings.py b/studio/backend/routes/settings.pyindex 5a2e7185627..37dca75f757 100644--- a/studio/backend/routes/settings.py+++ b/studio/backend/routes/settings.py@@ -633,6 +633,13 @@ class SystemOneModelOption(BaseModel):download_bytes: int+class SystemOneConnectionOption(BaseModel):+ name: str+ provider_id: str+ provider: str+ model: str++class SystemOneSettingsResponse(BaseModel):enabled: boolenabled_locked: bool@@ -1459,11 +1466,25 @@ def get_systemone_settings(return _systemone_response(request)+async def _refresh_decision_models(payload: SystemOneSettingsPayload) -> None:+ from core.systemone import catalog+ from routes.systemone import refresh_listed_decision_models+ if catalog.parse_connection(payload.model):+ await refresh_listed_decision_models()++@_owner_settings_router.put("/systemone", response_model = SystemOneSettingsResponse)-def update_systemone_settings(+async def update_systemone_settings(payload: SystemOneSettingsPayload,request: Request,current_subject: str = Depends(get_current_subject),+) -> SystemOneSettingsResponse:+ await _refresh_decision_models(payload)+ return await asyncio.to_thread(_save_systemone_settings, payload, request)+++def _save_systemone_settings(+ payload: SystemOneSettingsPayload, request: Request) -> SystemOneSettingsResponse:from core.systemone import laya_runtimewith _SYSTEMONE_SETTINGS_LOCK:@@ -1480,9 +1501,14 @@ def update_systemone_settings(@_owner_settings_router.post("/systemone/validate", status_code = 204)-def validate_systemone_settings(+async def validate_systemone_settings(payload: SystemOneSettingsPayload, current_subject: str = Depends(get_current_subject)) -> None:+ await _refresh_decision_models(payload)+ await asyncio.to_thread(_validate_systemone_settings, payload)+++def _validate_systemone_settings(payload: SystemOneSettingsPayload) -> None:from core.systemone import laya_runtimewith _SYSTEMONE_SETTINGS_LOCK:_check_systemone_expectations(payload)@@ -1494,15 +1520,43 @@ def validate_systemone_settings(raise HTTPException(status_code = 409, detail = exc.message) from None+@_owner_settings_router.get(+ "/systemone/connections", response_model = list[SystemOneConnectionOption]+)+async def list_systemone_connections(+ current_subject: str = Depends(get_current_subject),+) -> list[SystemOneConnectionOption]:+ from core.systemone import catalog+ from routes.systemone import refresh_listed_decision_models++ await refresh_listed_decision_models()+ return [+ SystemOneConnectionOption(+ name = catalog.Connection(row["id"], model).name,+ provider_id = row["id"],+ provider = row["display_name"],+ model = model,+ )+ for row, models in await asyncio.to_thread(catalog.decision_connections)+ for model in models+ ]++@_owner_settings_router.get("/systemone/resolve", response_model = SystemOneDownloadPlan)def resolve_systemone_download(model: Optional[str] = None, current_subject: str = Depends(get_current_subject)) -> SystemOneDownloadPlan:from core.systemone import catalog, laya_runtime- checkpoint = catalog.default_checkpoint() if model is None else catalog.resolve(model)+ checkpoint = (+ catalog.default_checkpoint()+ if model is None+ else catalog.parse_connection(model) or catalog.resolve(model)+ )if checkpoint is None:raise HTTPException(status_code = 400, detail = "Unknown Decision API model.")+ if isinstance(checkpoint, catalog.Connection):+ return SystemOneDownloadPlan(files = [], size_bytes = 0, cached = True)return SystemOneDownloadPlan(**laya_runtime.download_plan(checkpoint))diff --git a/studio/backend/routes/systemone.py b/studio/backend/routes/systemone.pyindex a95ba417e12..0033d07851f 100644--- a/studio/backend/routes/systemone.py+++ b/studio/backend/routes/systemone.py@@ -1,25 +1,34 @@# SPDX-License-Identifier: AGPL-3.0-only# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-"""Jev-compatible System One API: typed decisions (noul / choice / score) read off a Laya checkpoint."""+"""Jev-compatible System One API: typed decisions (noul / choice / score) from a Laya checkpoint or a saved connection."""from __future__ import annotations+import asyncioimport jsonimport math+import timefrom typing import Any, Optional, Unionfrom uuid import uuid4+import httpxfrom fastapi import APIRouter, Depends, HTTPException, Requestfrom fastapi.responses import JSONResponse+from starlette.concurrency import run_in_threadpoolfrom fastmcp import FastMCPfrom fastmcp.exceptions import ToolErrorfrom fastmcp.server.middleware import Middlewarefrom pydantic import BaseModel, ConfigDict, Fieldfrom auth.authentication import get_current_subject, security+from core.inference.external_provider import ExternalProviderClient+from core.inference.providers import answers_decisions_only, validate_provider_base_urlfrom core.systemone import catalog, laya_runtime+from routes.provider_credentials import provider_config_guard, resolve_provider_api_key_or_400+from storage import providers_dbfrom utils import systemone_settings+from utils.account_context import OWNER, arun_as, run_asMAX_QUESTIONS = 64MAX_CHOICES = 255@@ -28,6 +37,7 @@ MAX_STATE_CHARS = 200_000MAX_QUESTION_CHARS = 20_000_TYPES = ("noul", "choice", "score")MCP_PATH = "/mcp/decisions"+LISTED_MODELS_TTL = 300.0router = APIRouter()@@ -114,31 +124,34 @@ def _validate(name: str, question: QuestionIn) -> None:@router.post("/systemone")-def system_one(+async def system_one(payload: SystemOneRequest,request: Request,current_subject: str = Depends(get_current_subject),):- _require_enabled()+ # Settings and key checks read SQLite: keep them off the event loop.+ await asyncio.to_thread(_require_enabled)if payload.model_extra:raise _error(400,"api_usage_error",f"Unsupported field(s): {', '.join(sorted(payload.model_extra))}",)- checkpoint = catalog.resolve(payload.model)+ checkpoint = await asyncio.to_thread(catalog.resolve, payload.model)if checkpoint is None:raise _error(400, "api_usage_error", f"Unknown model: {payload.model}")from auth.authentication import request_admitted_without_credential# Same rule as the OpenAI routes: a keyless caller never downloads or swaps in another model.- if checkpoint != catalog.default_checkpoint() and request_admitted_without_credential(request):+ if checkpoint != await asyncio.to_thread(+ catalog.default_checkpoint+ ) and await asyncio.to_thread(request_admitted_without_credential, request):raise _error(403,"permission_error","Keyless requests can only use the configured Decision API model; send an API key to pick another.",)- result = _decide(checkpoint, payload.state, payload.questions)+ result = await _decide(checkpoint, payload.state, payload.questions)return JSONResponse(result, headers = {"x-typesafe-request-id": str(uuid4())})@@ -151,8 +164,10 @@ def _require_enabled() -> None:)-def _decide(- checkpoint: catalog.Checkpoint, state: JSONContent, questions: dict[str, QuestionIn]+async def _decide(+ checkpoint: catalog.Checkpoint | catalog.Connection,+ state: JSONContent,+ questions: dict[str, QuestionIn],) -> dict:if not questions:raise _error(422, "invalid_request_error", "At least one question is required")@@ -168,9 +183,18 @@ def _decide(for name, question in questions.items():_validate(name, question)+ if isinstance(checkpoint, catalog.Connection):+ return await _connection_decide(+ checkpoint,+ state,+ {name: q.model_dump(exclude_unset = True) for name, q in questions.items()},+ )try:- result = laya_runtime.decide(- checkpoint, state, {name: q.model_dump() for name, q in questions.items()}+ result = await run_in_threadpool(+ laya_runtime.decide,+ checkpoint,+ state,+ {name: q.model_dump() for name, q in questions.items()},)except laya_runtime.Unavailable as exc:raise _error(exc.status, exc.error_type, exc.message, exc.retry_after) from None@@ -184,9 +208,136 @@ def _decide(return result+async def _connection_decide(+ connection: catalog.Connection, state: JSONContent, questions: dict[str, dict[str, Any]]+) -> dict:+ # The connection and its key are the owner's; the URL check and the request run as the caller,+ # so a managed account keeps its egress policy.+ provider_id = connection.provider_id+ config = await asyncio.to_thread(run_as, OWNER, providers_db.get_provider, provider_id)+ if config is None or catalog.decision_models(config) is None:+ raise _error(+ 503,+ "api_usage_error",+ "The Decision API connection was removed. Pick another model in Settings > API.",+ )+ # OpenRouter's list is a cache, empty until refreshed; a decision connection's saved models are authoritative.+ if (+ answers_decisions_only(config["provider_type"], config.get("api_type"))+ and connection.model not in config["models"]+ ):+ raise _error(+ 503,+ "api_usage_error",+ f"'{connection.model}' is no longer enabled on '{config['display_name']}'. Pick another model in Settings > API.",+ )+ if not config["is_enabled"]:+ raise _error(503, "api_usage_error", f"Connection '{config['display_name']}' is disabled.")+ try:+ base_url = await asyncio.to_thread(validate_provider_base_url, config["base_url"])+ except ValueError as exc:+ raise _error(503, "api_usage_error", str(exc)) from None+ api_key = await arun_as(OWNER, _connection_key(provider_id, config))+ client = ExternalProviderClient(config["provider_type"], base_url, api_key)+ try:+ result = await client.create_decision(connection.model, state, questions)+ except httpx.HTTPStatusError as exc:+ raise _upstream_error(config["display_name"], exc.response) from None+ except (httpx.HTTPError, ValueError) as exc:+ raise _error(+ 502, "api_error", f"Couldn't reach '{config['display_name']}': {type(exc).__name__}"+ ) from None+ if not isinstance(result, dict) or not isinstance(result.get("answers"), dict):+ raise _error(+ 502, "api_error", f"'{config['display_name']}' did not answer in the System One format."+ )+ return result+++async def _connection_key(provider_id: str, config: dict) -> str:+ routing_fields = ("provider_type", "base_url", "api_type", "is_enabled")+ async with provider_config_guard(provider_id):+ current = await asyncio.to_thread(providers_db.get_provider, provider_id)+ if current is None or any(current.get(f) != config.get(f) for f in routing_fields):+ raise _error(409, "api_usage_error", "The connection changed while starting; retry.")+ try:+ api_key = await asyncio.to_thread(+ resolve_provider_api_key_or_400, provider_id, None, prefer_saved_key = True+ )+ except HTTPException as exc:+ raise _error(500, "api_error", exc.detail) from None+ latest = await asyncio.to_thread(providers_db.get_provider, provider_id)+ if latest is None or any(latest.get(f) != current.get(f) for f in routing_fields):+ raise _error(409, "api_usage_error", "The connection changed while starting; retry.")+ return api_key+++async def refresh_listed_decision_models() -> None:+ rows = await asyncio.to_thread(run_as, OWNER, providers_db.list_providers)+ for row in rows:+ if row["provider_type"] != "openrouter" or not row["is_enabled"]:+ continue+ key = (row["id"], row["updated_at"])+ cached = catalog.LISTED_DECISION_MODELS.get(key)+ if cached and cached[1] and time.monotonic() - cached[0] < LISTED_MODELS_TTL:+ continue+ try:+ api_key = await asyncio.to_thread(+ run_as,+ OWNER,+ resolve_provider_api_key_or_400,+ row["id"],+ None,+ prefer_saved_key = True,+ )+ client = ExternalProviderClient(row["provider_type"], row["base_url"], api_key, 10.0)+ models = await arun_as(OWNER, client.list_decision_models())+ except Exception:+ models = []+ catalog.LISTED_DECISION_MODELS[key] = (time.monotonic(), models)+++def decision_model_objects() -> list[dict[str, Any]]:+ if not systemone_settings.get_enabled():+ return []+ return [+ {+ "id": name,+ "object": "model",+ "owned_by": "unsloth",+ "architecture": {"input_modalities": ["text"], "output_modalities": ["decisions"]},+ }+ for name in (+ "default",+ *(() if systemone_settings.runtime_unavailable_reason() else catalog.CHECKPOINTS),+ )+ ]+++def _upstream_error(name: str, response: httpx.Response) -> HTTPException:+ try:+ body = response.json()+ except ValueError:+ body = None+ detail = (body.get("detail") or body.get("error")) if isinstance(body, dict) else None+ if isinstance(detail, str):+ detail = {"message": detail}+ elif not isinstance(detail, dict):+ detail = {}+ message = str(detail.get("message") or f"'{name}' answered HTTP {response.status_code}.")+ if response.status_code in (429, 503, 529):+ try:+ retry_after = float(response.headers.get("retry-after", ""))+ except ValueError:+ retry_after = None+ error_type = str(detail.get("error_type") or "overloaded")+ return _error(response.status_code, error_type, message, retry_after)+ return _error(502, "api_error", message)++class DecisionsAvailability(Middleware):async def on_list_tools(self, context, call_next):- if not systemone_settings.get_enabled():+ if not await asyncio.to_thread(systemone_settings.get_enabled):return []return await call_next(context)@@ -196,15 +347,16 @@ decisions_mcp.add_middleware(DecisionsAvailability())@decisions_mcp.tool-def decide(state: JSONContent, questions: dict[str, QuestionIn]) -> dict[str, Any]:- """Ask Unsloth's local Laya decision model typed questions about a state (text or JSON).+async def decide(state: JSONContent, questions: dict[str, QuestionIn]) -> dict[str, Any]:+ """Ask Unsloth's decision model typed questions about a state (text or JSON).questions maps a name you pick to {"type", "instructions", "criteria"}, for example{"urgent": {"type": "noul", "instructions": "Does this need a reply within the hour?"}}."noul" is yes/no and answers a probability; "choice" needs criteria mapping each option nameto a description; "score" needs criteria listing 1 to 10 levels, lowest first."""try:- _require_enabled()- return _decide(catalog.default_checkpoint(), state, questions)+ await asyncio.to_thread(_require_enabled)+ checkpoint = await asyncio.to_thread(catalog.default_checkpoint)+ return await _decide(checkpoint, state, questions)except HTTPException as exc:raise ToolError(exc.detail["message"]) from Nonediff --git a/studio/backend/tests/test_systemone_connections.py b/studio/backend/tests/test_systemone_connections.pynew file mode 100644index 00000000000..91bf69d589a--- /dev/null+++ b/studio/backend/tests/test_systemone_connections.py@@ -0,0 +1,585 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import asyncio+import json+from types import SimpleNamespace++import httpx+import pytest+from fastapi import FastAPI, HTTPException+from fastapi.testclient import TestClient++from auth.authentication import authenticated_via_api_key, get_current_subject+from core.inference import external_provider as ep+from core.systemone import catalog, laya_runtime+from routes import systemone+from storage import credential_secrets, providers_db+from utils import systemone_settings+from utils.account_context import AccountContext, run_as++QUESTIONS = {+ "urgent": {"type": "noul", "instructions": {"ask": "Reply within the hour?"}},+ "team": {+ "type": "choice",+ "instructions": "Which team?",+ "criteria": {"outage": {"signals": ["down"]}, "billing": "charges"},+ },+}+UPSTREAM = {+ "model": "jev-1.13",+ "answers": {+ "urgent": {"type": "noul", "noul": 0.93},+ "team": {"type": "choice", "choice": "outage", "confidence": 0.8},+ },+ "usage": {"input_tokens": 50, "output_tokens": 0, "cost_usd": 0.0001},+}+OPENROUTER_MODELS = {+ "data": [+ {+ "id": "upstage/solar-decide",+ "architecture": {"input_modalities": ["text"], "output_modalities": ["decisions"]},+ },+ {+ "id": "typesafe/jev-1.13",+ "architecture": {"input_modalities": ["text"], "output_modalities": ["decisions"]},+ },+ {+ "id": "openai/gpt-4o",+ "architecture": {"input_modalities": ["text", "image"], "output_modalities": ["text"]},+ },+ ]+}++[email protected](autouse = True)+def studio(monkeypatch, tmp_path):+ monkeypatch.setenv("UNSLOTH_STUDIO_HOME", str(tmp_path))+ monkeypatch.delenv("UNSLOTH_SYSTEMONE_MODEL", raising = False)+ monkeypatch.delenv("UNSLOTH_SYSTEMONE_DISABLE", raising = False)+ for module in (credential_secrets, providers_db):+ monkeypatch.setattr(module, "_schema_ready", set())+ monkeypatch.setattr(+ credential_secrets, "get_or_create_credential_encryption_key", lambda: b"k" * 32+ )+ import storage.studio_db as studio_db++ settings = {systemone_settings.ENABLED_KEY: True}+ monkeypatch.setattr(systemone_settings, "_owner_setting", settings.get)+ monkeypatch.setattr(studio_db, "upsert_app_settings", settings.update)+ monkeypatch.setattr(+ systemone_settings, "runtime_unavailable_reason", lambda: "The Decision API needs PyTorch."+ )++ def no_laya(*args):+ raise AssertionError("a connection must not load Laya")++ monkeypatch.setattr(laya_runtime, "decide", no_laya)+ monkeypatch.setattr(catalog, "LISTED_DECISION_MODELS", {})+ return settings+++def upstream(monkeypatch):+ calls = []+ replies = [httpx.Response(200, json = UPSTREAM)]++ def handle(request):+ calls.append(request)+ return replies[0]++ monkeypatch.setattr(+ ep, "_http_client", httpx.AsyncClient(transport = httpx.MockTransport(handle))+ )+ return SimpleNamespace(calls = calls, replies = replies)+++def _connection(+ provider_type = "typesafe",+ api_type = "chat_completions",+ base_url = "https://api.typesafe.ai/v1",+):+ providers_db.create_provider(+ id = "deciders",+ provider_type = provider_type,+ display_name = "TypeSafe",+ base_url = base_url,+ models = ["jev-latest"],+ api_type = api_type,+ )+ credential_secrets.save_provider_api_key("deciders", "ts-key")+ return "connection:deciders:jev-latest"+++def _client():+ from routes.settings import router as settings_router++ app = FastAPI()+ app.include_router(systemone.router, prefix = "/v1")+ app.include_router(settings_router, prefix = "/api/settings")+ app.dependency_overrides[get_current_subject] = lambda: "tester"+ return TestClient(app)+++def _post(client, model = "jev-latest"):+ return client.post(+ "/v1/systemone", json = {"model": model, "state": "The site is down.", "questions": QUESTIONS}+ )+++def test_decision_api_answers_through_a_saved_connection(upstream):+ client = _client()+ name = _connection()+ assert client.get("/api/settings/systemone/connections").json() == [+ {"name": name, "provider_id": "deciders", "provider": "TypeSafe", "model": "jev-latest"}+ ]+ saved = client.put("/api/settings/systemone", json = {"model": name})+ assert saved.status_code == 200, saved.text+ assert saved.json()["model"] == name++ for model in ("default", name):+ response = _post(client, model)+ assert response.status_code == 200, response.text+ assert response.json() == UPSTREAM++ request = upstream.calls[-1]+ assert str(request.url) == "https://api.typesafe.ai/v1/systemone"+ assert request.headers["authorization"] == "Bearer ts-key"+ body = json.loads(request.content)+ assert body["model"] == "jev-latest"+ assert body["state"] == "The site is down."+ assert body["questions"]["urgent"] == {+ "type": "noul",+ "instructions": json.dumps({"ask": "Reply within the hour?"}),+ }+ assert body["questions"]["team"]["criteria"] == {+ "outage": json.dumps({"signals": ["down"]}),+ "billing": "charges",+ }+++def test_a_connection_can_be_enabled_without_local_torch(upstream, studio):+ client = _client()+ studio[systemone_settings.ENABLED_KEY] = False+ refused = client.put("/api/settings/systemone", json = {"enabled": True})+ assert refused.status_code == 400+ name = _connection()+ enabled = client.put("/api/settings/systemone", json = {"enabled": True, "model": name})+ assert enabled.status_code == 200, enabled.text+ assert client.get("/api/settings/systemone/resolve").json()["cached"] is True+ other = "connection:deciders:jev-1.13"+ plan = client.get("/api/settings/systemone/resolve", params = {"model": other})+ assert plan.status_code == 200, plan.text+ assert plan.json()["cached"] is True+++def test_a_remote_decision_api_cannot_switch_to_a_local_model_without_torch(studio):+ client = _client()+ studio[systemone_settings.ENABLED_KEY] = False+ name = _connection()+ assert (+ client.put("/api/settings/systemone", json = {"enabled": True, "model": name}).status_code+ == 200+ )+ for route in ("validate", ""):+ refused = client.request(+ "POST" if route else "PUT",+ f"/api/settings/systemone/{route}".rstrip("/"),+ json = {"model": "laya-english"},+ )+ assert refused.status_code == 400+ assert refused.json()["detail"] == "The Decision API needs PyTorch."+ assert client.get("/api/settings/systemone").json()["model"] == name+ off = client.put("/api/settings/systemone", json = {"enabled": False, "model": "laya-english"})+ assert off.status_code == 200, off.text+++def test_a_custom_system_one_connection_is_called_at_its_base_url(upstream):+ client = _client()+ name = _connection("custom", "systemone", "http://decider.example/v1/systemone")+ assert client.put("/api/settings/systemone", json = {"model": name}).status_code == 200+ assert _post(client).status_code == 200+ assert str(upstream.calls[-1].url) == "http://decider.example/v1/systemone"+++def test_openrouter_offers_its_decision_models(upstream):+ upstream.replies[0] = httpx.Response(200, json = OPENROUTER_MODELS)+ providers_db.create_provider(+ id = "router",+ provider_type = "openrouter",+ display_name = "OpenRouter",+ base_url = "https://openrouter.ai/api/v1",+ models = ["openai/gpt-4o"],+ )+ credential_secrets.save_provider_api_key("router", "or-key")+ client = _client()+ listed = client.get("/api/settings/systemone/connections").json()+ assert [option["model"] for option in listed] == ["upstage/solar-decide", "typesafe/jev-1.13"]+ request = upstream.calls[0]+ assert request.url.params["output_modalities"] == "decisions"+ assert request.headers["authorization"] == "Bearer or-key"++ client.get("/api/settings/systemone/connections")+ assert len(upstream.calls) == 1+ saved = client.put("/api/settings/systemone", json = {"model": listed[1]["name"]})+ assert saved.status_code == 200, saved.text+ upstream.replies[0] = httpx.Response(200, json = UPSTREAM)+ assert _post(client).status_code == 200+ assert json.loads(upstream.calls[-1].content)["model"] == "typesafe/jev-1.13"+ assert str(upstream.calls[-1].url) == "https://openrouter.ai/api/v1/systemone"+++def test_an_openrouter_decision_model_saves_without_a_listed_copy(upstream, monkeypatch):+ upstream.replies[0] = httpx.Response(200, json = OPENROUTER_MODELS)+ providers_db.create_provider(+ id = "router",+ provider_type = "openrouter",+ display_name = "OpenRouter",+ base_url = "https://openrouter.ai/api/v1",+ models = ["openai/gpt-4o"],+ )+ credential_secrets.save_provider_api_key("router", "or-key")+ client = _client()+ name = "connection:router:typesafe/jev-1.13"+ assert client.post("/api/settings/systemone/validate", json = {"model": name}).status_code == 204+ assert client.put("/api/settings/systemone", json = {"model": name}).status_code == 200++ monkeypatch.setattr(catalog, "LISTED_DECISION_MODELS", {})+ upstream.replies[0] = httpx.Response(503, json = {"error": {"message": "down"}})+ client.get("/api/settings/systemone/connections")+ upstream.replies[0] = httpx.Response(200, json = OPENROUTER_MODELS)+ assert client.put("/api/settings/systemone", json = {"model": name}).status_code == 200+ chat = client.put("/api/settings/systemone", json = {"model": "connection:router:openai/gpt-4o"})+ assert chat.status_code == 400+++def test_an_unreachable_openrouter_lists_no_decision_models(upstream):+ upstream.replies[0] = httpx.Response(401, json = {"error": {"message": "No auth"}})+ providers_db.create_provider(+ id = "router",+ provider_type = "openrouter",+ display_name = "OpenRouter",+ base_url = "https://openrouter.ai/api/v1",+ models = ["openai/gpt-4o"],+ )+ credential_secrets.save_provider_api_key("router", "or-key")+ response = _client().get("/api/settings/systemone/connections")+ assert response.status_code == 200+ assert response.json() == []+++def test_only_saved_decision_connections_are_accepted_as_the_model():+ client = _client()+ _connection()+ providers_db.create_provider(+ id = "chat", provider_type = "openai", display_name = "OpenAI", base_url = "", models = ["gpt-5.5"]+ )+ providers_db.create_provider(+ id = "vllm", provider_type = "custom", display_name = "vLLM", base_url = "", models = ["qwen"]+ )+ for model in (+ "connection:deciders:other",+ "connection:chat:gpt-5.5",+ "connection:vllm:qwen",+ "connection:gone:x",+ ):+ response = client.put("/api/settings/systemone", json = {"model": model})+ assert response.status_code == 400, model+ saved = client.put("/api/settings/systemone", json = {"model": "connection:deciders:jev-latest"})+ assert saved.status_code == 200, saved.text++[email protected]("status", [429, 503, 529])+def test_upstream_backpressure_keeps_the_decision_api_error_shape(upstream, status):+ client = _client()+ client.put("/api/settings/systemone", json = {"model": _connection()})+ upstream.replies[0] = httpx.Response(+ status,+ headers = {"Retry-After": "7"},+ json = {"detail": {"error_type": "rate_limited", "message": "Slow down"}},+ )+ response = _post(client)+ assert response.status_code == status+ assert response.headers["retry-after"] == "7"+ assert response.json() == {"detail": {"error_type": "rate_limited", "message": "Slow down"}}+++def test_an_upstream_text_detail_reaches_the_caller(upstream):+ client = _client()+ client.put("/api/settings/systemone", json = {"model": _connection()})+ upstream.replies[0] = httpx.Response(400, json = {"detail": "Unknown model jev-9"})+ response = _post(client)+ assert response.status_code == 502+ assert response.json()["detail"]["message"] == "Unknown model jev-9"+++def test_durable_research_refuses_a_decision_connection():+ from routes.research_runs import CreateResearchRun, _sanitize_config++ _connection("custom", "systemone", "http://decider.example/v1")+ payload = CreateResearchRun(+ threadId = "t",+ userMessageId = "u",+ inferenceRequest = {+ "providerId": "deciders",+ "providerType": "custom",+ "externalModel": "jev-latest",+ },+ )+ with pytest.raises(HTTPException) as refused:+ _sanitize_config(payload, {"modelId": "local-model"})+ assert refused.value.status_code == 400+++def test_a_model_unticked_on_the_connection_is_not_called(upstream):+ client = _client()+ client.put("/api/settings/systemone", json = {"model": _connection()})+ providers_db.update_provider("deciders", models = ["jev-1.13"])+ response = _post(client)+ assert response.status_code == 503+ assert "no longer enabled" in response.json()["detail"]["message"]+ assert upstream.calls == []+++def test_a_disabled_connection_is_not_called(upstream):+ client = _client()+ client.put("/api/settings/systemone", json = {"model": _connection()})+ providers_db.update_provider("deciders", is_enabled = False)+ response = _post(client)+ assert response.status_code == 503+ assert "disabled" in response.json()["detail"]["message"]+ assert upstream.calls == []+++def test_decisions_mcp_uses_the_connection(upstream):+ from fastmcp import Client++ _client().put("/api/settings/systemone", json = {"model": _connection()})++ async def call():+ async with Client(systemone.decisions_mcp) as mcp:+ return await mcp.call_tool("decide", {"state": "x", "questions": QUESTIONS})++ assert asyncio.run(call()).structured_content == UPSTREAM+ assert len(upstream.calls) == 1+++def test_decision_settings_are_read_off_the_event_loop(upstream, studio, monkeypatch):+ import threading++ from fastmcp import Client++ client = _client()+ loop_threads = []+ read_on_loop = []++ @client.app.middleware("http")+ async def note_loop_thread(request, call_next):+ loop_threads.append(threading.current_thread())+ return await call_next(request)++ assert client.put("/api/settings/systemone", json = {"model": _connection()}).status_code == 200++ def read(key, fallback = None):+ if threading.current_thread() in loop_threads:+ read_on_loop.append(key)+ return studio.get(key, fallback)++ monkeypatch.setattr(systemone_settings, "_owner_setting", read)+ assert _post(client, "default").status_code == 200++ async def call():+ loop_threads.append(threading.current_thread())+ async with Client(systemone.decisions_mcp) as mcp:+ return await mcp.call_tool("decide", {"state": "x", "questions": QUESTIONS})++ assert asyncio.run(call()).structured_content == UPSTREAM+ assert read_on_loop == []+++def test_a_managed_caller_keeps_its_egress_policy_on_an_owner_connection(upstream):+ from utils.account_context import arun_as++ _client().put("/api/settings/systemone", json = {"model": _connection()})+ providers_db.update_provider("deciders", base_url = "http://127.0.0.1:9/v1")+ alice = AccountContext("a" * 32, "alice")+ with pytest.raises(HTTPException) as refused:+ asyncio.run(+ arun_as(+ alice,+ systemone._decide(+ catalog.Connection("deciders", "jev-latest"),+ "x",+ {name: systemone.QuestionIn(**q) for name, q in QUESTIONS.items()},+ ),+ )+ )+ assert refused.value.status_code == 503+ assert "removed" not in refused.value.detail["message"]+ assert upstream.calls == []+++def test_managed_accounts_lose_the_decisions_mcp_bypass_for_a_connection():+ from core.inference.mcp_client import validate_mcp_address++ alice = AccountContext("a" * 32, "alice")+ url = f"http://127.0.0.1:8888{systemone.MCP_PATH}/"+ run_as(alice, validate_mcp_address, url)+ _client().put("/api/settings/systemone", json = {"model": _connection()})+ with pytest.raises(HTTPException):+ run_as(alice, validate_mcp_address, url)+++def _providers_post(path, payload):+ from routes import providers++ app = FastAPI()+ app.include_router(providers.router, prefix = "/providers")+ app.dependency_overrides[get_current_subject] = lambda: "tester"+ app.dependency_overrides[authenticated_via_api_key] = lambda: False+ return TestClient(app).post(path, json = payload).json()+++def _provider_test(payload):+ return _providers_post("/providers/test", payload)+++def test_a_system_one_connection_lists_only_decision_models(upstream):+ upstream.replies[0] = httpx.Response(200, json = OPENROUTER_MODELS)+ listed = _providers_post(+ "/providers/models",+ {+ "provider_type": "custom",+ "api_type": "systemone",+ "base_url": "http://localhost:8888/v1",+ },+ )+ assert [model["id"] for model in listed] == ["upstage/solar-decide", "typesafe/jev-1.13"]+ assert upstream.calls[0].url.params["output_modalities"] == "decisions"++ _providers_post(+ "/providers/models",+ {+ "provider_type": "custom",+ "api_type": "systemone",+ "base_url": "http://localhost:8888/v1/systemone",+ },+ )+ assert upstream.calls[-1].url.path == "/v1/models"++ upstream.replies[0] = httpx.Response(200, json = {"data": [{"id": "HuggingFaceTB/SmolLM2-135M"}]})+ chat = _providers_post(+ "/providers/models", {"provider_type": "custom", "base_url": "http://localhost:8888/v1"}+ )+ assert [model["id"] for model in chat] == ["HuggingFaceTB/SmolLM2-135M"]+ assert "output_modalities" not in upstream.calls[-1].url.params+++ "reply,detail",+ [+ (httpx.Response(401, json = {"detail": "no key"}), "refused the API key (HTTP 401)"),+ (httpx.Response(500, text = "boom"), "answered HTTP 500"),+ (httpx.Response(404, text = "not found"), None),+ (httpx.Response(200, text = "<html>welcome</html>"), None),+ (httpx.Response(200, json = [{"id": "gpt2"}]), None),+ (httpx.Response(200, json = {"data": ["jev", {"id": "x", "architecture": None}]}), None),+ ],+)+def test_a_system_one_model_list_explains_what_went_wrong(upstream, reply, detail):+ upstream.replies[0] = reply+ listed = _providers_post(+ "/providers/models",+ {+ "provider_type": "custom",+ "api_type": "systemone",+ "base_url": "http://localhost:8888/v1",+ },+ )+ if detail is None:+ assert listed == []+ else:+ assert detail in listed["detail"]+++def test_studio_lists_its_decision_models_only_when_asked(monkeypatch, studio):+ from routes import inference++ async def chat_catalog():+ return [{"id": "unsloth/Qwen3-0.6B", "object": "model"}]++ monkeypatch.setattr(inference, "_openai_catalog_objects", chat_catalog)++ def ids(output_modalities = None):+ listed = asyncio.run(+ inference.openai_list_models(output_modalities = output_modalities, current_subject = "t")+ )+ return [model["id"] for model in listed["data"]]++ assert ids("decisions") == ["default"]+ monkeypatch.setattr(systemone_settings, "runtime_unavailable_reason", lambda: None)+ laya = ["default", *catalog.CHECKPOINTS]+ assert ids() == ["unsloth/Qwen3-0.6B"]+ assert ids("text") == ids("image") == ["unsloth/Qwen3-0.6B"]+ assert ids("decisions") == laya+ assert ids("text,decisions") == ids("all") == ["unsloth/Qwen3-0.6B", *laya]+ studio[systemone_settings.ENABLED_KEY] = False+ assert ids("decisions") == []+ assert ids() == ["unsloth/Qwen3-0.6B"]+++ "reply,success",+ [+ (httpx.Response(200, json = {"answers": {"outage": {"type": "noul", "noul": 0.9}}}), True),+ (httpx.Response(200, json = {"choices": [{"message": {"content": "hi"}}]}), False),+ (httpx.Response(200, text = "<html>welcome</html>"), False),+ (httpx.Response(404, json = {"detail": "Not Found"}), False),+ ],+)+def test_connection_test_checks_the_system_one_shape(upstream, reply, success):+ upstream.replies[0] = reply+ result = _provider_test(+ {+ "provider_type": "custom",+ "api_type": "systemone",+ "base_url": "http://localhost:8080/v1",+ "model_id": "jev-latest",+ }+ )+ assert result["success"] is success, result+ if not success:+ assert "does not speak the System One API" in result["message"]+ assert json.loads(upstream.calls[0].content)["questions"]["outage"]["type"] == "noul"+ assert upstream.calls[0].url.path == "/v1/systemone"+++def test_typesafe_check_asks_its_decision_endpoint(upstream):+ upstream.replies[0] = httpx.Response(+ 200, json = {"answers": {"outage": {"type": "noul", "noul": 0.9}}}+ )+ result = _provider_test({"provider_type": "typesafe", "model_id": "jev-latest"})+ assert result["success"] is True, result+ assert str(upstream.calls[0].url) == "https://api.typesafe.ai/v1/systemone"+++ "provider_type,api_type", [("typesafe", "chat_completions"), ("custom", "systemone")]+)+def test_chat_refuses_a_decision_connection(upstream, provider_type, api_type):+ from models.inference import ChatCompletionRequest+ from routes import inference++ _connection(provider_type, api_type)+ payload = ChatCompletionRequest(+ messages = [{"role": "user", "content": "Hi"}],+ stream = False,+ provider_id = "deciders",+ external_model = "jev-latest",+ )+ request = SimpleNamespace(headers = {}, state = SimpleNamespace(), url = SimpleNamespace(path = "/"))+ with pytest.raises(HTTPException) as refused:+ asyncio.run(inference._proxy_to_external_provider(payload, request))+ assert refused.value.status_code == 400+ assert "Decision API" in refused.value.detail+ assert upstream.calls == []diff --git a/studio/backend/utils/systemone_settings.py b/studio/backend/utils/systemone_settings.pyindex 8c963d79905..3394383f487 100644--- a/studio/backend/utils/systemone_settings.py+++ b/studio/backend/utils/systemone_settings.py@@ -72,10 +72,10 @@ def get_enabled() -> bool:def get_model() -> str:if model_locked():return _env(ENV_MODEL)- from core.systemone.catalog import CHECKPOINTS+ from core.systemone.catalog import CHECKPOINTS, parse_connectionstored = _owner_setting(MODEL_KEY)- return stored if stored in CHECKPOINTS else DEFAULT_MODEL+ return stored if stored in CHECKPOINTS or parse_connection(stored) else DEFAULT_MODELdef get_device() -> str:@@ -91,19 +91,24 @@ def validate(model: str | None = None,device: str | None = None,) -> dict[str, Any]:- from core.systemone.catalog import CHECKPOINTS+ from core.systemone.catalog import CHECKPOINTS, decision_connections, parse_connectionvalues: dict[str, Any] = {}if enabled is not None:if enabled_locked():raise ValueError(f"The Decision API is turned off by {ENV_DISABLE}.")- if enabled and (reason := runtime_unavailable_reason()):- raise ValueError(reason)values[ENABLED_KEY] = bool(enabled)if model is not None:if model_locked():raise ValueError(f"The Decision API model is set by {ENV_MODEL}.")- if model not in CHECKPOINTS:+ connection = parse_connection(model)+ if model not in CHECKPOINTS and not (+ connection+ and any(+ row["id"] == connection.provider_id and connection.model in models+ for row, models in decision_connections()+ )+ ):raise ValueError(f"Unknown Decision API model: {model}")values[MODEL_KEY] = modelif device is not None:@@ -112,6 +117,10 @@ def validate(if device not in DEVICES:raise ValueError("Device must be cpu or gpu.")values[DEVICE_KEY] = device+ serving = enabled if enabled is not None else model is not None and get_enabled()+ local = parse_connection(get_model() if model is None else model) is None+ if serving and local and (reason := runtime_unavailable_reason()):+ raise ValueError(reason)return valuesdiff --git a/studio/frontend/public/provider-logos/liquid.svg b/studio/frontend/public/provider-logos/liquid.svgnew file mode 100644index 00000000000..f849e6054ea--- /dev/null+++ b/studio/frontend/public/provider-logos/liquid.svg@@ -0,0 +1 @@+<svg fill="currentColor" fill-rule="evenodd" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Liquid</title><path d="M12.028 8.546l-.008.005 3.03 5.25a3.94 3.94 0 01.643 2.162c0 .754-.212 1.46-.58 2.062l6.173-1.991L11.63 0 9.304 3.872l2.724 4.674zM6.837 24l4.85-4.053h-.013c-2.219 0-4.017-1.784-4.017-3.984 0-.794.235-1.534.64-2.156l2.865-4.976-2.381-4.087L2 16.034 6.83 24h.007zM13.737 19.382h-.001L8.222 24h8.182l4.148-6.769-6.815 2.151z"></path></svg>\ No newline at end of filediff --git a/studio/frontend/public/provider-logos/typesafe.svg b/studio/frontend/public/provider-logos/typesafe.svgnew file mode 100644index 00000000000..6832aef5508--- /dev/null+++ b/studio/frontend/public/provider-logos/typesafe.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 21 32"><path fill="#1E1E1E" fill-rule="evenodd" clip-rule="evenodd" d="M10.3604 0.0713094C10.5495 -0.0544688 10.7065 -0.0082915 10.7568 0.166036L15.5703 2.79201L15.3301 3.23049L15.748 2.95315V8.80959L20.542 11.4248L20.2236 12.0078L20.7422 11.6631V23.6133C20.7422 23.8894 20.5559 24.2375 20.3262 24.3906L10.3828 31.0205V30.4024L10.1201 30.8848L5.32324 28.2686C5.12353 28.365 4.97169 28.262 4.97168 28.0117V22.1533L0.398438 19.6592C0.176221 19.7971 0 19.6973 0 19.4278V7.47756C0.000183397 7.20148 0.186363 6.85331 0.416016 6.70022L10.3604 0.0713094ZM6.26953 27.6455L10.4902 29.9473L19.4336 23.9854L15.2119 21.6836L6.26953 27.6455ZM10.7754 12.7432V18.2178C10.7753 18.4938 10.589 18.842 10.3594 18.9951L5.80371 22.0322V26.9571L14.915 20.8819V9.98342L10.7754 12.7432ZM15.7471 20.8272C15.7471 20.8297 15.7461 20.8324 15.7461 20.835L19.9102 23.1065V12.2188L15.7471 9.94826V20.8272ZM1.33984 19.0332L5.40137 21.249L9.43457 18.5596L5.37305 16.3447L1.33984 19.0332ZM0.832031 7.42287V18.3731L4.97168 15.6133V10.1387C4.97179 9.86264 5.15806 9.51452 5.3877 9.36135L9.94434 6.32424V1.34865L0.832031 7.42287ZM5.80371 15.4395L9.94336 17.6973V12.9131L5.80371 10.6553V15.4395ZM6.27148 9.7715L10.335 11.9883C10.3433 11.9822 10.3509 11.9754 10.3594 11.9697L14.374 9.29104L10.3135 7.07717L6.27148 9.7715ZM10.7764 6.18947L14.916 8.44729V3.57326L10.7764 1.31643V6.18947Z"/></svg>diff --git a/studio/frontend/src/features/chat/api-provider-logo.tsx b/studio/frontend/src/features/chat/api-provider-logo.tsxindex 2e6eba15589..1214bbe47e0 100644--- a/studio/frontend/src/features/chat/api-provider-logo.tsx+++ b/studio/frontend/src/features/chat/api-provider-logo.tsx@@ -20,7 +20,7 @@ interface ApiProviderLogoProps {title?: string;}-const DARK_INVERT_LOGOS = new Set(["openai", "openai_codex", "ollama", "openrouter"]);+const DARK_INVERT_LOGOS = new Set(["openai", "openai_codex", "ollama", "openrouter", "liquid", "typesafe"]);/** Shared hub or connection logo; monochrome ones invert in dark mode. */export function ApiProviderLogo({ providerType, className, title }: ApiProviderLogoProps) {diff --git a/studio/frontend/src/features/chat/api/providers-api.ts b/studio/frontend/src/features/chat/api/providers-api.tsindex e273045802a..ef567dc55c3 100644--- a/studio/frontend/src/features/chat/api/providers-api.ts+++ b/studio/frontend/src/features/chat/api/providers-api.ts@@ -36,9 +36,10 @@ export interface ProviderRegistryEntry {}export type ProviderApiType = "chat_completions" | "responses";+export type ConnectionApiType = ProviderApiType | "systemone";export interface ProviderConfig {- api_type?: ProviderApiType;+ api_type?: ConnectionApiType;id: string;provider_type: string;display_name: string;@@ -205,7 +206,7 @@ export async function createProviderConfig(payload: {providerType: string;displayName: string;baseUrl?: string | null;- apiType?: ProviderApiType;+ apiType?: ConnectionApiType;models?: string[];availableModels?: string[];maxOutputTokens?: number | null;@@ -252,7 +253,7 @@ export async function updateProviderConfig(payload: {displayName?: string;baseUrl?: string | null;- apiType?: ProviderApiType;+ apiType?: ConnectionApiType;isEnabled?: boolean;models?: string[];availableModels?: string[];@@ -327,7 +328,7 @@ export async function testProviderConnection(payload: {providerId?: string | null;apiKey: string;baseUrl?: string | null;- apiType?: ProviderApiType;+ apiType?: ConnectionApiType;modelId?: string | null;}): Promise<ProviderTestResult> {return withApiKeyEncryptionRetry(payload.apiKey, async (encryptedApiKey) => {@@ -354,7 +355,7 @@ export async function listProviderModels(payload: {providerId?: string | null;apiKey: string;baseUrl?: string | null;- apiType?: ProviderApiType;+ apiType?: ConnectionApiType;}): Promise<ProviderModelInfo[]> {return withApiKeyEncryptionRetry(payload.apiKey, async (encryptedApiKey) => {const response = await authFetch("/api/providers/models", {diff --git a/studio/frontend/src/features/chat/chat-page.tsx b/studio/frontend/src/features/chat/chat-page.tsxindex 95906d59922..f7673a3a38f 100644--- a/studio/frontend/src/features/chat/chat-page.tsx+++ b/studio/frontend/src/features/chat/chat-page.tsx@@ -158,6 +158,7 @@ import { ProjectSwitcher } from "./components/project-switcher";import { EditProjectDialog } from "./components/edit-project-dialog";import {buildExternalModelId,+ isDecisionConnection,isExternalModelId,parseExternalModelId,@@ -3885,7 +3886,8 @@ export function ChatPage({);const externalModels = useMemo<ExternalModelOption[]>(() =>- [...externalProvidersForChat]+ externalProvidersForChat+ .filter((provider) => !isDecisionConnection(provider)).sort((a, b) =>getExternalProviderDropdownRank(a.providerType) -diff --git a/studio/frontend/src/features/chat/chat-providers-dialog.tsx b/studio/frontend/src/features/chat/chat-providers-dialog.tsxindex 993484fe672..e715585d142 100644--- a/studio/frontend/src/features/chat/chat-providers-dialog.tsx+++ b/studio/frontend/src/features/chat/chat-providers-dialog.tsx@@ -39,13 +39,15 @@ import {import { AnimatePresence, motion, useReducedMotion } from "motion/react";import { useEffect, useMemo, useRef, useState } from "react";import { toast } from "sonner";+import { useSettingsDialogStore } from "@/features/settings";+import { useT } from "@/i18n";import { ApiProviderLogo } from "./api-provider-logo";import { OpenAICodexConnect } from "./openai-codex-connect";import {type CodexSubscriptionModels,type ProviderAuthStatus,- type ProviderApiType,+ type ConnectionApiType,type ProviderRegistryEntry,createProviderConfig,deleteProviderConfig,@@ -67,8 +69,10 @@ import {customProviderModelIdsPlaceholder,customPresetSkipsApiKeyField,PROVIDER_MAX_OUTPUT_TOKENS_MIN,+ connectionApiFields,getExternalProviderApiKey,isCustomProviderType,+ isDecisionConnection,LEGACY_CUSTOM_PROVIDER_TYPE,CUSTOM_PROVIDER_DISPLAY_NAME,getProviderModelCapabilities,@@ -132,6 +136,12 @@ const EMPTY_CATALOG_HINTS: Record<string, { title: string; description: string }},};+const SYSTEM_ONE_EMPTY_CATALOG_HINT = {+ title: "No decision models found on this server.",+ description:+ "Type the model name in the box below. For another Unsloth server, type default.",+};+function emptyCatalogHint(providerType: string): {title: string;description: string;@@ -252,13 +262,14 @@ export function ChatProvidersSettings({// first sync cannot pull them back into the form.const autoOpenedAddFormRef = useRef(false);const [page, setPage] = useState<"list" | "form">("list");+ const t = useT();const [providerType, setProviderType] = useState<string>("");const [apiKey, setApiKey] = useState("");const [showApiKey, setShowApiKey] = useState(false);const [clearApiKeyRequested, setClearApiKeyRequested] = useState(false);const [baseUrlDraft, setBaseUrlDraft] = useState("");- const [apiType, setApiType] = useState<ProviderApiType>("chat_completions");+ const [apiType, setApiType] = useState<ConnectionApiType>("chat_completions");const [maxOutputTokensDraft, setMaxOutputTokensDraft] = useState("");const [editingBackendProviderType, setEditingBackendProviderType] = useState<string | null@@ -292,11 +303,15 @@ export function ChatProvidersSettings({(s) => s.setConnectionsEnabled,);const isCustomProvider = isCustomProviderType(providerType);+ const decisionsOnly = isDecisionConnection({+ providerType,+ decisionsOnly: apiType === "systemone",+ });// a connection being created has no stored type yet, so only the UI type can decideconst supportsMaxOutputTokens = supportsProviderMaxOutputTokens(providerType,editingProviderId ? editingBackendProviderType : null,- );+ ) && !decisionsOnly;// llama.cpp hides the key field. Ollama and vLLM show an optional key: Ollama cloud and// secured vLLM need one; local servers leave it empty.const showReasoningToggle = supportsProviderReasoningToggle(providerType);@@ -304,6 +319,7 @@ export function ChatProvidersSettings({// capability, with no extra opt-in. Say so where the connection is created: tool results// also travel back to the provider as the next turn's input.const runsStudioToolsLocally =+ !decisionsOnly &&providerModelSupportsStudioTools(toExternalBackendProviderType(providerType),null,@@ -418,7 +434,11 @@ export function ChatProvidersSettings({// cloud providers and local OpenAI-compat presets stay empty until "Load available models".const seedDefaults = entry.model_list_mode === "curated";setAvailableModels(seedDefaults ? [...entry.default_models] : []);- setSelectedModelIds([]);+ setSelectedModelIds(+ isDecisionConnection({ providerType })+ ? entry.default_models.slice(0, 1)+ : [],+ );setManualModelIds("");setModelSearchQuery("");setBaseUrlDraft("");@@ -543,6 +563,9 @@ export function ChatProvidersSettings({if (entry?.model_list_mode === "curated") {setAvailableModels([...entry.default_models]);}+ if (entry && isDecisionConnection({ providerType: entry.provider_type })) {+ setSelectedModelIds(entry.default_models.slice(0, 1));+ }autoOpenedAddFormRef.current = true;setPage("form");}@@ -608,9 +631,12 @@ export function ChatProvidersSettings({}return null;}- return parseOptionalBaseUrl(trimmed, {+ const baseUrl = parseOptionalBaseUrl(trimmed, {appendOpenAiVersionPath: shouldAppendOpenAiVersionPath(providerTypeForUrl),});+ return apiType === "systemone"+ ? (baseUrl?.replace(/\/systemone$/, "") ?? null)+ : baseUrl;}function parseMaxOutputTokens(input: string): number | null {@@ -715,7 +741,10 @@ export function ChatProvidersSettings({prev.filter((id) => modelIds.includes(id)),);if (modelIds.length === 0) {- const hint = emptyCatalogHint(providerType);+ const hint =+ providerType === LEGACY_CUSTOM_PROVIDER_TYPE && apiType === "systemone"+ ? SYSTEM_ONE_EMPTY_CATALOG_HINT+ : emptyCatalogHint(providerType);toast.info(hint.title, { description: hint.description });} else {toast.success(@@ -769,7 +798,7 @@ export function ChatProvidersSettings({providerType: created.provider_type,name: created.display_name,baseUrl: created.base_url ?? "",- apiType: created.api_type ?? "chat_completions",+ ...connectionApiFields(created.api_type),models,availableModels: available,hasApiKey: created.has_api_key,@@ -896,7 +925,7 @@ export function ChatProvidersSettings({backendProviderType: created.provider_type,name: created.display_name,baseUrl: created.base_url ?? "",- apiType: created.api_type ?? "chat_completions",+ ...connectionApiFields(created.api_type),models: modelsToSave,availableModels: manualOnly? []@@ -923,7 +952,20 @@ export function ChatProvidersSettings({resetForm();autoOpenedAddFormRef.current = true;setPage("list");- toast.success("Connection added.");+ toast.success(+ "Connection added.",+ isDecisionConnection(provider)+ ? {+ action: {+ label: "Use it for the Decision API",+ onClick: () =>+ useSettingsDialogStore.getState().openDialog("api-keys", {+ scrollTarget: "api-keys-decision-api",+ }),+ },+ }+ : undefined,+ );} catch (error) {const message = error instanceof Error ? error.message : "Unknown error";toast.error(`Failed to add connection: ${message}`);@@ -1057,7 +1099,7 @@ export function ChatProvidersSettings({backendProviderType: updated.provider_type,name: updated.display_name,baseUrl: updated.base_url ?? "",- apiType: updated.api_type ?? "chat_completions",+ ...connectionApiFields(updated.api_type),models: keepSavedModels? (updated.models?.length ? updated.models : existing.models): modelsToSave,@@ -1175,7 +1217,9 @@ export function ChatProvidersSettings({setBaseUrlDraft(provider.baseUrl);setAutoReloadModels(provider.autoReloadModels === true);modelFieldsAtOpenRef.current = null;- setApiType(provider.apiType ?? "chat_completions");+ setApiType(+ provider.decisionsOnly ? "systemone" : (provider.apiType ?? "chat_completions"),+ );// Seeded at the floor: parseMaxOutputTokens throws below it, so a row stored under one would// fail every unrelated edit. The resolver already reads it as the floor.setMaxOutputTokensDraft(@@ -1335,9 +1379,10 @@ export function ChatProvidersSettings({providerId: provider.id,apiKey: savedKey,baseUrl: provider.baseUrl || null,- apiType: provider.apiType,+ apiType: provider.decisionsOnly ? "systemone" : provider.apiType,modelId:- provider.providerType === LEGACY_CUSTOM_PROVIDER_TYPE+ provider.providerType === LEGACY_CUSTOM_PROVIDER_TYPE ||+ isDecisionConnection(provider)? (provider.models[0] ?? null): null,});@@ -1585,7 +1630,7 @@ export function ChatProvidersSettings({</div><Selectvalue={apiType}- onValueChange={(value) => setApiType(value as ProviderApiType)}+ onValueChange={(value) => setApiType(value as ConnectionApiType)}><SelectTrigger id="provider-api-type" className="h-9 w-full text-sm"><SelectValue />@@ -1593,6 +1638,7 @@ export function ChatProvidersSettings({<SelectContent><SelectItem value="chat_completions">OpenAI Chat Completions</SelectItem><SelectItem value="responses">OpenAI Responses</SelectItem>+ <SelectItem value="systemone">System One (decisions)</SelectItem></SelectContent></Select></div>@@ -1608,7 +1654,9 @@ export function ChatProvidersSettings({Base URL</Label><p className="text-xs leading-snug text-muted-foreground">- OpenAI-compatible endpoint.+ {decisionsOnly+ ? "Up to the version, such as /v1. Studio adds /systemone."+ : "OpenAI-compatible endpoint."}</p></div><Input@@ -2100,7 +2148,7 @@ export function ChatProvidersSettings({<header className="flex min-w-0 flex-col gap-1 pr-8"><h1 className="text-xl font-semibold font-heading">Connections</h1><p className="text-xs text-muted-foreground">- Manage model connections for chat.+ Manage model connections for chat and the Decision API.</p></header>@@ -2186,6 +2234,11 @@ export function ChatProvidersSettings({{provider.models.length}{" "}{provider.models.length === 1 ? "model" : "models"}</span>+ {isDecisionConnection(provider) ? (+ <span className="shrink-0 rounded-full border border-control-accent/15 bg-control-accent/8 px-1.5 py-0.5 text-ui-10 leading-none text-control-accent">+ {t("settings.apiKeys.decisionApi.title")}+ </span>+ ) : null}</div><div className="mt-0.5 truncate text-xs text-muted-foreground"><span>{providerLabel}</span>diff --git a/studio/frontend/src/features/chat/external-providers.ts b/studio/frontend/src/features/chat/external-providers.tsindex b557003adfc..d1e4267fe21 100644--- a/studio/frontend/src/features/chat/external-providers.ts+++ b/studio/frontend/src/features/chat/external-providers.ts@@ -2,6 +2,7 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import type {+ ConnectionApiType,ProviderApiType,ProviderAuthKind,ProviderAuthStatus,@@ -17,6 +18,7 @@ export interface ExternalProviderConfig {/** Provider base URL (default from registry or backend-saved override). */baseUrl: string;apiType?: ProviderApiType;+ decisionsOnly?: boolean;/** Model ids user enabled from `/api/providers/models`. */models: string[];/** Cached available model ids from the provider's /models response. */@@ -124,6 +126,26 @@ export function supportsProviderReasoningToggle();}+const DECISION_PROVIDER_TYPES = new Set(["typesafe", "liquid"]);++export function isDecisionConnection(+ provider: Pick<ExternalProviderConfig, "providerType" | "decisionsOnly">,+): boolean {+ return (+ provider.decisionsOnly === true ||+ DECISION_PROVIDER_TYPES.has(provider.providerType)+ );+}++export function connectionApiFields(+ apiType: ConnectionApiType | undefined,+): Pick<ExternalProviderConfig, "apiType" | "decisionsOnly"> {+ return {+ apiType: apiType === "responses" ? "responses" : "chat_completions",+ decisionsOnly: apiType === "systemone",+ };+}+// Known text-only providers on their main chat endpoint.const NON_VISION_PROVIDER_TYPES = new Set<string>(["cohere",diff --git a/studio/frontend/src/features/chat/index.ts b/studio/frontend/src/features/chat/index.tsindex a6713d40a09..dedbc45cae5 100644--- a/studio/frontend/src/features/chat/index.ts+++ b/studio/frontend/src/features/chat/index.ts@@ -269,6 +269,7 @@ export type { ChatModelLoadedInput } from "./lib/chat-model-loaded";export {customProviderDisplayName,isCustomProviderType,+ isDecisionConnection,isExternalModelId,parseExternalModelId,} from "./external-providers";diff --git a/studio/frontend/src/features/chat/provider-logo-path.ts b/studio/frontend/src/features/chat/provider-logo-path.tsindex d98920b869a..e56511a91a0 100644--- a/studio/frontend/src/features/chat/provider-logo-path.ts+++ b/studio/frontend/src/features/chat/provider-logo-path.ts@@ -26,6 +26,8 @@ const CONNECTION_LOGO_PATHS = new Map([["vllm", "/provider-logos/vllm.svg"],["ollama", "/provider-logos/ollama.svg"],["llama_cpp", "/provider-logos/llama_cpp.svg"],+ ["liquid", "/provider-logos/liquid.svg"],+ ["typesafe", "/provider-logos/typesafe.svg"],]);/** Public asset path shared by Connections, agent icons, and the model picker. */diff --git a/studio/frontend/src/features/chat/sync-external-providers.ts b/studio/frontend/src/features/chat/sync-external-providers.tsindex ae1a58d6bbb..90279677a58 100644--- a/studio/frontend/src/features/chat/sync-external-providers.ts+++ b/studio/frontend/src/features/chat/sync-external-providers.ts@@ -25,6 +25,7 @@ import {CUSTOM_BACKEND_PROVIDER_TYPE,CUSTOM_PROVIDER_DISPLAY_NAME,CUSTOM_PROVIDER_PRESETS,+ connectionApiFields,type ExternalProviderConfig,getExternalProviderApiKey,isPromptCacheTtl,@@ -313,7 +314,7 @@ export async function syncExternalProvidersFromBackend(backendProviderType: config.provider_type,name: config.display_name,baseUrl: config.base_url ?? "",- apiType: config.api_type ?? "chat_completions",+ ...connectionApiFields(config.api_type),models: resolvedModels,availableModels: resolvedAvailableModels,maxOutputTokens: config.max_output_tokens ?? undefined,diff --git a/studio/frontend/src/features/settings/api/systemone.ts b/studio/frontend/src/features/settings/api/systemone.tsindex 6feef03311d..3e987e95efc 100644--- a/studio/frontend/src/features/settings/api/systemone.ts+++ b/studio/frontend/src/features/settings/api/systemone.ts@@ -29,6 +29,13 @@ export type SystemOneSettings = {mcpUrl: string;};+export type SystemOneConnection = {+ name: string;+ providerId: string;+ provider: string;+ model: string;+};+export type SystemOneDownloadPlan = {repo: string | null;files: string[];@@ -45,6 +52,14 @@ export type SystemOneSettingsPatch = {expectedModel?: string;};+type ApiSystemOneConnection = {+ name: string;+ // biome-ignore lint/style/useNamingConvention: API schema+ provider_id: string;+ provider: string;+ model: string;+};+type ApiSystemOneSettings = {enabled: boolean;// biome-ignore lint/style/useNamingConvention: API schema@@ -188,6 +203,24 @@ export async function unloadSystemOneModel(): Promise<SystemOneSettings> {);}+export async function loadSystemOneConnections(): Promise<+ SystemOneConnection[]+> {+ const res = await authFetch(`${SETTINGS_PATH}/connections`);+ if (!res.ok) {+ throw new Error(+ await readFastApiError(res, "Failed to load Decision API connections"),+ );+ }+ const options = (await res.json()) as ApiSystemOneConnection[];+ return options.map((option) => ({+ name: option.name,+ providerId: option.provider_id,+ provider: option.provider,+ model: option.model,+ }));+}+export async function resolveSystemOneDownload(model?: string,): Promise<SystemOneDownloadPlan> {diff --git a/studio/frontend/src/features/settings/components/decision-api-section.tsx b/studio/frontend/src/features/settings/components/decision-api-section.tsxindex 5426d2f88fe..4c2bf3ac3e1 100644--- a/studio/frontend/src/features/settings/components/decision-api-section.tsx+++ b/studio/frontend/src/features/settings/components/decision-api-section.tsx@@ -16,7 +16,9 @@ import { Button } from "@/components/ui/button";import {Select,SelectContent,+ SelectGroup,SelectItem,+ SelectLabel,SelectTrigger,SelectValue,} from "@/components/ui/select";@@ -35,11 +37,14 @@ import { toast } from "@/lib/toast";import { cn } from "@/lib/utils";import { TaskDone01Icon } from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";-import { type ReactElement, useEffect, useState } from "react";+import { type ReactElement, useEffect, useRef, useState } from "react";+import { useSettingsDialogStore } from "../stores/settings-dialog-store";import {+ type SystemOneConnection,type SystemOneDevice,type SystemOneDownloadPlan,type SystemOneSettings,+ loadSystemOneConnections,loadSystemOneSettings,resolveSystemOneDownload,unloadSystemOneModel,@@ -71,6 +76,9 @@ function errorMessage(error: unknown): string | null {export function DecisionApiSection(): ReactElement | null {const t = useT();const [settings, setSettings] = useState<SystemOneSettings | null>(null);+ const [connections, setConnections] = useState<+ SystemOneConnection[] | null+ >(null);const [planState, setPlanState] = useState<{model: string;plan: SystemOneDownloadPlan;@@ -82,6 +90,8 @@ export function DecisionApiSection(): ReactElement | null {} | null>(null);const [busy, setBusy] = useState(false);const [error, setError] = useState<string | null>(null);+ const sectionRef = useRef<HTMLElement | null>(null);+ const scrollTarget = useSettingsDialogStore((s) => s.scrollTarget);const enabled = settings?.enabled ?? false;const model = settings?.model ?? null;@@ -98,11 +108,26 @@ export function DecisionApiSection(): ReactElement | null {translate("settings.apiKeys.decisionApi.loadError"),),);+ loadSystemOneConnections().then(+ (next) => live && setConnections(next),+ () => live && setConnections([]),+ );return () => {live = false;};}, []);+ useEffect(() => {+ if (scrollTarget !== "api-keys-decision-api" || !settings) return;+ const frame = window.requestAnimationFrame(() => {+ sectionRef.current?.scrollIntoView({ block: "start", behavior: "smooth" });+ useSettingsDialogStore+ .getState()+ .consumeScrollTarget("api-keys-decision-api");+ });+ return () => window.cancelAnimationFrame(frame);+ }, [scrollTarget, settings]);+useEffect(() => {if (!enabled) return;const timer = window.setInterval(() => {@@ -134,8 +159,11 @@ export function DecisionApiSection(): ReactElement | null {};}, [enabled, model, downloadDone]);- const modelLabel = (name: string) =>- MODEL_LABELS[name] ? t(MODEL_LABELS[name]) : name;+ const modelLabel = (name: string) => {+ const option = connections?.find((c) => c.name === name);+ if (option) return `${option.provider} · ${option.model}`;+ return MODEL_LABELS[name] ? t(MODEL_LABELS[name]) : name;+ };const resyncSettingsAfterError = async (message: string) => {try {@@ -309,13 +337,27 @@ export function DecisionApiSection(): ReactElement | null {}const current = settings.models.find((m) => m.name === settings.model);- const knownModel = current !== undefined;+ const isRemote = settings.model.startsWith("connection:");+ const remote = connections?.find((c) => c.name === settings.model);+ const knownModel = current !== undefined || isRemote;+ const connectionGroups = [+ ...new Set(connections?.map((c) => c.providerId)),+ ].map((id) => connections?.filter((c) => c.providerId === id) ?? []);const sizeBytes = plan?.sizeBytes || current?.downloadBytes || 0;let tone: "pending" | "ready" | "error" | null = null;let status = "";let action: "download" | "unload" | null = null;- if (settings.error) {+ if (remote) {+ status = t("settings.apiKeys.decisionApi.sendsTo", {+ provider: remote.provider,+ });+ } else if (isRemote) {+ tone = connections ? "error" : "pending";+ status = connections+ ? t("settings.apiKeys.decisionApi.connectionMissing")+ : t("settings.apiKeys.decisionApi.checking");+ } else if (settings.error) {tone = "error";status = settings.error;} else if (settings.installing) {@@ -351,6 +393,7 @@ export function DecisionApiSection(): ReactElement | null {return (<section+ ref={sectionRef}data-settings-label={t("settings.apiKeys.decisionApi.title")}className="overflow-hidden rounded-lg border border-border/70">@@ -364,7 +407,9 @@ export function DecisionApiSection(): ReactElement | null {? t("settings.apiKeys.decisionApi.lockedByEnv", {name: ENV_DISABLE,})- : t("settings.apiKeys.decisionApi.enableDescription")+ : isRemote+ ? t("settings.apiKeys.decisionApi.enableRemoteDescription")+ : t("settings.apiKeys.decisionApi.enableDescription")}><Switch@@ -385,7 +430,7 @@ export function DecisionApiSection(): ReactElement | null {: undefined}description={- enabled && status ? (+ (enabled || isRemote) && status ? (<spanclassName={cn("flex min-w-0 items-center gap-2",@@ -442,26 +487,47 @@ export function DecisionApiSection(): ReactElement | null {onValueChange={(name) => void apply({ model: name }, true)}><SelectTrigger- className="w-48 max-[420px]:flex-1"+ className={cn(+ isRemote ? "w-64" : "w-48",+ "max-[420px]:flex-1",+ )}aria-label={t("settings.apiKeys.decisionApi.model")}+ title={isRemote ? modelLabel(settings.model) : undefined}>- <SelectValue>{modelLabel(settings.model)}</SelectValue>+ <SelectValue className="min-w-0">+ <span className="truncate">{modelLabel(settings.model)}</span>+ </SelectValue></SelectTrigger><SelectContent>- {settings.models.map((option) => (- <SelectItem key={option.name} value={option.name}>- <span className="flex items-center gap-2">- {modelLabel(option.name)}- <span className="text-ui-10 tabular-nums text-muted-foreground">- {formatBytes(option.downloadBytes)}- </span>- {option.name === RECOMMENDED_MODEL ? (- <span className="rounded-full bg-emerald-500/12 px-1.5 py-px text-ui-9 font-medium text-emerald-600 dark:text-emerald-400">- {t("settings.apiKeys.decisionApi.recommended")}+ <SelectGroup>+ <SelectLabel>+ {t("settings.apiKeys.decisionApi.thisMachine")}+ </SelectLabel>+ {settings.models.map((option) => (+ <SelectItem key={option.name} value={option.name}>+ <span className="flex items-center gap-2">+ {modelLabel(option.name)}+ <span className="text-ui-10 tabular-nums text-muted-foreground">+ {formatBytes(option.downloadBytes)}</span>- ) : null}- </span>- </SelectItem>+ {option.name === RECOMMENDED_MODEL ? (+ <span className="rounded-full bg-emerald-500/12 px-1.5 py-px text-ui-9 font-medium text-emerald-600 dark:text-emerald-400">+ {t("settings.apiKeys.decisionApi.recommended")}+ </span>+ ) : null}+ </span>+ </SelectItem>+ ))}+ </SelectGroup>+ {connectionGroups.map((group) => (+ <SelectGroup key={group[0].providerId}>+ <SelectLabel>{group[0].provider}</SelectLabel>+ {group.map((option) => (+ <SelectItem key={option.name} value={option.name}>+ {option.model}+ </SelectItem>+ ))}+ </SelectGroup>))}</SelectContent></Select>@@ -473,39 +539,56 @@ export function DecisionApiSection(): ReactElement | null {</div></SettingsRow>- <SettingsRow- label={t("settings.apiKeys.decisionApi.device")}- description={- settings.deviceLocked- ? t("settings.apiKeys.decisionApi.lockedByEnv", {- name: ENV_DEVICE,- })- : t("settings.apiKeys.decisionApi.deviceDescription")- }- >- <Select- value={settings.device}- disabled={busy || settings.deviceLocked}- onValueChange={(device) =>- void apply({ device: device as SystemOneDevice }, false)+ {isRemote ? null : (+ <SettingsRow+ label={t("settings.apiKeys.decisionApi.device")}+ description={+ settings.deviceLocked+ ? t("settings.apiKeys.decisionApi.lockedByEnv", {+ name: ENV_DEVICE,+ })+ : t("settings.apiKeys.decisionApi.deviceDescription")}>- <SelectTrigger- className="w-36"- aria-label={t("settings.apiKeys.decisionApi.device")}+ <Select+ value={settings.device}+ disabled={busy || settings.deviceLocked}+ onValueChange={(device) =>+ void apply({ device: device as SystemOneDevice }, false)+ }>- <SelectValue />- </SelectTrigger>- <SelectContent>- <SelectItem value="cpu">- {t("settings.apiKeys.decisionApi.deviceCpu")}- </SelectItem>- <SelectItem value="gpu" disabled={!settings.gpuAvailable}>- {t("settings.apiKeys.decisionApi.deviceGpu")}- </SelectItem>- </SelectContent>- </Select>- </SettingsRow>+ <SelectTrigger+ className="w-36"+ aria-label={t("settings.apiKeys.decisionApi.device")}+ >+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ <SelectItem value="cpu">+ {t("settings.apiKeys.decisionApi.deviceCpu")}+ </SelectItem>+ <SelectItem value="gpu" disabled={!settings.gpuAvailable}>+ {t("settings.apiKeys.decisionApi.deviceGpu")}+ </SelectItem>+ </SelectContent>+ </Select>+ </SettingsRow>+ )}++ {connections?.length === 0 && !settings.modelLocked ? (+ <p className="pb-3 text-xs text-muted-foreground">+ {t("settings.apiKeys.decisionApi.addConnection")}{" "}+ <button+ type="button"+ className="font-medium text-foreground underline underline-offset-2 hover:text-primary"+ onClick={() =>+ useSettingsDialogStore.getState().setActiveTab("connections")+ }+ >+ {t("settings.apiKeys.decisionApi.openConnections")}+ </button>+ </p>+ ) : null}</div><AlertDialogdiff --git a/studio/frontend/src/features/settings/stores/settings-dialog-store.ts b/studio/frontend/src/features/settings/stores/settings-dialog-store.tsindex 03d3d7fe0d2..57ba09a0f5f 100644--- a/studio/frontend/src/features/settings/stores/settings-dialog-store.ts+++ b/studio/frontend/src/features/settings/stores/settings-dialog-store.ts@@ -30,6 +30,7 @@ export type SettingsTab = (typeof SETTINGS_TABS)[number];export type SettingsScrollTarget =| "about-updates"+ | "api-keys-decision-api"| "appearance-sidebar-nav"| "chat-composer"| "chat-canvas-network"@@ -132,6 +133,7 @@ function loadInitialTab(): SettingsTab {const SCROLL_TARGET_TAB: Record<SettingsScrollTarget, SettingsTab> = {"chat-composer": "chat","about-updates": "about",+ "api-keys-decision-api": "api-keys","appearance-sidebar-nav": "appearance","chat-canvas-network": "chat","general-hub": "general",diff --git a/studio/frontend/src/features/settings/tabs/voice-tab.tsx b/studio/frontend/src/features/settings/tabs/voice-tab.tsxindex 9166201563d..ef0768828b6 100644--- a/studio/frontend/src/features/settings/tabs/voice-tab.tsx+++ b/studio/frontend/src/features/settings/tabs/voice-tab.tsx@@ -27,6 +27,7 @@ import {fetchSttStatus,generateCustomTtsAudio,generateStudioTtsAudio,+ isDecisionConnection,loadSttModel,releaseTtsAudioUrl,startSttDownload,@@ -436,7 +437,12 @@ export function VoiceTab() {const setTtsProviderVoice = useVoiceSettingsStore((s) => s.setTtsProviderVoice,);- const ttsConnections = useExternalProvidersStore((s) => s.providers);+ const connections = useExternalProvidersStore((s) => s.providers);+ const ttsConnections = useMemo(+ () =>+ connections.filter((connection) => !isDecisionConnection(connection)),+ [connections],+ );const hasSelectedTtsConnection = ttsConnections.some((connection) => connection.id === ttsProviderId,);@@ -446,7 +452,7 @@ export function VoiceTab() {const setTtsPitch = useVoiceSettingsStore((s) => s.setTtsPitch);const ttsVolume = useVoiceSettingsStore((s) => s.ttsVolume);const setTtsVolume = useVoiceSettingsStore((s) => s.setTtsVolume);- const sttConnections = useExternalProvidersStore((s) => s.providers);+ const sttConnections = ttsConnections;const connectionsEnabled = useExternalProvidersStore((s) => s.connectionsEnabled,);diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.tsindex 94d7bb2fa16..6ae67bdd4ee 100644--- a/studio/frontend/src/i18n/locales/ar.ts+++ b/studio/frontend/src/i18n/locales/ar.ts@@ -2216,11 +2216,13 @@ export const ar = {revoking: "جارٍ الإلغاء...",decisionApi: {title: "واجهة القرارات البرمجية",- description: "أجب عن أسئلة نعم/لا والاختيار من متعدد والتقييم حول النص باستخدام نموذج Laya محلي. يعمل مع حزمة TypeSafe.",+ description: "أجب عن أسئلة نعم/لا والاختيار من متعدد والتقييم حول النص باستخدام نموذج على هذا الجهاز أو نموذج قرارات من الاتصالات. يعمل مع حزمة TypeSafe.",enable: "خدمة الطلبات",enableDescription: "يقدّم /v1/systemone. عند التشغيل يُنزَّل النموذج.",+ enableRemoteDescription: "يقدّم /v1/systemone.",lockedByEnv: "مضبوط بواسطة {name}.",model: "النموذج",+ thisMachine: "هذا الجهاز",modelMultilingual: "متعدد اللغات",modelEnglish: "إنجليزي",modelTypedDecisions: "قرارات مُصنَّفة",@@ -2245,6 +2247,10 @@ export const ar = {downloadFailed: "تعذّر بدء التنزيل.",saveFailed: "تعذّر حفظ إعداد واجهة القرارات.",loadError: "تعذّر تحميل إعدادات واجهة القرارات.",+ sendsTo: "تُرسَل الطلبات إلى {provider}.",+ connectionMissing: "هذا الاتصال لم يعد موجودًا أو لا يحتوي على نماذج قرارات. اختر نموذجًا آخر.",+ addConnection: "لاستخدام نموذج قرارات مستضاف، أضف TypeSafe أو Liquid AI أو OpenRouter في الاتصالات.",+ openConnections: "فتح الاتصالات",},usageNoModel:"حمّل نموذجًا أو نزّله لعرض أمثلة قابلة للتشغيل. لا يوجد في هذا الخادم أي نموذج يمكن استخدامه في الأمثلة بعد.",diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.tsindex 03057ec8751..172d7c39325 100644--- a/studio/frontend/src/i18n/locales/de.ts+++ b/studio/frontend/src/i18n/locales/de.ts@@ -2260,11 +2260,13 @@ export const de = {revoking: "Wird widerrufen...",decisionApi: {title: "Entscheidungs-API",- description: "Beantworte Ja/Nein-, Auswahl- und Bewertungsfragen zu Text mit einem lokalen Laya-Modell. Funktioniert mit dem TypeSafe-SDK.",+ description: "Beantworte Ja/Nein-, Auswahl- und Bewertungsfragen zu Text mit einem Modell auf diesem Rechner oder einem Entscheidungsmodell aus den Verbindungen. Funktioniert mit dem TypeSafe-SDK.",enable: "Anfragen beantworten",enableDescription: "Stellt /v1/systemone bereit. Beim Einschalten wird das Modell heruntergeladen.",+ enableRemoteDescription: "Stellt /v1/systemone bereit.",lockedByEnv: "Festgelegt durch {name}.",model: "Modell",+ thisMachine: "Dieser Rechner",modelMultilingual: "Multilingual",modelEnglish: "Englisch",modelTypedDecisions: "Typisierte Entscheidungen",@@ -2289,6 +2291,10 @@ export const de = {downloadFailed: "Der Download konnte nicht gestartet werden.",saveFailed: "Die Einstellung der Entscheidungs-API konnte nicht gespeichert werden.",loadError: "Die Einstellungen der Entscheidungs-API konnten nicht geladen werden.",+ sendsTo: "Anfragen gehen an {provider}.",+ connectionMissing: "Diese Verbindung gibt es nicht mehr oder sie hat keine Entscheidungsmodelle. Wähle ein anderes Modell.",+ addConnection: "Für ein gehostetes Entscheidungsmodell füge TypeSafe, Liquid AI oder OpenRouter unter Verbindungen hinzu.",+ openConnections: "Verbindungen öffnen",},usageNoModel:"Laden Sie ein Modell oder laden Sie eines herunter, um ausführbare Beispiele zu sehen. Dieser Server kennt noch kein Modell, das in den Beispielen verwendet werden könnte.",diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.tsindex 37395b48808..4120dd905c0 100644--- a/studio/frontend/src/i18n/locales/en.ts+++ b/studio/frontend/src/i18n/locales/en.ts@@ -2211,11 +2211,13 @@ export const en = {revoking: "Revoking...",decisionApi: {title: "Decision API",- description: "Answer yes/no, multiple choice and score questions about text with a local Laya model. Works with the TypeSafe SDK.",+ description: "Answer yes/no, multiple choice and score questions about text with a model on this machine or a decision model from Connections. Works with the TypeSafe SDK.",enable: "Serve requests",enableDescription: "Serves /v1/systemone. Turning it on downloads the model.",+ enableRemoteDescription: "Serves /v1/systemone.",lockedByEnv: "Set by {name}.",model: "Model",+ thisMachine: "This machine",modelMultilingual: "Multilingual",modelEnglish: "English",modelTypedDecisions: "Typed decisions",@@ -2240,6 +2242,10 @@ export const en = {downloadFailed: "Couldn't start the download.",saveFailed: "Couldn't save the Decision API setting.",loadError: "Couldn't load Decision API settings.",+ sendsTo: "Requests are sent to {provider}.",+ connectionMissing: "This connection is gone or has no decision models. Pick another model.",+ addConnection: "To use a hosted decision model, add TypeSafe, Liquid AI or OpenRouter in Connections.",+ openConnections: "Open Connections",},},about: {diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.tsindex 15010182afe..223962100e2 100644--- a/studio/frontend/src/i18n/locales/es.ts+++ b/studio/frontend/src/i18n/locales/es.ts@@ -2251,11 +2251,13 @@ export const es = {revoking: "Revocando...",decisionApi: {title: "API de decisiones",- description: "Responde preguntas de sí/no, de opción múltiple y de puntuación sobre texto con un modelo Laya local. Funciona con el SDK de TypeSafe.",+ description: "Responde preguntas de sí/no, de opción múltiple y de puntuación sobre texto con un modelo en este equipo o un modelo de decisiones de Conexiones. Funciona con el SDK de TypeSafe.",enable: "Atender solicitudes",enableDescription: "Atiende /v1/systemone. Al activarlo se descarga el modelo.",+ enableRemoteDescription: "Atiende /v1/systemone.",lockedByEnv: "Definido por {name}.",model: "Modelo",+ thisMachine: "Este equipo",modelMultilingual: "Multilingüe",modelEnglish: "Inglés",modelTypedDecisions: "Decisiones tipadas",@@ -2280,6 +2282,10 @@ export const es = {downloadFailed: "No se pudo iniciar la descarga.",saveFailed: "No se pudo guardar el ajuste de la API de decisiones.",loadError: "No se pudieron cargar los ajustes de la API de decisiones.",+ sendsTo: "Las solicitudes se envían a {provider}.",+ connectionMissing: "Esta conexión ya no existe o no tiene modelos de decisiones. Elige otro modelo.",+ addConnection: "Para usar un modelo de decisiones alojado, añade TypeSafe, Liquid AI u OpenRouter en Conexiones.",+ openConnections: "Abrir Conexiones",},usageNoModel:"Carga o descarga un modelo para ver ejemplos ejecutables. Este servidor todavía no tiene ningún modelo que indicar.",diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.tsindex 62a6f62cb9b..2ebbab4fbef 100644--- a/studio/frontend/src/i18n/locales/fr.ts+++ b/studio/frontend/src/i18n/locales/fr.ts@@ -2261,11 +2261,13 @@ export const fr = {revoking: "Révocation...",decisionApi: {title: "API de décision",- description: "Répondez à des questions oui/non, à choix multiples et à score sur du texte avec un modèle Laya local. Compatible avec le SDK TypeSafe.",+ description: "Répondez à des questions oui/non, à choix multiples et à score sur du texte avec un modèle sur cette machine ou un modèle de décision issu des Connexions. Compatible avec le SDK TypeSafe.",enable: "Répondre aux requêtes",enableDescription: "Sert /v1/systemone. L'activer télécharge le modèle.",+ enableRemoteDescription: "Sert /v1/systemone.",lockedByEnv: "Défini par {name}.",model: "Modèle",+ thisMachine: "Cette machine",modelMultilingual: "Multilingue",modelEnglish: "Anglais",modelTypedDecisions: "Décisions typées",@@ -2290,6 +2292,10 @@ export const fr = {downloadFailed: "Impossible de lancer le téléchargement.",saveFailed: "Impossible d'enregistrer le réglage de l'API de décision.",loadError: "Impossible de charger les réglages de l'API de décision.",+ sendsTo: "Les requêtes sont envoyées à {provider}.",+ connectionMissing: "Cette connexion n'existe plus ou n'a pas de modèle de décision. Choisissez un autre modèle.",+ addConnection: "Pour utiliser un modèle de décision hébergé, ajoutez TypeSafe, Liquid AI ou OpenRouter dans Connexions.",+ openConnections: "Ouvrir Connexions",},usageNoModel:"Chargez ou téléchargez un modèle pour voir des exemples exécutables. Aucun modèle n'est encore disponible sur ce serveur pour figurer dans les exemples.",diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.tsindex 31565e047d5..2eab57514b2 100644--- a/studio/frontend/src/i18n/locales/hi.ts+++ b/studio/frontend/src/i18n/locales/hi.ts@@ -2222,11 +2222,13 @@ export const hi = {revoking: "रद्द किया जा रहा है...",decisionApi: {title: "निर्णय API",- description: "लोकल Laya मॉडल से टेक्स्ट पर हाँ/नहीं, बहुविकल्पी और स्कोर वाले सवालों के जवाब दें। TypeSafe SDK के साथ काम करता है।",+ description: "इस मशीन के मॉडल या कनेक्शन के किसी निर्णय मॉडल से टेक्स्ट पर हाँ/नहीं, बहुविकल्पी और स्कोर वाले सवालों के जवाब दें। TypeSafe SDK के साथ काम करता है।",enable: "अनुरोधों का जवाब दें",enableDescription: "/v1/systemone चलाता है। चालू करने पर मॉडल डाउनलोड होता है।",+ enableRemoteDescription: "/v1/systemone चलाता है।",lockedByEnv: "{name} द्वारा सेट।",model: "मॉडल",+ thisMachine: "यह मशीन",modelMultilingual: "बहुभाषी",modelEnglish: "अंग्रेज़ी",modelTypedDecisions: "टाइप्ड निर्णय",@@ -2251,6 +2253,10 @@ export const hi = {downloadFailed: "डाउनलोड शुरू नहीं हो सका।",saveFailed: "निर्णय API की सेटिंग सेव नहीं हो सकी।",loadError: "निर्णय API की सेटिंग्स लोड नहीं हो सकीं।",+ sendsTo: "अनुरोध {provider} को भेजे जाते हैं।",+ connectionMissing: "यह कनेक्शन अब मौजूद नहीं है या इसमें कोई निर्णय मॉडल नहीं है। कोई दूसरा मॉडल चुनें।",+ addConnection: "होस्ट किया गया निर्णय मॉडल इस्तेमाल करने के लिए कनेक्शन में TypeSafe, Liquid AI या OpenRouter जोड़ें।",+ openConnections: "कनेक्शन खोलें",},usageNoModel:"चलाने योग्य उदाहरण देखने के लिए कोई मॉडल लोड या डाउनलोड करें। इस सर्वर के पास अभी बताने को कोई मॉडल नहीं है।",diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.tsindex a45f798241f..060e4307700 100644--- a/studio/frontend/src/i18n/locales/it.ts+++ b/studio/frontend/src/i18n/locales/it.ts@@ -2221,11 +2221,13 @@ export const it = {revoking: "Revoca in corso...",decisionApi: {title: "API decisionale",- description: "Rispondi a domande sì/no, a scelta multipla e a punteggio sul testo con un modello Laya locale. Funziona con l'SDK di TypeSafe.",+ description: "Rispondi a domande sì/no, a scelta multipla e a punteggio sul testo con un modello su questo computer o un modello decisionale dalle Connessioni. Funziona con l'SDK di TypeSafe.",enable: "Rispondi alle richieste",enableDescription: "Gestisce /v1/systemone. Attivandolo si scarica il modello.",+ enableRemoteDescription: "Gestisce /v1/systemone.",lockedByEnv: "Impostato da {name}.",model: "Modello",+ thisMachine: "Questo computer",modelMultilingual: "Multilingue",modelEnglish: "Inglese",modelTypedDecisions: "Decisioni tipizzate",@@ -2250,6 +2252,10 @@ export const it = {downloadFailed: "Impossibile avviare il download.",saveFailed: "Impossibile salvare l'impostazione dell'API decisionale.",loadError: "Impossibile caricare le impostazioni dell'API decisionale.",+ sendsTo: "Le richieste vengono inviate a {provider}.",+ connectionMissing: "Questa connessione non esiste più o non ha modelli decisionali. Scegli un altro modello.",+ addConnection: "Per usare un modello decisionale ospitato, aggiungi TypeSafe, Liquid AI o OpenRouter in Connessioni.",+ openConnections: "Apri Connessioni",},},about: {diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.tsindex c0cd1546514..b6bbb949204 100644--- a/studio/frontend/src/i18n/locales/ja.ts+++ b/studio/frontend/src/i18n/locales/ja.ts@@ -2186,11 +2186,13 @@ export const ja = {revoking: "失効中...",decisionApi: {title: "判定 API",- description: "ローカルの Laya モデルで、テキストに関するはい/いいえ・選択式・スコアの質問に答えます。TypeSafe SDK で使えます。",+ description: "このマシン上のモデル、または接続の判定モデルで、テキストに関するはい/いいえ・選択式・スコアの質問に答えます。TypeSafe SDK で使えます。",enable: "リクエストに応答",enableDescription: "/v1/systemone を提供します。オンにするとモデルをダウンロードします。",+ enableRemoteDescription: "/v1/systemone を提供します。",lockedByEnv: "{name} で設定されています。",model: "モデル",+ thisMachine: "このマシン",modelMultilingual: "多言語",modelEnglish: "英語",modelTypedDecisions: "型付き判定",@@ -2215,6 +2217,10 @@ export const ja = {downloadFailed: "ダウンロードを開始できませんでした。",saveFailed: "判定 API の設定を保存できませんでした。",loadError: "判定 API の設定を読み込めませんでした。",+ sendsTo: "リクエストは {provider} に送信されます。",+ connectionMissing: "この接続は存在しないか、判定モデルがありません。別のモデルを選んでください。",+ addConnection: "ホスト型の判定モデルを使うには、接続で TypeSafe、Liquid AI、OpenRouter のいずれかを追加してください。",+ openConnections: "接続を開く",},usageNoModel:"モデルを読み込むかダウンロードすると、実行できる例が表示されます。このサーバーにはまだ指定できるモデルがありません。",diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.tsindex b205da8c15b..572421baa0f 100644--- a/studio/frontend/src/i18n/locales/ko.ts+++ b/studio/frontend/src/i18n/locales/ko.ts@@ -2209,11 +2209,13 @@ export const ko = {revoking: "폐기 중...",decisionApi: {title: "판단 API",- description: "로컬 Laya 모델로 텍스트에 대한 예/아니오, 객관식, 점수 질문에 답합니다. TypeSafe SDK와 함께 사용할 수 있습니다.",+ description: "이 컴퓨터의 모델이나 연결의 판단 모델로 텍스트에 대한 예/아니오, 객관식, 점수 질문에 답합니다. TypeSafe SDK와 함께 사용할 수 있습니다.",enable: "요청 처리",enableDescription: "/v1/systemone을 제공합니다. 켜면 모델을 다운로드합니다.",+ enableRemoteDescription: "/v1/systemone을 제공합니다.",lockedByEnv: "{name}(으)로 설정됨.",model: "모델",+ thisMachine: "이 컴퓨터",modelMultilingual: "다국어",modelEnglish: "영어",modelTypedDecisions: "유형별 판단",@@ -2238,6 +2240,10 @@ export const ko = {downloadFailed: "다운로드를 시작하지 못했습니다.",saveFailed: "판단 API 설정을 저장하지 못했습니다.",loadError: "판단 API 설정을 불러오지 못했습니다.",+ sendsTo: "요청은 {provider}(으)로 전송됩니다.",+ connectionMissing: "이 연결이 없거나 판단 모델이 없습니다. 다른 모델을 선택하세요.",+ addConnection: "호스팅된 판단 모델을 사용하려면 연결에서 TypeSafe, Liquid AI 또는 OpenRouter를 추가하세요.",+ openConnections: "연결 열기",},usageNoModel:"모델을 로드하거나 다운로드하면 실행 가능한 예제가 표시됩니다. 이 서버에는 아직 지정할 모델이 없습니다.",diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.tsindex 37a05782c94..b724e039d4f 100644--- a/studio/frontend/src/i18n/locales/pt-br.ts+++ b/studio/frontend/src/i18n/locales/pt-br.ts@@ -2232,11 +2232,13 @@ export const ptBR = {revoking: "Revogando...",decisionApi: {title: "API de decisões",- description: "Responda a perguntas de sim/não, múltipla escolha e pontuação sobre texto com um modelo Laya local. Funciona com o SDK da TypeSafe.",+ description: "Responda a perguntas de sim/não, múltipla escolha e pontuação sobre texto com um modelo neste computador ou um modelo de decisões das Conexões. Funciona com o SDK da TypeSafe.",enable: "Atender solicitações",enableDescription: "Atende /v1/systemone. Ao ativar, o modelo é baixado.",+ enableRemoteDescription: "Atende /v1/systemone.",lockedByEnv: "Definido por {name}.",model: "Modelo",+ thisMachine: "Este computador",modelMultilingual: "Multilíngue",modelEnglish: "Inglês",modelTypedDecisions: "Decisões tipadas",@@ -2261,6 +2263,10 @@ export const ptBR = {downloadFailed: "Não foi possível iniciar o download.",saveFailed: "Não foi possível salvar a configuração da API de decisões.",loadError: "Não foi possível carregar as configurações da API de decisões.",+ sendsTo: "As solicitações são enviadas para {provider}.",+ connectionMissing: "Esta conexão não existe mais ou não tem modelos de decisões. Escolha outro modelo.",+ addConnection: "Para usar um modelo de decisões hospedado, adicione TypeSafe, Liquid AI ou OpenRouter em Conexões.",+ openConnections: "Abrir Conexões",},usageNoModel:"Carregue ou baixe um modelo para ver exemplos executáveis. Este servidor ainda não tem nenhum modelo para indicar.",diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.tsindex 366ac1cf2bf..4739fa60bd5 100644--- a/studio/frontend/src/i18n/locales/ru.ts+++ b/studio/frontend/src/i18n/locales/ru.ts@@ -2228,11 +2228,13 @@ export const ru = {revoking: "Отзыв...",decisionApi: {title: "API решений",- description: "Отвечайте на вопросы «да/нет», с выбором и с оценкой о тексте с помощью локальной модели Laya. Работает с SDK TypeSafe.",+ description: "Отвечайте на вопросы «да/нет», с выбором и с оценкой о тексте с помощью модели на этом компьютере или модели решений из подключений. Работает с SDK TypeSafe.",enable: "Обрабатывать запросы",enableDescription: "Обслуживает /v1/systemone. При включении модель скачивается.",+ enableRemoteDescription: "Обслуживает /v1/systemone.",lockedByEnv: "Задано переменной {name}.",model: "Модель",+ thisMachine: "Этот компьютер",modelMultilingual: "Многоязычная",modelEnglish: "Английская",modelTypedDecisions: "Типизированные решения",@@ -2257,6 +2259,10 @@ export const ru = {downloadFailed: "Не удалось начать скачивание.",saveFailed: "Не удалось сохранить настройку API решений.",loadError: "Не удалось загрузить настройки API решений.",+ sendsTo: "Запросы отправляются в {provider}.",+ connectionMissing: "Этого подключения больше нет или в нём нет моделей решений. Выберите другую модель.",+ addConnection: "Чтобы использовать облачную модель решений, добавьте TypeSafe, Liquid AI или OpenRouter в разделе «Подключения».",+ openConnections: "Открыть подключения",},usageNoModel:"Загрузите или скачайте модель, чтобы увидеть готовые к запуску примеры. На этом сервере пока нет модели, которую можно подставить в примеры.",diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.tsindex 6907c99d18d..4bee36c07f7 100644--- a/studio/frontend/src/i18n/locales/zh-CN.ts+++ b/studio/frontend/src/i18n/locales/zh-CN.ts@@ -2166,11 +2166,13 @@ export const zhCN = {revoking: "撤销中...",decisionApi: {title: "决策 API",- description: "使用本地 Laya 模型回答关于文本的是/否、选择和评分问题。可配合 TypeSafe SDK 使用。",+ description: "使用本机模型或连接中的决策模型回答关于文本的是/否、选择和评分问题。可配合 TypeSafe SDK 使用。",enable: "处理请求",enableDescription: "提供 /v1/systemone。开启后会下载模型。",+ enableRemoteDescription: "提供 /v1/systemone。",lockedByEnv: "由 {name} 设置。",model: "模型",+ thisMachine: "本机",modelMultilingual: "多语言",modelEnglish: "英语",modelTypedDecisions: "类型化决策",@@ -2195,6 +2197,10 @@ export const zhCN = {downloadFailed: "无法开始下载。",saveFailed: "无法保存决策 API 设置。",loadError: "无法加载决策 API 设置。",+ sendsTo: "请求将发送到 {provider}。",+ connectionMissing: "此连接已不存在或没有决策模型。请选择其他模型。",+ addConnection: "要使用托管的决策模型,请在连接中添加 TypeSafe、Liquid AI 或 OpenRouter。",+ openConnections: "打开连接",},usageNoModel:"加载或下载一个模型后即可看到可运行的示例。此服务器目前还没有可指定的模型。",diff --git a/studio/frontend/tests/decision-connections.test.ts b/studio/frontend/tests/decision-connections.test.tsnew file mode 100644index 00000000000..77219ee65f2--- /dev/null+++ b/studio/frontend/tests/decision-connections.test.ts@@ -0,0 +1,41 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import assert from "node:assert/strict";+import test, { after } from "node:test";+import { createServer } from "vite";+import { installLocalStorageFake } from "./helpers/kit.ts";++installLocalStorageFake();+Object.assign(window.location, { href: "http://localhost/" });+const vite = await createServer({ server: { middlewareMode: true } });+after(() => vite.close());++test("System One connections stay decision-only after a reload", async () => {+ const api = await vite.ssrLoadModule("/src/features/chat/api/providers-api.ts");+ const providers = await vite.ssrLoadModule("/src/features/chat/external-providers.ts");+ const bodies: Record<string, unknown>[] = [];+ const previous = globalThis.fetch;+ globalThis.fetch = (async (_url, init) => {+ bodies.push(JSON.parse(String(init?.body))); return Response.json({});+ }) as typeof fetch;+ try {+ await api.createProviderConfig({ providerType: "custom", displayName: "Decider", apiType: "systemone" });+ } finally {+ globalThis.fetch = previous;+ }+ assert.equal(bodies[0].api_type, "systemone");++ const decider = { id: "decider", providerType: "custom", name: "Decider", baseUrl: "http://localhost:8080/v1",+ models: ["jev-latest"], createdAt: 1, updatedAt: 1, ...providers.connectionApiFields("systemone") };+ providers.saveExternalProviders([decider]);+ assert.ok(providers.isDecisionConnection(providers.loadExternalProviders()[0]));+ for (const providerType of ["typesafe", "liquid"]) {+ assert.ok(providers.isDecisionConnection({ providerType }), providerType);+ }+ for (const apiType of ["chat_completions", "responses", undefined]) {+ const chat = { providerType: "custom", ...providers.connectionApiFields(apiType) };+ assert.equal(providers.isDecisionConnection(chat), false, String(apiType));+ }+ assert.equal(providers.isDecisionConnection({ providerType: "openrouter" }), false);+});diff --git a/studio/frontend/tests/provider-logo-path.test.ts b/studio/frontend/tests/provider-logo-path.test.tsindex eeacf86d60f..c889bf11eb9 100644--- a/studio/frontend/tests/provider-logo-path.test.ts+++ b/studio/frontend/tests/provider-logo-path.test.ts@@ -38,6 +38,7 @@ test("every supported connection resolves to an existing public asset", () => {for (const type of ["openai", "openai_codex", "deepseek", "mistral", "huggingface", "kimi","qwen", "gemini", "anthropic", "openrouter", "vllm", "ollama", "llama_cpp",+ "liquid", "typesafe",]) {const path = providerLogoPath(type);assert.ok(path?.startsWith("/"), type);