macore-client-dev 0.1.138__tar.gz → 0.1.140__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {macore_client_dev-0.1.138 → macore_client_dev-0.1.140}/PKG-INFO +1 -1
- {macore_client_dev-0.1.138 → macore_client_dev-0.1.140}/macore_client/__about__.py +1 -1
- {macore_client_dev-0.1.138 → macore_client_dev-0.1.140}/macore_client/__init__.py +2 -2
- {macore_client_dev-0.1.138 → macore_client_dev-0.1.140}/macore_client/client.py +38 -0
- {macore_client_dev-0.1.138 → macore_client_dev-0.1.140}/.gitignore +0 -0
- {macore_client_dev-0.1.138 → macore_client_dev-0.1.140}/macore_client/cli.py +0 -0
- {macore_client_dev-0.1.138 → macore_client_dev-0.1.140}/macore_client/decision.py +0 -0
- {macore_client_dev-0.1.138 → macore_client_dev-0.1.140}/macore_client/live_check.py +0 -0
- {macore_client_dev-0.1.138 → macore_client_dev-0.1.140}/macore_client/trace.py +0 -0
- {macore_client_dev-0.1.138 → macore_client_dev-0.1.140}/pyproject.toml +0 -0
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
# Project: model_access_core (71b1e006-b777-4edb-854e-f0a47120f793)
|
|
4
4
|
"""Client package for the Model Access Core (MAC) server."""
|
|
5
5
|
|
|
6
|
-
from macore_client.client import MacClient
|
|
6
|
+
from macore_client.client import MacClient, json_object_format, json_schema_format
|
|
7
7
|
from macore_client.__about__ import __version__
|
|
8
8
|
from macore_client.decision import DecisionResult, DecisionAuditReceipt, ThresholdResult, NoulAnswer, ChoiceAnswer, ScoreAnswer
|
|
9
9
|
|
|
10
|
-
__all__ = ["MacClient", "__version__", "DecisionResult", "DecisionAuditReceipt", "ThresholdResult", "NoulAnswer", "ChoiceAnswer", "ScoreAnswer"]
|
|
10
|
+
__all__ = ["MacClient", "json_object_format", "json_schema_format", "__version__", "DecisionResult", "DecisionAuditReceipt", "ThresholdResult", "NoulAnswer", "ChoiceAnswer", "ScoreAnswer"]
|
|
@@ -340,7 +340,45 @@ class MacClient:
|
|
|
340
340
|
})
|
|
341
341
|
|
|
342
342
|
|
|
343
|
+
class _Unset:
|
|
344
|
+
"""The marker of a keyword the caller did not supply (``None`` is a value of ``response_format``: the explicit null cell)."""
|
|
345
|
+
|
|
346
|
+
def __repr__(self) -> str:
|
|
347
|
+
return "<not supplied>"
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
_UNSET: Any = _Unset()
|
|
351
|
+
_RESPONSE_FORMAT_COMMANDS: frozenset[str] = frozenset({"model_chat", "model_count_tokens", "model_estimate_request_capacity"})
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def json_object_format() -> dict[str, Any]:
|
|
355
|
+
"""The ``response_format`` cell asking for one JSON object (``{"type": "json_object"}``)."""
|
|
356
|
+
return {"type": "json_object"}
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
def json_schema_format(name: str, schema: dict[str, Any], *, strict: bool = True, description: str | None = None) -> dict[str, Any]:
|
|
360
|
+
"""The ``response_format`` cell asking for JSON that follows ``schema`` (``name`` matches ``^[A-Za-z0-9_-]{1,64}$``); ``description`` is sent only when given."""
|
|
361
|
+
spec: dict[str, Any] = {"name": name, "schema": schema, "strict": strict}
|
|
362
|
+
if description is not None:
|
|
363
|
+
spec["description"] = description
|
|
364
|
+
return {"type": "json_schema", "json_schema": spec}
|
|
365
|
+
|
|
366
|
+
|
|
343
367
|
def _make_method(command: str) -> Any:
|
|
368
|
+
if command in _RESPONSE_FORMAT_COMMANDS:
|
|
369
|
+
async def with_response_format(self: MacClient, params: dict[str, Any] | None = None, *, response_format: Any = _UNSET) -> Any:
|
|
370
|
+
"""Execute the MAC command; ``response_format`` (keyword) is the top-level structured-output cell (``text`` | ``json_object`` | ``json_schema``, see ``json_object_format`` / ``json_schema_format``) and overrides a cell in ``params``."""
|
|
371
|
+
merged = dict(params or {})
|
|
372
|
+
if response_format is not _UNSET:
|
|
373
|
+
merged["response_format"] = response_format
|
|
374
|
+
return await self.call(command, merged)
|
|
375
|
+
|
|
376
|
+
with_response_format.__name__ = command
|
|
377
|
+
with_response_format.__qualname__ = f"MacClient.{command}"
|
|
378
|
+
with_response_format.__doc__ = (f"Execute the MAC ``{command}`` command; the keyword ``response_format`` is the top-level structured-output cell "
|
|
379
|
+
"(``text`` | ``json_object`` | ``json_schema``, see ``json_object_format`` / ``json_schema_format``) and overrides a cell in ``params``.")
|
|
380
|
+
return with_response_format
|
|
381
|
+
|
|
344
382
|
async def method(self: MacClient, params: dict[str, Any] | None = None) -> Any:
|
|
345
383
|
return await self.call(command, params)
|
|
346
384
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|