$ cat node-template.py
O
Ontology Create Object
// Create (or idempotently upsert by identity key) an object in the organization ontology and return its id for chaining into Ontology Create Link.
Process
Data
#ontology#knowledge-graph#create#object#write
template.py
1"""ontology-create-object — mint (or idempotently upsert) an ontology object.23Creates a new object of ``objectTypeId`` keyed by ``identityKey`` via the4gais.ontology SDK (``Gais.ontology.create_object``). The server de-dupes by the5identity key, so re-running returns the existing object's id instead of a6duplicate. Privileged IO carries the per-execution USER_TOKEN inside the SDK —7this node imports no HTTP client. Returns the object ``id`` for chaining into8Ontology Create Link.9"""1011from __future__ import annotations1213import json14import sys15import traceback16from typing import Any1718from gais import Gais192021def _parse_obj(value: Any, field: str) -> dict:22 """Accept a mapping or a JSON-object string; reject anything else."""23 if value in (None, ""):24 return {}25 if isinstance(value, dict):26 return value27 if isinstance(value, str):28 parsed = json.loads(value)29 if not isinstance(parsed, dict):30 raise ValueError(f"{field} must be a JSON object")31 return parsed32 raise ValueError(f"{field} must be a JSON object")333435def _parse_confidence(value: Any) -> float | None:36 if value in (None, ""):37 return None38 return float(value)394041def process(inputs: dict[str, Any]) -> dict[str, Any]:42 object_type_id = str(inputs.get("objectTypeId") or "").strip()43 if not object_type_id:44 raise ValueError("Required input 'objectTypeId' not provided")4546 identity_key = str(inputs.get("identityKey") or "").strip()47 if not identity_key:48 raise ValueError("Required input 'identityKey' not provided")4950 properties = _parse_obj(inputs.get("properties"), "properties")51 confidence = _parse_confidence(inputs.get("confidence"))5253 result = Gais.ontology.create_object(54 object_type_id=object_type_id,55 identity_key=identity_key,56 properties=properties,57 confidence=confidence,58 )59 object_id = result.get("id", "") if isinstance(result, dict) else ""6061 print(62 f"[ontology-create-object] type={object_type_id} "63 f"identity_key={identity_key} id={object_id}",64 file=sys.stderr,65 )6667 return {"id": object_id}686970def main() -> None:71 try:72 envelope = json.loads(sys.stdin.read() or "{}")73 if not isinstance(envelope, dict):74 envelope = {}75 inputs = envelope.get("inputs", {}) or {}76 json.dump(process(inputs), sys.stdout)77 except Exception as e:78 print(79 json.dumps({80 "error": str(e),81 "errorType": type(e).__name__,82 "traceback": traceback.format_exc(),83 }),84 file=sys.stderr,85 )86 sys.exit(1)878889if __name__ == "__main__":90 main()$ git log --oneline
v1.0.0
HEAD
2026-08-18