Open-source inference server and production cluster for all the models your agent needs.
Python bgecolbertdata-pipelinedeep-learningembeddingsinferenceinference-serverinformation-retrievalllmmlmlopsnatural-language-processingnlppythonrerankingretrievalretrieval-augmented-generationsemantic-searchspladevector-search
fix(api): refresh model metadata and scope usage checks
svonava24d4d0fc553f
diff --git a/examples/systemone-local/README.md b/examples/systemone-local/README.mdindex 482d9e10b..481804849 100644--- a/examples/systemone-local/README.md+++ b/examples/systemone-local/README.md@@ -60,9 +60,14 @@ Use the same three variables with the Serverless endpoint and your SIE key:export TYPESAFE_BASE_URL=<your SIE Serverless URL>export TYPESAFE_DEFAULT_MODEL=fastino/GLiNER2.5-Decideexport TYPESAFE_API_KEY=$SIE_API_KEY-uv run conformance.py --check-auth+uv run conformance.py --gateway --check-auth```+`--gateway` allows the gateway's current `usage.input_tokens=0` placeholder+until native extract usage is available. Without it, the checker requires a+positive input-token count from a direct server. `--check-auth` separately+checks that an invalid key is refused.+A Serverless model that has gone cold takes minutes to load. SIE answers`503` with a `Retry-After` of at most 60 seconds while it loads, and theTypeSafe SDK retries twice by default (`max_retries=2` in `typesafe-sdk`diff --git a/examples/systemone-local/conformance.py b/examples/systemone-local/conformance.pyindex 3fd1b7be9..e4adc8e44 100644--- a/examples/systemone-local/conformance.py+++ b/examples/systemone-local/conformance.py@@ -10,10 +10,12 @@ case fails.TYPESAFE_BASE_URL=http://localhost:8080 \\TYPESAFE_DEFAULT_MODEL=fastino/GLiNER2.5-Decide \\TYPESAFE_API_KEY=local \\- uv run conformance.py [--check-auth] [--json results.json]+ uv run conformance.py [--gateway] [--check-auth] [--json results.json]``--check-auth`` adds the bad-key case, for a deployment that checks keys(a cluster gateway or SIE Serverless); a local ``sie-server`` checks none.+``--gateway`` accepts its current zero input-token usage placeholder. Direct+server checks require a positive input-token count."""from __future__ import annotations@@ -134,10 +136,13 @@ def case_extra_body(client: TypeSafeClient, model: str) -> str:return "unknown request fields ignored"-def case_envelope(client: TypeSafeClient, model: str) -> str:+def case_envelope(client: TypeSafeClient, model: str, *, gateway: bool = False) -> str:response = client.system_one(state=TICKET, questions={"spam": Noul(instructions="Is this spam?")})assert response.model == model, response.model- assert response.usage.input_tokens is not None and response.usage.input_tokens > 0, response.usage+ minimum_input_tokens = 0 if gateway else 1+ assert response.usage.input_tokens is not None and response.usage.input_tokens >= minimum_input_tokens, (+ response.usage+ )assert response.usage.output_tokens == 0, response.usagereturn f"model={response.model} input_tokens={response.usage.input_tokens}"@@ -213,7 +218,7 @@ CASES: list[Callable[[TypeSafeClient, str], str]] = []-def run(*, check_auth: bool = False) -> list[Case]:+def run(*, check_auth: bool = False, gateway: bool = False) -> list[Case]:model = os.environ.get("TYPESAFE_DEFAULT_MODEL", "")if not model:raise SystemExit("Set TYPESAFE_DEFAULT_MODEL to an SIE decision model, e.g. fastino/GLiNER2.5-Decide")@@ -223,7 +228,8 @@ def run(*, check_auth: bool = False) -> list[Case]:for case in cases:name = case.__name__.removeprefix("case_")try:- results.append(Case(name, True, case(client, model)))+ detail = case_envelope(client, model, gateway=gateway) if case is case_envelope else case(client, model)+ results.append(Case(name, True, detail))except Exception as error: # noqa: BLE001 - every failure is reported, not raisedresults.append(Case(name, False, f"{type(error).__name__}: {error}"))return results@@ -240,14 +246,16 @@ def report(results: list[Case]) -> str:def main(argv: list[str] | None = None) -> int:parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)parser.add_argument("--check-auth", action="store_true", help="also check that a bad key is refused")+ parser.add_argument("--gateway", action="store_true", help="allow the gateway's zero input-token usage placeholder")parser.add_argument("--json", type=Path, help="write the results to this file")args = parser.parse_args(argv)- results = run(check_auth=args.check_auth)+ results = run(check_auth=args.check_auth, gateway=args.gateway)print(report(results))if args.json:payload: dict[str, Any] = {"base_url": os.environ.get("TYPESAFE_BASE_URL"),"model": os.environ.get("TYPESAFE_DEFAULT_MODEL"),+ "gateway": args.gateway,"cases": [asdict(result) for result in results],}args.json.write_text(json.dumps(payload, indent=2) + "\n", encoding="utf-8")diff --git a/examples/systemone-local/tests/test_conformance.py b/examples/systemone-local/tests/test_conformance.pyindex ffbed9600..411a9acf1 100644--- a/examples/systemone-local/tests/test_conformance.py+++ b/examples/systemone-local/tests/test_conformance.py@@ -12,6 +12,7 @@ import jsonimport threadingfrom collections.abc import Iteratorfrom http.server import BaseHTTPRequestHandler, ThreadingHTTPServer+from pathlib import Pathfrom typing import Anyimport pytest@@ -63,7 +64,7 @@ def _systemone(body: dict[str, Any], authorization: str | None) -> tuple[int, dianswers = {qid: _answer(question) for qid, question in questions.items()}if KNOBS.get("drop_answer"):answers.popitem()- tokens: Any = 12.0 if KNOBS.get("float_tokens") else 12+ tokens: Any = KNOBS.get("input_tokens", 12.0 if KNOBS.get("float_tokens") else 12)return 200, {"model": MODEL, "answers": answers, "usage": {"input_tokens": tokens, "output_tokens": 0}}@@ -150,3 +151,20 @@ def test_report_lists_every_case(server: str) -> None:results = conformance.run()text = conformance.report(results)assert text.splitlines()[-1] == f"{len(results)}/{len(results)} passed"++[email protected]("gateway", [False, True])[email protected]("tokens", [None, -1, 0, 12])+def test_envelope_requires_explicit_gateway_for_zero_usage(server: str, gateway: bool, tokens: int | None) -> None:+ KNOBS["input_tokens"] = tokens+ assert _verdicts(gateway=gateway)["envelope"] is (tokens is not None and tokens >= (0 if gateway else 1))+++def test_gateway_flag_is_explicit_and_recorded(server: str, tmp_path: Path) -> None:+ KNOBS["input_tokens"] = 0+ assert conformance.main([]) == 1+ output = tmp_path / "gateway.json"+ assert conformance.main(["--gateway", "--json", str(output)]) == 0+ payload = json.loads(output.read_text())+ assert payload["gateway"] is True+ assert all(case["passed"] for case in payload["cases"])diff --git a/packages/sie_gateway/src/state/model_registry.rs b/packages/sie_gateway/src/state/model_registry.rsindex 88467446a..46505f41d 100644--- a/packages/sie_gateway/src/state/model_registry.rs+++ b/packages/sie_gateway/src/state/model_registry.rs@@ -2993,6 +2993,8 @@ impl ModelRegistry {&& config.tasks.is_none()&& config.max_sequence_length.is_none()&& config.hf_revision.is_none()+ && config.description.is_none()+ && config.release_date.is_none()&& !touches_profiles{return;@@ -3002,6 +3004,12 @@ impl ModelRegistry {if config.hf_revision.is_some() {existing.revision = refreshed.revision;}+ if config.description.is_some() {+ existing.description = refreshed.description;+ }+ if config.release_date.is_some() {+ existing.release_date = refreshed.release_date;+ }if config.inputs.is_some() {existing.inputs = refreshed.inputs;}@@ -5753,6 +5761,108 @@ encode:assert_eq!(refreshed.info_extras.max_sequence_length, Some(1024));}+ #[test]+ fn test_model_metadata_delta_refreshes_base_and_profile_variants() {+ let (_dir, bundles_dir, models_dir) = create_test_dirs();+ fs::write(+ bundles_dir.join("default.yaml"),+ "name: default\npriority: 10\nadapters:\n - module\n",+ )+ .unwrap();+ let registry = ModelRegistry::new(&bundles_dir, &models_dir, true);+ let initial: ModelConfig = serde_json::from_value(serde_json::json!({+ "name": "test/model",+ "description": "Original description",+ "release_date": "2026-09-24",+ "max_sequence_length": 512,+ "tasks": {"encode": {"dense": {"dim": 384}}},+ "profiles": {+ "default": {"adapter_path": "module:Adapter", "max_batch_tokens": 4096},+ "alt": {"adapter_path": "module:Adapter", "max_batch_tokens": 2048}+ }+ }))+ .unwrap();+ registry.add_model_config(initial).unwrap();++ for (metadata, description, release_date) in [+ (+ serde_json::json!({"description": "Updated description"}),+ "Updated description",+ "2026-09-24",+ ),+ (+ serde_json::json!({"release_date": "2026-10-16"}),+ "Updated description",+ "2026-10-16",+ ),+ (serde_json::json!({}), "Updated description", "2026-10-16"),+ (+ serde_json::json!({"description": "", "release_date": ""}),+ "",+ "",+ ),+ ] {+ let mut delta = serde_json::json!({+ "name": "test/model",+ "profiles": {"default": {"adapter_path": "module:Adapter", "max_batch_tokens": 4096}}+ });+ delta+ .as_object_mut()+ .unwrap()+ .extend(metadata.as_object().unwrap().clone());+ registry+ .add_model_config(serde_json::from_value(delta).unwrap())+ .unwrap();++ for name in ["test/model", "test/model:alt"] {+ let info = registry.get_model_info(name).unwrap();+ assert_eq!(info.info_extras.description.as_deref(), Some(description));+ assert_eq!(info.info_extras.release_date.as_deref(), Some(release_date));+ assert_eq!(info.info_extras.outputs, vec!["dense"]);+ assert_eq!(info.info_extras.dims["dense"], 384);+ assert_eq!(info.info_extras.max_sequence_length, Some(512));+ }+ }+ }++ #[test]+ fn test_model_metadata_only_merge_preserves_omitted_fields() {+ let initial: ModelConfig = serde_json::from_value(serde_json::json!({+ "name": "test/model",+ "description": "Original description",+ "release_date": "2026-09-24",+ "max_sequence_length": 512+ }))+ .unwrap();+ let mut extras = ModelInfoExtras::from_model_config(&initial);+ for (metadata, description, release_date) in [+ (+ serde_json::json!({"description": "Updated description"}),+ "Updated description",+ "2026-09-24",+ ),+ (+ serde_json::json!({"release_date": "2026-10-16"}),+ "Updated description",+ "2026-10-16",+ ),+ ] {+ let mut delta = serde_json::json!({"name": "test/model"});+ delta+ .as_object_mut()+ .unwrap()+ .extend(metadata.as_object().unwrap().clone());+ ModelRegistry::merge_model_info_extras(+ &mut extras,+ &serde_json::from_value(delta).unwrap(),+ &HashMap::new(),+ );+ assert_eq!(extras.description.as_deref(), Some(description));+ assert_eq!(extras.release_date.as_deref(), Some(release_date));+ assert_eq!(extras.max_sequence_length, Some(512));+ }+ }+#[test]fn test_tasks_delta_refreshes_streaming_capability_for_base_and_variants() {let (_dir, bundles_dir, models_dir) = create_test_dirs();