grasp_agents 0.4.4__tar.gz → 0.4.7__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.
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/PKG-INFO +1 -1
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/pyproject.toml +1 -1
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/cloud_llm.py +29 -23
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/utils.py +18 -6
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/.gitignore +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/LICENSE.md +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/README.md +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/__init__.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/comm_processor.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/costs_dict.yaml +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/errors.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/generics_utils.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/grasp_logging.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/http_client.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/llm.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/llm_agent.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/llm_agent_memory.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/llm_policy_executor.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/memory.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/openai/__init__.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/openai/completion_chunk_converters.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/openai/completion_converters.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/openai/content_converters.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/openai/converters.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/openai/message_converters.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/openai/openai_llm.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/openai/tool_converters.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/packet.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/packet_pool.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/printer.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/processor.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/prompt_builder.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/rate_limiting/__init__.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/rate_limiting/rate_limiter_chunked.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/rate_limiting/types.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/rate_limiting/utils.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/run_context.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/typing/__init__.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/typing/completion.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/typing/completion_chunk.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/typing/content.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/typing/converters.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/typing/events.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/typing/io.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/typing/message.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/typing/tool.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/usage_tracker.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/workflow/__init__.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/workflow/looped_workflow.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/workflow/sequential_workflow.py +0 -0
- {grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/workflow/workflow_processor.py +0 -0
@@ -42,26 +42,28 @@ class APIProvider(TypedDict):
|
|
42
42
|
struct_outputs_support: NotRequired[tuple[str, ...]]
|
43
43
|
|
44
44
|
|
45
|
-
|
46
|
-
"
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
45
|
+
def get_api_providers() -> dict[APIProviderName, APIProvider]:
|
46
|
+
"""Returns a dictionary of available API providers."""
|
47
|
+
return {
|
48
|
+
"openai": APIProvider(
|
49
|
+
name="openai",
|
50
|
+
base_url="https://api.openai.com/v1",
|
51
|
+
api_key=os.getenv("OPENAI_API_KEY"),
|
52
|
+
struct_outputs_support=("*",),
|
53
|
+
),
|
54
|
+
"openrouter": APIProvider(
|
55
|
+
name="openrouter",
|
56
|
+
base_url="https://openrouter.ai/api/v1",
|
57
|
+
api_key=os.getenv("OPENROUTER_API_KEY"),
|
58
|
+
struct_outputs_support=(),
|
59
|
+
),
|
60
|
+
"google_ai_studio": APIProvider(
|
61
|
+
name="google_ai_studio",
|
62
|
+
base_url="https://generativelanguage.googleapis.com/v1beta/openai/",
|
63
|
+
api_key=os.getenv("GOOGLE_AI_STUDIO_API_KEY"),
|
64
|
+
struct_outputs_support=("*",),
|
65
|
+
),
|
66
|
+
}
|
65
67
|
|
66
68
|
|
67
69
|
def retry_error_callback(retry_state: RetryCallState) -> Completion:
|
@@ -142,12 +144,16 @@ class CloudLLM(LLM[SettingsT_co, ConvertT_co], Generic[SettingsT_co, ConvertT_co
|
|
142
144
|
if len(model_name_parts) == 2:
|
143
145
|
api_provider_name, api_model_name = model_name_parts
|
144
146
|
self._api_model_name: str = api_model_name
|
145
|
-
|
147
|
+
|
148
|
+
api_providers = get_api_providers()
|
149
|
+
|
150
|
+
if api_provider_name not in api_providers:
|
146
151
|
raise ValueError(
|
147
152
|
f"API provider '{api_provider_name}' is not supported. "
|
148
|
-
f"Supported providers are: {', '.join(
|
153
|
+
f"Supported providers are: {', '.join(api_providers.keys())}"
|
149
154
|
)
|
150
|
-
|
155
|
+
|
156
|
+
_api_provider = api_providers[api_provider_name]
|
151
157
|
elif api_provider is not None:
|
152
158
|
self._api_model_name: str = model_name
|
153
159
|
_api_provider = api_provider
|
@@ -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:
|
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
|
{grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/openai/completion_chunk_converters.py
RENAMED
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
|
{grasp_agents-0.4.4 → grasp_agents-0.4.7}/src/grasp_agents/rate_limiting/rate_limiter_chunked.py
RENAMED
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
|