statek 1.2.0__tar.gz → 1.2.2__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.
- {statek-1.2.0/statek.egg-info → statek-1.2.2}/PKG-INFO +4 -4
- {statek-1.2.0 → statek-1.2.2}/pyproject.toml +4 -4
- {statek-1.2.0 → statek-1.2.2}/statek/executors/job.py +13 -17
- {statek-1.2.0 → statek-1.2.2}/statek/llm_api.py +51 -7
- {statek-1.2.0 → statek-1.2.2}/statek/locale.py +15 -4
- {statek-1.2.0 → statek-1.2.2}/statek/provider_config.py +40 -2
- {statek-1.2.0 → statek-1.2.2}/statek/system.py +11 -0
- {statek-1.2.0 → statek-1.2.2/statek.egg-info}/PKG-INFO +4 -4
- {statek-1.2.0 → statek-1.2.2}/statek.egg-info/requires.txt +3 -3
- {statek-1.2.0 → statek-1.2.2}/LICENSE +0 -0
- {statek-1.2.0 → statek-1.2.2}/MANIFEST.in +0 -0
- {statek-1.2.0 → statek-1.2.2}/NOTICE +0 -0
- {statek-1.2.0 → statek-1.2.2}/README.md +0 -0
- {statek-1.2.0 → statek-1.2.2}/THIRD_PARTY_NOTICES.md +0 -0
- {statek-1.2.0 → statek-1.2.2}/setup.cfg +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/__init__.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/agents/__init__.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/agents/agent.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/agents/coordinator.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/agents/dialog_agent.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/agents/list_of_documents.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/agents/list_of_examples.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/agents/message_dispatcher.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/agents/researcher.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/chat_history.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/chat_style.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/dbzero_restricted.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/docstring.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/document.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/exceptions.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/executors/chat_log_item.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/executors/example.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/executors/llm_usage.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/executors/post_processor.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/executors/utils.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/future.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/llm_harness.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/llm_tools_scope.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/model_name.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/model_pricing.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/multi_source_settings.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/prompt_config.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/pyenv.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/python_response_format.json +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/python_sandbox.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/rpc_integration.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/runner.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/settings.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/shared_context.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/statek_client_api.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/statek_push_queue.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/task.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/task_difficulty.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/testing.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek/utils.py +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek.egg-info/SOURCES.txt +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek.egg-info/dependency_links.txt +0 -0
- {statek-1.2.0 → statek-1.2.2}/statek.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: statek
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: Durable Python workspaces for stateful LLM agents
|
|
5
5
|
Author: Statek authors
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -26,12 +26,12 @@ Requires-Dist: nest_asyncio==1.6.0
|
|
|
26
26
|
Requires-Dist: RestrictedPython>=8.3
|
|
27
27
|
Provides-Extra: dbzero
|
|
28
28
|
Requires-Dist: dbzero-modelkit[dbzero]>=1.2.0; extra == "dbzero"
|
|
29
|
-
Requires-Dist: dbzero>=0.6.
|
|
29
|
+
Requires-Dist: dbzero>=0.6.1; extra == "dbzero"
|
|
30
30
|
Provides-Extra: dbzero-pro
|
|
31
31
|
Requires-Dist: dbzero-modelkit[dbzero-pro]>=1.2.0; extra == "dbzero-pro"
|
|
32
|
-
Requires-Dist: dbzero-pro>=0.6.
|
|
32
|
+
Requires-Dist: dbzero-pro>=0.6.2; extra == "dbzero-pro"
|
|
33
33
|
Provides-Extra: dev
|
|
34
|
-
Requires-Dist: dbzero>=0.6.
|
|
34
|
+
Requires-Dist: dbzero>=0.6.1; extra == "dev"
|
|
35
35
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
36
36
|
Requires-Dist: pytest-asyncio==1.3.0; extra == "dev"
|
|
37
37
|
Requires-Dist: pylint>=3.0; extra == "dev"
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "statek"
|
|
7
|
-
version = "1.2.
|
|
7
|
+
version = "1.2.2"
|
|
8
8
|
description = "Durable Python workspaces for stateful LLM agents"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -33,14 +33,14 @@ dependencies = [
|
|
|
33
33
|
[project.optional-dependencies]
|
|
34
34
|
dbzero = [
|
|
35
35
|
"dbzero-modelkit[dbzero]>=1.2.0",
|
|
36
|
-
"dbzero>=0.6.
|
|
36
|
+
"dbzero>=0.6.1",
|
|
37
37
|
]
|
|
38
38
|
dbzero-pro = [
|
|
39
39
|
"dbzero-modelkit[dbzero-pro]>=1.2.0",
|
|
40
|
-
"dbzero-pro>=0.6.
|
|
40
|
+
"dbzero-pro>=0.6.2",
|
|
41
41
|
]
|
|
42
42
|
dev = [
|
|
43
|
-
"dbzero>=0.6.
|
|
43
|
+
"dbzero>=0.6.1",
|
|
44
44
|
"pytest>=7.0",
|
|
45
45
|
"pytest-asyncio==1.3.0",
|
|
46
46
|
"pylint>=3.0",
|
|
@@ -344,6 +344,7 @@ class JobDefError:
|
|
|
344
344
|
|
|
345
345
|
|
|
346
346
|
_JOBDEF_HASH_TAG_PREFIX = "STATEK_JOBDEF:H:"
|
|
347
|
+
_JOB_LIFETIME_TAG = "STATEK_JOB"
|
|
347
348
|
|
|
348
349
|
|
|
349
350
|
def _job_def_identity_hash(
|
|
@@ -401,6 +402,7 @@ def job_def_identity_tag_for_job_def(job_def: "JobDef") -> str:
|
|
|
401
402
|
|
|
402
403
|
|
|
403
404
|
@memo
|
|
405
|
+
@db0.tag_fields("agent")
|
|
404
406
|
@dataclass
|
|
405
407
|
class JobDef:
|
|
406
408
|
"""
|
|
@@ -424,8 +426,6 @@ class JobDef:
|
|
|
424
426
|
provider_config: Optional[ProviderConfig] = None
|
|
425
427
|
|
|
426
428
|
def __post_init__(self):
|
|
427
|
-
if self.agent is not None:
|
|
428
|
-
db0.tags(self).add(self.agent)
|
|
429
429
|
if self.metadata is None:
|
|
430
430
|
self.metadata = (
|
|
431
431
|
self.agent._metadata
|
|
@@ -568,6 +568,7 @@ class ErrorHandler:
|
|
|
568
568
|
|
|
569
569
|
|
|
570
570
|
@memo
|
|
571
|
+
@db0.tag_fields("agent", "job_def", "job_status")
|
|
571
572
|
class Job:
|
|
572
573
|
"""
|
|
573
574
|
A single "job" is a stateful class representing the current state of a single unit-of-work, being performed end-to-end by a single agent. By a "job" we might mean either a very simple operation such as answering a basic question ("Hey, what day of week is today") or a complex task involving retrieving information from external systems, communicating with external actors, waiting for approvals etc. - before the final response is generated.
|
|
@@ -590,12 +591,10 @@ class Job:
|
|
|
590
591
|
):
|
|
591
592
|
del model_family, model # backward-compatible init args; source of truth is JobDef
|
|
592
593
|
self.job_def = job_def
|
|
594
|
+
self.agent = self.job_def.agent
|
|
593
595
|
self.parent_job = parent_job
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
# Private job status attribute
|
|
597
|
-
self.__job_status = None
|
|
598
|
-
self.set_status(job_status)
|
|
596
|
+
self.job_status = job_status
|
|
597
|
+
db0.tags(self).add(_JOB_LIFETIME_TAG)
|
|
599
598
|
# LLM program's execution environment
|
|
600
599
|
self.py_env = py_env if py_env is not None else PyEnv()
|
|
601
600
|
# Current chat state
|
|
@@ -920,26 +919,23 @@ class Job:
|
|
|
920
919
|
Returns:
|
|
921
920
|
JobStatus: The current status of the job
|
|
922
921
|
"""
|
|
923
|
-
return self.
|
|
922
|
+
return self.job_status
|
|
924
923
|
|
|
925
924
|
def set_status(self, new_status: JobStatus):
|
|
926
925
|
"""
|
|
927
|
-
Sets or updates job status.
|
|
928
|
-
|
|
926
|
+
Sets or updates job status. The job_status tag field keeps lookup tags
|
|
927
|
+
synchronized with the persisted status field.
|
|
929
928
|
|
|
930
929
|
Args:
|
|
931
930
|
new_status: The status/tag to be assigned or updated
|
|
932
931
|
"""
|
|
933
|
-
|
|
934
|
-
db0.tags(self).remove(self.__job_status)
|
|
935
|
-
db0.tags(self).add(new_status)
|
|
936
|
-
self.__job_status = new_status
|
|
932
|
+
self.job_status = new_status
|
|
937
933
|
|
|
938
934
|
def _language_hint_suffix(self) -> str:
|
|
939
|
-
"""Return the
|
|
935
|
+
"""Return the configured locale hint suffix for user messages, if enabled.
|
|
940
936
|
|
|
941
|
-
|
|
942
|
-
|
|
937
|
+
The result is empty when no JobDef locale exists or AUTO_LANG_HINT is
|
|
938
|
+
disabled.
|
|
943
939
|
"""
|
|
944
940
|
locale = self.job_def.locale
|
|
945
941
|
if locale is None:
|
|
@@ -112,6 +112,20 @@ def resolve_reasoning_payload(
|
|
|
112
112
|
default_provider: Optional[str],
|
|
113
113
|
) -> Tuple[str, Optional[Dict]]:
|
|
114
114
|
"""Resolve model parameters into an upstream model ID and provider payload."""
|
|
115
|
+
upstream_model, payload, _ = _resolve_reasoning_request(
|
|
116
|
+
model,
|
|
117
|
+
provider_config,
|
|
118
|
+
default_provider,
|
|
119
|
+
)
|
|
120
|
+
return upstream_model, payload
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def _resolve_reasoning_request(
|
|
124
|
+
model: str,
|
|
125
|
+
provider_config: Optional[ProviderConfig],
|
|
126
|
+
default_provider: Optional[str],
|
|
127
|
+
) -> Tuple[str, Optional[Dict], List[str]]:
|
|
128
|
+
"""Resolve model parameters into request model, reasoning payload, and conflicts."""
|
|
115
129
|
model_name = ensure_model_name(model)
|
|
116
130
|
provider = select_model_provider(model_name, default_provider=default_provider)
|
|
117
131
|
aliases = [
|
|
@@ -120,6 +134,7 @@ def resolve_reasoning_payload(
|
|
|
120
134
|
if key in model_name.params
|
|
121
135
|
]
|
|
122
136
|
payload = None
|
|
137
|
+
ignored_parameters: List[str] = []
|
|
123
138
|
if aliases:
|
|
124
139
|
if len(aliases) == 2 and aliases[0] != aliases[1]:
|
|
125
140
|
raise ValueError("rl and reasoning_level specify conflicting values")
|
|
@@ -137,6 +152,11 @@ def resolve_reasoning_payload(
|
|
|
137
152
|
if payload is None:
|
|
138
153
|
raise ValueError(
|
|
139
154
|
"positive reasoning level has no matching provider configuration payload")
|
|
155
|
+
ignored_parameters = provider_config.find_ignored_parameters(
|
|
156
|
+
provider,
|
|
157
|
+
model_name.model_family,
|
|
158
|
+
model_name.model,
|
|
159
|
+
) or []
|
|
140
160
|
upstream_model = (
|
|
141
161
|
format_model_for_provider(model_name, provider)
|
|
142
162
|
if provider is not None else (
|
|
@@ -144,7 +164,27 @@ def resolve_reasoning_payload(
|
|
|
144
164
|
if model_name.model_family else model_name.model
|
|
145
165
|
)
|
|
146
166
|
)
|
|
147
|
-
return upstream_model, payload
|
|
167
|
+
return upstream_model, payload, ignored_parameters
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def _ignore_request_parameters(
|
|
171
|
+
payload: Dict,
|
|
172
|
+
ignored_parameters: Sequence[str],
|
|
173
|
+
nested_container: Optional[str] = None,
|
|
174
|
+
) -> Dict:
|
|
175
|
+
"""Remove reasoning-conflicting parameters from final provider request JSON."""
|
|
176
|
+
for parameter in ignored_parameters:
|
|
177
|
+
payload.pop(parameter, None)
|
|
178
|
+
if nested_container is None:
|
|
179
|
+
return payload
|
|
180
|
+
nested_payload = payload.get(nested_container)
|
|
181
|
+
if not isinstance(nested_payload, dict):
|
|
182
|
+
return payload
|
|
183
|
+
for parameter in ignored_parameters:
|
|
184
|
+
nested_payload.pop(parameter, None)
|
|
185
|
+
if not nested_payload:
|
|
186
|
+
payload.pop(nested_container)
|
|
187
|
+
return payload
|
|
148
188
|
|
|
149
189
|
LLM_Stats = namedtuple(
|
|
150
190
|
"LLM_Stats",
|
|
@@ -759,7 +799,7 @@ class DefaultLLM_API_Impl(LLM_API):
|
|
|
759
799
|
from .utils import format_tool_spec # pylint: disable=import-outside-toplevel
|
|
760
800
|
|
|
761
801
|
provider = select_model_provider(model, default_provider=(metadata or {}).get("PROVIDER"))
|
|
762
|
-
model, reasoning_payload =
|
|
802
|
+
model, reasoning_payload, ignored_parameters = _resolve_reasoning_request(
|
|
763
803
|
self.require_model(model),
|
|
764
804
|
provider_config,
|
|
765
805
|
provider,
|
|
@@ -782,7 +822,7 @@ class DefaultLLM_API_Impl(LLM_API):
|
|
|
782
822
|
payload.update(self.kwargs)
|
|
783
823
|
if reasoning_payload is not None:
|
|
784
824
|
payload = _deep_merge(payload, reasoning_payload)
|
|
785
|
-
return payload
|
|
825
|
+
return _ignore_request_parameters(payload, ignored_parameters)
|
|
786
826
|
|
|
787
827
|
async def _process_request( # pylint: disable=too-many-locals,too-many-arguments,too-many-positional-arguments
|
|
788
828
|
self,
|
|
@@ -1263,7 +1303,7 @@ class VertexAI_API(LLM_API):
|
|
|
1263
1303
|
from .utils import format_tool_spec # pylint: disable=import-outside-toplevel
|
|
1264
1304
|
|
|
1265
1305
|
provider = select_model_provider(model, default_provider=(metadata or {}).get("PROVIDER"))
|
|
1266
|
-
model, reasoning_payload =
|
|
1306
|
+
model, reasoning_payload, ignored_parameters = _resolve_reasoning_request(
|
|
1267
1307
|
self.require_model(model),
|
|
1268
1308
|
provider_config,
|
|
1269
1309
|
provider,
|
|
@@ -1296,7 +1336,11 @@ class VertexAI_API(LLM_API):
|
|
|
1296
1336
|
self.require_model(model)
|
|
1297
1337
|
if reasoning_payload is not None:
|
|
1298
1338
|
payload = _deep_merge(payload, reasoning_payload)
|
|
1299
|
-
return
|
|
1339
|
+
return _ignore_request_parameters(
|
|
1340
|
+
payload,
|
|
1341
|
+
ignored_parameters,
|
|
1342
|
+
nested_container="generationConfig",
|
|
1343
|
+
)
|
|
1300
1344
|
|
|
1301
1345
|
@staticmethod
|
|
1302
1346
|
def _parse_response( # pylint: disable=too-many-locals
|
|
@@ -1630,7 +1674,7 @@ class ClaudeAI_API(LLM_API):
|
|
|
1630
1674
|
from .utils import format_tool_spec # pylint: disable=import-outside-toplevel
|
|
1631
1675
|
|
|
1632
1676
|
provider = select_model_provider(model, default_provider=(metadata or {}).get("PROVIDER"))
|
|
1633
|
-
model, reasoning_payload =
|
|
1677
|
+
model, reasoning_payload, ignored_parameters = _resolve_reasoning_request(
|
|
1634
1678
|
self.require_model(model),
|
|
1635
1679
|
provider_config,
|
|
1636
1680
|
provider,
|
|
@@ -1650,7 +1694,7 @@ class ClaudeAI_API(LLM_API):
|
|
|
1650
1694
|
payload["temperature"] = temperature
|
|
1651
1695
|
if reasoning_payload is not None:
|
|
1652
1696
|
payload = _deep_merge(payload, reasoning_payload)
|
|
1653
|
-
return payload
|
|
1697
|
+
return _ignore_request_parameters(payload, ignored_parameters)
|
|
1654
1698
|
|
|
1655
1699
|
async def _process_request( # pylint: disable=too-many-locals,too-many-arguments,too-many-positional-arguments
|
|
1656
1700
|
self,
|
|
@@ -132,6 +132,14 @@ class StatekCountryCode:
|
|
|
132
132
|
# Language rules keyed by language code value.
|
|
133
133
|
# Each rule instructs the LLM to respond exclusively in the target language.
|
|
134
134
|
LANGUAGE_RULES = {
|
|
135
|
+
"EN": (
|
|
136
|
+
"CRITICAL LANGUAGE RULE: "
|
|
137
|
+
"1. Respond to the user exclusively in English. "
|
|
138
|
+
"2. Translate example text, tool names, parameter names, and tool output "
|
|
139
|
+
"into English before displaying them to the user. "
|
|
140
|
+
"3. Do not let examples or tool output written in another language change "
|
|
141
|
+
"the language of your user-facing response."
|
|
142
|
+
),
|
|
135
143
|
"PL": (
|
|
136
144
|
"KRYTYCZNA ZASADA JĘZYKOWA: "
|
|
137
145
|
"1. Nigdy nie używaj angielskich nazw narzędzi ani parametrów "
|
|
@@ -185,7 +193,8 @@ LANGUAGE_RULES = {
|
|
|
185
193
|
def get_language_rule(lang_code: "StatekLangCode"):
|
|
186
194
|
"""Return the language rule for the given language code, or None.
|
|
187
195
|
|
|
188
|
-
|
|
196
|
+
Explicit locales, including English, return their configured response rule.
|
|
197
|
+
Languages without an explicit rule return ``None``.
|
|
189
198
|
"""
|
|
190
199
|
return LANGUAGE_RULES.get(str(lang_code))
|
|
191
200
|
|
|
@@ -193,6 +202,7 @@ def get_language_rule(lang_code: "StatekLangCode"):
|
|
|
193
202
|
# Language hints keyed by language code value.
|
|
194
203
|
# Each hint is a short reminder appended in round brackets to user messages.
|
|
195
204
|
LANGUAGE_HINTS = {
|
|
205
|
+
"EN": "REMEMBER: Respond exclusively in English",
|
|
196
206
|
"PL": "PAMIĘTAJ: Odpowiedz wyłącznie po polsku",
|
|
197
207
|
"DE": "ERINNERUNG: Antworte ausschließlich auf Deutsch",
|
|
198
208
|
"FR": "RAPPEL : Réponds uniquement en français",
|
|
@@ -204,7 +214,8 @@ LANGUAGE_HINTS = {
|
|
|
204
214
|
def get_language_hint(lang_code: "StatekLangCode"):
|
|
205
215
|
"""Return the language hint for the given language code, or None.
|
|
206
216
|
|
|
207
|
-
|
|
217
|
+
Explicit locales, including English, return their configured user-message
|
|
218
|
+
hint. Languages without an explicit hint return ``None``.
|
|
208
219
|
"""
|
|
209
220
|
return LANGUAGE_HINTS.get(str(lang_code))
|
|
210
221
|
|
|
@@ -214,8 +225,8 @@ def get_language_hint(lang_code: "StatekLangCode"):
|
|
|
214
225
|
class StatekLocale:
|
|
215
226
|
"""Locale settings that control language-specific LLM behaviour.
|
|
216
227
|
|
|
217
|
-
Combines a language code and country code (e.g. ``EN`` + ``US``)
|
|
218
|
-
|
|
228
|
+
Combines a language code and country code (e.g. ``EN`` + ``US``) to
|
|
229
|
+
explicitly enforce the language of user-facing LLM responses through:
|
|
219
230
|
- the language rule appended to system prompts
|
|
220
231
|
- the language hint appended to user messages
|
|
221
232
|
"""
|
|
@@ -29,7 +29,7 @@ _PROVIDER_CONFIG_HASH_TAG_PREFIX = "STATEK_PROVIDER_CONFIG:H:"
|
|
|
29
29
|
@db0.memo
|
|
30
30
|
@dataclass
|
|
31
31
|
class ProviderConfig:
|
|
32
|
-
"""Durable snapshot of provider-specific
|
|
32
|
+
"""Durable snapshot of provider-specific reasoning payload and conflict mappings."""
|
|
33
33
|
|
|
34
34
|
provider_config: Dict[str, Any]
|
|
35
35
|
|
|
@@ -53,11 +53,26 @@ class ProviderConfig:
|
|
|
53
53
|
node = _find_path_node(self.provider_config, path)
|
|
54
54
|
if node is None:
|
|
55
55
|
continue
|
|
56
|
-
|
|
56
|
+
reasoning = _reasoning_config(node)
|
|
57
|
+
if reasoning is None:
|
|
58
|
+
continue
|
|
59
|
+
payload = _matching_payload(reasoning, reasoning_level)
|
|
57
60
|
if payload is not None:
|
|
58
61
|
return payload
|
|
59
62
|
return None
|
|
60
63
|
|
|
64
|
+
def find_ignored_parameters(self, *args: Optional[str]) -> Optional[List[str]]:
|
|
65
|
+
"""Return the deepest explicit reasoning parameter ignore list for a model path."""
|
|
66
|
+
for path in _candidate_paths(args):
|
|
67
|
+
node = _find_path_node(self.provider_config, path)
|
|
68
|
+
if node is None:
|
|
69
|
+
continue
|
|
70
|
+
reasoning = _reasoning_config(node)
|
|
71
|
+
if reasoning is None or "ignore_parameters" not in reasoning:
|
|
72
|
+
continue
|
|
73
|
+
return _ignored_parameters(reasoning["ignore_parameters"])
|
|
74
|
+
return None
|
|
75
|
+
|
|
61
76
|
|
|
62
77
|
def resolve_provider_config(provider_config: Mapping[str, Any]) -> ProviderConfig:
|
|
63
78
|
"""Reuse or persist a durable provider-configuration snapshot by exact content."""
|
|
@@ -141,6 +156,29 @@ def _matching_payload(config: Mapping[str, Any], reasoning_level: int) -> Option
|
|
|
141
156
|
return None
|
|
142
157
|
|
|
143
158
|
|
|
159
|
+
def _reasoning_config(config: Mapping[str, Any]) -> Optional[Mapping[str, Any]]:
|
|
160
|
+
"""Return the canonical nested reasoning configuration at one hierarchy node."""
|
|
161
|
+
if "reasoning" not in config:
|
|
162
|
+
return None
|
|
163
|
+
reasoning = config["reasoning"]
|
|
164
|
+
if not _is_mapping(reasoning):
|
|
165
|
+
raise ValueError("Provider configuration reasoning must be a mapping")
|
|
166
|
+
return reasoning
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def _ignored_parameters(parameters: Any) -> List[str]:
|
|
170
|
+
"""Validate and copy a reasoning parameter ignore list."""
|
|
171
|
+
error_message = (
|
|
172
|
+
"Provider configuration reasoning ignore_parameters must be a sequence of strings"
|
|
173
|
+
)
|
|
174
|
+
if not _is_sequence(parameters):
|
|
175
|
+
raise ValueError(error_message)
|
|
176
|
+
copied_parameters = list(parameters)
|
|
177
|
+
if any(not isinstance(parameter, str) for parameter in copied_parameters):
|
|
178
|
+
raise ValueError(error_message)
|
|
179
|
+
return copied_parameters
|
|
180
|
+
|
|
181
|
+
|
|
144
182
|
def _is_mapping(value: Any) -> bool:
|
|
145
183
|
"""Return whether a regular or dbzero persistent value exposes mapping items."""
|
|
146
184
|
return isinstance(value, Mapping) or callable(getattr(value, "items", None))
|
|
@@ -642,6 +642,13 @@ def create_tool(tool_name: str, callable: Callable, docstring: str,
|
|
|
642
642
|
return new_tool
|
|
643
643
|
|
|
644
644
|
|
|
645
|
+
def _normalize_method_name(method_name: Optional[str]) -> Optional[str]:
|
|
646
|
+
"""Return a stripped method name or ``None`` when no method was requested."""
|
|
647
|
+
if method_name is None:
|
|
648
|
+
return None
|
|
649
|
+
return method_name.strip() or None
|
|
650
|
+
|
|
651
|
+
|
|
645
652
|
@tool(system=True)
|
|
646
653
|
def docstr(what: type | Callable | Any, method_name: str = None, **kwargs): # pylint: disable=unused-argument
|
|
647
654
|
"""Prints the docstring associated with a tool, class, object instance or method.
|
|
@@ -663,6 +670,8 @@ def docstr(what: type | Callable | Any, method_name: str = None, **kwargs): # p
|
|
|
663
670
|
print(f"NameError: name '{what}' is not defined")
|
|
664
671
|
return
|
|
665
672
|
|
|
673
|
+
method_name = _normalize_method_name(method_name)
|
|
674
|
+
|
|
666
675
|
try:
|
|
667
676
|
# Handle object instances - get their class
|
|
668
677
|
target_type = what
|
|
@@ -714,6 +723,8 @@ def brief(what: type | Callable | Any, method_name: str = None, **kwargs): # py
|
|
|
714
723
|
print(f"NameError: name '{what}' is not defined")
|
|
715
724
|
return
|
|
716
725
|
|
|
726
|
+
method_name = _normalize_method_name(method_name)
|
|
727
|
+
|
|
717
728
|
try:
|
|
718
729
|
# Handle object instances - get their class
|
|
719
730
|
target_type = what
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: statek
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: Durable Python workspaces for stateful LLM agents
|
|
5
5
|
Author: Statek authors
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -26,12 +26,12 @@ Requires-Dist: nest_asyncio==1.6.0
|
|
|
26
26
|
Requires-Dist: RestrictedPython>=8.3
|
|
27
27
|
Provides-Extra: dbzero
|
|
28
28
|
Requires-Dist: dbzero-modelkit[dbzero]>=1.2.0; extra == "dbzero"
|
|
29
|
-
Requires-Dist: dbzero>=0.6.
|
|
29
|
+
Requires-Dist: dbzero>=0.6.1; extra == "dbzero"
|
|
30
30
|
Provides-Extra: dbzero-pro
|
|
31
31
|
Requires-Dist: dbzero-modelkit[dbzero-pro]>=1.2.0; extra == "dbzero-pro"
|
|
32
|
-
Requires-Dist: dbzero-pro>=0.6.
|
|
32
|
+
Requires-Dist: dbzero-pro>=0.6.2; extra == "dbzero-pro"
|
|
33
33
|
Provides-Extra: dev
|
|
34
|
-
Requires-Dist: dbzero>=0.6.
|
|
34
|
+
Requires-Dist: dbzero>=0.6.1; extra == "dev"
|
|
35
35
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
36
36
|
Requires-Dist: pytest-asyncio==1.3.0; extra == "dev"
|
|
37
37
|
Requires-Dist: pylint>=3.0; extra == "dev"
|
|
@@ -7,14 +7,14 @@ RestrictedPython>=8.3
|
|
|
7
7
|
|
|
8
8
|
[dbzero]
|
|
9
9
|
dbzero-modelkit[dbzero]>=1.2.0
|
|
10
|
-
dbzero>=0.6.
|
|
10
|
+
dbzero>=0.6.1
|
|
11
11
|
|
|
12
12
|
[dbzero-pro]
|
|
13
13
|
dbzero-modelkit[dbzero-pro]>=1.2.0
|
|
14
|
-
dbzero-pro>=0.6.
|
|
14
|
+
dbzero-pro>=0.6.2
|
|
15
15
|
|
|
16
16
|
[dev]
|
|
17
|
-
dbzero>=0.6.
|
|
17
|
+
dbzero>=0.6.1
|
|
18
18
|
pytest>=7.0
|
|
19
19
|
pytest-asyncio==1.3.0
|
|
20
20
|
pylint>=3.0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|