macore-client-dev 0.1.79__tar.gz → 0.1.81__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: macore-client-dev
3
- Version: 0.1.79
3
+ Version: 0.1.81
4
4
  Summary: Client for the Model Access Core (MAC) server
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: mcp-proxy-adapter<9,>=8.11.11
@@ -1,3 +1,3 @@
1
1
  """The single release version shared by the client and server packages."""
2
2
 
3
- __version__ = "0.1.79"
3
+ __version__ = "0.1.81"
@@ -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``. It contains only positive integer limits and the
46
- exact model ID advertised by MAC; it never translates provider aliases.
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 not isinstance(max_output_tokens, int)
79
- or isinstance(max_output_tokens, bool)
80
- or max_output_tokens <= 0
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
- return min(selections, key=lambda selection: str(selection["model_id"])) if selections else None
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 limits in catalog")
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": min(32, int(selection["max_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
  }