grasp_agents 0.4.4__py3-none-any.whl → 0.4.6__py3-none-any.whl
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.
- grasp_agents/utils.py +18 -6
- {grasp_agents-0.4.4.dist-info → grasp_agents-0.4.6.dist-info}/METADATA +1 -1
- {grasp_agents-0.4.4.dist-info → grasp_agents-0.4.6.dist-info}/RECORD +5 -5
- {grasp_agents-0.4.4.dist-info → grasp_agents-0.4.6.dist-info}/WHEEL +0 -0
- {grasp_agents-0.4.4.dist-info → grasp_agents-0.4.6.dist-info}/licenses/LICENSE.md +0 -0
grasp_agents/utils.py
CHANGED
@@ -90,10 +90,18 @@ def validate_obj_from_json_or_py_string(
|
|
90
90
|
strip_language_markdown: bool = True,
|
91
91
|
) -> T | str:
|
92
92
|
_selected_adapter: TypeAdapter[T] | None = None
|
93
|
+
_selected_tag: str | None = None
|
94
|
+
s_orig = s
|
95
|
+
|
93
96
|
if isinstance(adapter, Mapping):
|
94
|
-
for
|
95
|
-
|
96
|
-
|
97
|
+
for _tag, _adapter in adapter.items():
|
98
|
+
match = re.search(rf"<{_tag}>\s*(.*?)\s*</{_tag}>", s, re.DOTALL)
|
99
|
+
if not match:
|
100
|
+
continue
|
101
|
+
s = match.group(1).strip()
|
102
|
+
_selected_adapter = _adapter
|
103
|
+
_selected_tag = _tag
|
104
|
+
break
|
97
105
|
if _selected_adapter is None:
|
98
106
|
return s
|
99
107
|
else:
|
@@ -126,9 +134,12 @@ def validate_obj_from_json_or_py_string(
|
|
126
134
|
parsed = s
|
127
135
|
return _selected_adapter.validate_python(parsed)
|
128
136
|
except ValidationError as exc:
|
129
|
-
|
130
|
-
|
131
|
-
|
137
|
+
err_message = f"Invalid JSON or Python string:\n{s_orig}"
|
138
|
+
if _selected_tag:
|
139
|
+
err_message += f"\nExpected type {_type} within tag <{_selected_tag}>"
|
140
|
+
else:
|
141
|
+
err_message += f"\nExpected type {_type}"
|
142
|
+
raise OutputValidationError(err_message) from exc
|
132
143
|
|
133
144
|
|
134
145
|
def extract_xml_list(text: str) -> list[str]:
|
@@ -170,6 +181,7 @@ async def asyncio_gather_with_pbar(
|
|
170
181
|
no_tqdm: bool = False,
|
171
182
|
desc: str | None = None,
|
172
183
|
) -> list[Any]:
|
184
|
+
# TODO: optimize
|
173
185
|
pbar = tqdm(total=len(corouts), desc=desc, disable=no_tqdm)
|
174
186
|
|
175
187
|
async def run_and_update(coro: Coroutine[Any, Any, Any]) -> Any:
|
@@ -18,7 +18,7 @@ grasp_agents/processor.py,sha256=WZ7ps3b3knBaGrMAjEaIBUlOV1L_Dh4H6BUOf4CGWF8,112
|
|
18
18
|
grasp_agents/prompt_builder.py,sha256=wDcB1UaOH8vdxw1tmWZwVZS_bCdWU0VKQvHLpI8SnCk,7970
|
19
19
|
grasp_agents/run_context.py,sha256=pUi2a9WeHUg67cUTQ5T13mmJ3vzQfv-855fWLPeYRmo,1438
|
20
20
|
grasp_agents/usage_tracker.py,sha256=3gmgPcB7qHAl5W5Ffnmu_8GOcKBSv3xM1NLy-HMuSlo,3691
|
21
|
-
grasp_agents/utils.py,sha256=
|
21
|
+
grasp_agents/utils.py,sha256=fSi4nOwRezg4umzHVO23-mhuyjMAvJQLAfsmGjxxrKc,5928
|
22
22
|
grasp_agents/openai/__init__.py,sha256=wpTeew6EjhM6esHCKrEKUpwq0kygMN2QQDxYtmbRG8Y,4201
|
23
23
|
grasp_agents/openai/completion_chunk_converters.py,sha256=TFOA7MJniiSV6_lPZsPSg06GlfdWguTrYS2Hd45BjcU,2674
|
24
24
|
grasp_agents/openai/completion_converters.py,sha256=vzPEkUOX4l2hobKxZjEk_dyWfzeYesO0DlvWvNVb-Sg,2656
|
@@ -44,7 +44,7 @@ grasp_agents/workflow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
|
|
44
44
|
grasp_agents/workflow/looped_workflow.py,sha256=eQkjCo6j3W5Xc7mw3AGmXpUhTkK2BmhrvCuht2UkZuI,4537
|
45
45
|
grasp_agents/workflow/sequential_workflow.py,sha256=UCHZXvTy47S0UG0WwuKp2G7Az6dAcE5tIFPaOXhxcWM,2347
|
46
46
|
grasp_agents/workflow/workflow_processor.py,sha256=lGW-Cy1QraU1AaCPVRs9-EtU5Z_3O3EAnuyIPzD6KQ8,3134
|
47
|
-
grasp_agents-0.4.
|
48
|
-
grasp_agents-0.4.
|
49
|
-
grasp_agents-0.4.
|
50
|
-
grasp_agents-0.4.
|
47
|
+
grasp_agents-0.4.6.dist-info/METADATA,sha256=EDbimHKbXtf77__Yx5MXeebiKOA_0Y6cTT-8RNrytK0,6868
|
48
|
+
grasp_agents-0.4.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
49
|
+
grasp_agents-0.4.6.dist-info/licenses/LICENSE.md,sha256=-nNNdWqGB8gJ2O-peFQ2Irshv5tW5pHKyTcYkwvH7CE,1201
|
50
|
+
grasp_agents-0.4.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|