macore-client-dev 0.1.80__tar.gz → 0.1.82__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.80 → macore_client_dev-0.1.82}/PKG-INFO +2 -2
- {macore_client_dev-0.1.80 → macore_client_dev-0.1.82}/macore_client/__about__.py +1 -1
- {macore_client_dev-0.1.80 → macore_client_dev-0.1.82}/macore_client/live_check.py +24 -10
- {macore_client_dev-0.1.80 → macore_client_dev-0.1.82}/pyproject.toml +1 -1
- {macore_client_dev-0.1.80 → macore_client_dev-0.1.82}/.gitignore +0 -0
- {macore_client_dev-0.1.80 → macore_client_dev-0.1.82}/macore_client/__init__.py +0 -0
- {macore_client_dev-0.1.80 → macore_client_dev-0.1.82}/macore_client/cli.py +0 -0
- {macore_client_dev-0.1.80 → macore_client_dev-0.1.82}/macore_client/client.py +0 -0
|
@@ -37,13 +37,16 @@ async def _with_client(coro: Any) -> int:
|
|
|
37
37
|
await client.close()
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
def select_catalog_chat_model(catalog: Any, provider_id: str) -> dict[str, int | str] | None:
|
|
40
|
+
def select_catalog_chat_model(catalog: Any, provider_id: str) -> dict[str, int | str | None] | None:
|
|
41
41
|
"""Return one catalog-backed chat identity for ``provider_id``.
|
|
42
42
|
|
|
43
43
|
The returned mapping is deliberately small and stable for pipeline callers:
|
|
44
44
|
``provider_id``, ``model_id``, ``context_window``, and
|
|
45
|
-
``max_output_tokens``.
|
|
46
|
-
|
|
45
|
+
``max_output_tokens``. Every listed chat model has a positive integer context
|
|
46
|
+
window (provider/config value or the macsc fallback table); ``max_output_tokens``
|
|
47
|
+
is a positive integer or ``None`` where no source documents one. A model with a
|
|
48
|
+
documented output limit is preferred; the exact model ID advertised by MAC is
|
|
49
|
+
returned, provider aliases are never translated.
|
|
47
50
|
"""
|
|
48
51
|
|
|
49
52
|
data = catalog.get("data") if isinstance(catalog, dict) else None
|
|
@@ -62,7 +65,7 @@ def select_catalog_chat_model(catalog: Any, provider_id: str) -> dict[str, int |
|
|
|
62
65
|
if not isinstance(summaries, list):
|
|
63
66
|
return None
|
|
64
67
|
|
|
65
|
-
selections: list[dict[str, int | str]] = []
|
|
68
|
+
selections: list[dict[str, int | str | None]] = []
|
|
66
69
|
for summary in summaries:
|
|
67
70
|
if not isinstance(summary, dict):
|
|
68
71
|
continue
|
|
@@ -75,9 +78,14 @@ def select_catalog_chat_model(catalog: Any, provider_id: str) -> dict[str, int |
|
|
|
75
78
|
or not isinstance(context_window, int)
|
|
76
79
|
or isinstance(context_window, bool)
|
|
77
80
|
or context_window <= 0
|
|
78
|
-
or
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
or (
|
|
82
|
+
max_output_tokens is not None
|
|
83
|
+
and (
|
|
84
|
+
not isinstance(max_output_tokens, int)
|
|
85
|
+
or isinstance(max_output_tokens, bool)
|
|
86
|
+
or max_output_tokens <= 0
|
|
87
|
+
)
|
|
88
|
+
)
|
|
81
89
|
):
|
|
82
90
|
continue
|
|
83
91
|
selections.append(
|
|
@@ -89,14 +97,16 @@ def select_catalog_chat_model(catalog: Any, provider_id: str) -> dict[str, int |
|
|
|
89
97
|
}
|
|
90
98
|
)
|
|
91
99
|
|
|
92
|
-
|
|
100
|
+
if not selections:
|
|
101
|
+
return None
|
|
102
|
+
return min(selections, key=lambda selection: (selection["max_output_tokens"] is None, str(selection["model_id"])))
|
|
93
103
|
|
|
94
104
|
|
|
95
105
|
async def _run_catalog_chat_live(client: MacClient, provider_id: str) -> int:
|
|
96
106
|
catalog = await client.model_providers()
|
|
97
107
|
selection = select_catalog_chat_model(catalog, provider_id)
|
|
98
108
|
if selection is None:
|
|
99
|
-
print(f"FAIL {provider_id}-live: no chat model with positive
|
|
109
|
+
print(f"FAIL {provider_id}-live: no chat model with a positive context window in catalog")
|
|
100
110
|
return 1
|
|
101
111
|
|
|
102
112
|
result = await client.model_chat(
|
|
@@ -107,7 +117,11 @@ async def _run_catalog_chat_live(client: MacClient, provider_id: str) -> int:
|
|
|
107
117
|
"messages": [
|
|
108
118
|
{"role": "user", "content": [{"type": "text", "text": "Reply OK."}]}
|
|
109
119
|
],
|
|
110
|
-
"reserved_output_tokens":
|
|
120
|
+
"reserved_output_tokens": (
|
|
121
|
+
32
|
|
122
|
+
if selection["max_output_tokens"] is None
|
|
123
|
+
else min(32, int(selection["max_output_tokens"]))
|
|
124
|
+
),
|
|
111
125
|
"stream": False,
|
|
112
126
|
"generation_options": {},
|
|
113
127
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|