grasp_agents 0.3.6__tar.gz → 0.3.8__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.3.6 → grasp_agents-0.3.8}/PKG-INFO +1 -1
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/pyproject.toml +1 -1
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/llm_agent.py +3 -11
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/prompt_builder.py +15 -12
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/.gitignore +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/LICENSE.md +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/README.md +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/__init__.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/cloud_llm.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/comm_processor.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/costs_dict.yaml +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/generics_utils.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/grasp_logging.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/http_client.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/llm.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/llm_agent_memory.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/llm_policy_executor.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/memory.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/message_history.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/openai/__init__.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/openai/completion_chunk_converters.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/openai/completion_converters.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/openai/content_converters.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/openai/converters.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/openai/message_converters.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/openai/openai_llm.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/openai/tool_converters.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/packet.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/packet_pool.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/printer.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/processor.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/rate_limiting/__init__.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/rate_limiting/rate_limiter_chunked.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/rate_limiting/types.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/rate_limiting/utils.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/run_context.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/typing/__init__.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/typing/completion.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/typing/completion_chunk.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/typing/content.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/typing/converters.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/typing/events.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/typing/io.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/typing/message.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/typing/tool.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/usage_tracker.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/utils.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/workflow/__init__.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/workflow/looped_workflow.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/workflow/parallel_processor.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/workflow/sequential_workflow.py +0 -0
- {grasp_agents-0.3.6 → grasp_agents-0.3.8}/src/grasp_agents/workflow/workflow_processor.py +0 -0
@@ -175,10 +175,12 @@ class LLMAgent(
|
|
175
175
|
|
176
176
|
# 2. Set agent memory
|
177
177
|
|
178
|
+
system_message: SystemMessage | None = None
|
178
179
|
_memory = self.memory.model_copy(deep=True)
|
179
|
-
prev_message_hist_length = len(_memory.message_history)
|
180
180
|
if self._reset_memory_on_run or _memory.is_empty:
|
181
181
|
_memory.reset(formatted_sys_prompt)
|
182
|
+
if formatted_sys_prompt is not None:
|
183
|
+
system_message = _memory.message_history[0][0] # type: ignore[assignment]
|
182
184
|
elif self._set_memory_impl:
|
183
185
|
_memory = self._set_memory_impl(
|
184
186
|
prev_memory=_memory,
|
@@ -195,16 +197,6 @@ class LLMAgent(
|
|
195
197
|
if user_message_batch:
|
196
198
|
_memory.update(message_batch=user_message_batch)
|
197
199
|
|
198
|
-
# 4. Extract system message if it was added
|
199
|
-
|
200
|
-
system_message: SystemMessage | None = None
|
201
|
-
if (
|
202
|
-
len(_memory.message_history) == 1
|
203
|
-
and prev_message_hist_length == 0
|
204
|
-
and isinstance(_memory.message_history[0][0], SystemMessage)
|
205
|
-
):
|
206
|
-
system_message = _memory.message_history[0][0]
|
207
|
-
|
208
200
|
return system_message, user_message_batch, _memory
|
209
201
|
|
210
202
|
def _extract_outputs(
|
@@ -165,7 +165,7 @@ class PromptBuilder(AutoInstanceAttributesMixin, Generic[InT_contra, CtxT]):
|
|
165
165
|
if in_args is not None:
|
166
166
|
val_in_args = self._in_args_type_adapter.validate_python(in_args)
|
167
167
|
if isinstance(val_in_args, BaseModel):
|
168
|
-
|
168
|
+
has_image = self._has_image_data(val_in_args)
|
169
169
|
if has_image and self.in_prompt_template is None:
|
170
170
|
raise TypeError(
|
171
171
|
"BaseModel input arguments contain ImageData, but input prompt "
|
@@ -179,22 +179,27 @@ class PromptBuilder(AutoInstanceAttributesMixin, Generic[InT_contra, CtxT]):
|
|
179
179
|
|
180
180
|
return val_in_args, val_usr_args
|
181
181
|
|
182
|
+
@staticmethod
|
183
|
+
def _has_image_data(inp: BaseModel) -> bool:
|
184
|
+
contains_image_data = False
|
185
|
+
for field in type(inp).model_fields:
|
186
|
+
if isinstance(getattr(inp, field), ImageData):
|
187
|
+
contains_image_data = True
|
188
|
+
|
189
|
+
return contains_image_data
|
190
|
+
|
182
191
|
@staticmethod
|
183
192
|
def _format_pydantic_prompt_args(
|
184
193
|
inp: BaseModel,
|
185
|
-
) ->
|
194
|
+
) -> dict[str, PromptArgumentType]:
|
186
195
|
formatted_args: dict[str, PromptArgumentType] = {}
|
187
|
-
contains_image_data = False
|
188
196
|
for field in type(inp).model_fields:
|
189
197
|
if field == "selected_recipients":
|
190
198
|
continue
|
191
199
|
|
192
200
|
val = getattr(inp, field)
|
193
|
-
if isinstance(val, (int, str, bool)):
|
194
|
-
formatted_args[field] = val
|
195
|
-
elif isinstance(val, ImageData):
|
201
|
+
if isinstance(val, (int, str, bool, ImageData)):
|
196
202
|
formatted_args[field] = val
|
197
|
-
contains_image_data = True
|
198
203
|
elif isinstance(val, BaseModel):
|
199
204
|
formatted_args[field] = val.model_dump_json(indent=2, warnings="error")
|
200
205
|
else:
|
@@ -203,20 +208,18 @@ class PromptBuilder(AutoInstanceAttributesMixin, Generic[InT_contra, CtxT]):
|
|
203
208
|
"int, str, bool, BaseModel, or ImageData."
|
204
209
|
)
|
205
210
|
|
206
|
-
return formatted_args
|
211
|
+
return formatted_args
|
207
212
|
|
208
213
|
def _combine_args(
|
209
214
|
self, *, in_args: InT_contra | None, usr_args: LLMPromptArgs | None
|
210
215
|
) -> Mapping[str, PromptArgumentType] | str:
|
211
|
-
fmt_usr_args
|
212
|
-
self._format_pydantic_prompt_args(usr_args) if usr_args else ({}, False)
|
213
|
-
)
|
216
|
+
fmt_usr_args = self._format_pydantic_prompt_args(usr_args) if usr_args else {}
|
214
217
|
|
215
218
|
if in_args is None:
|
216
219
|
return fmt_usr_args
|
217
220
|
|
218
221
|
if isinstance(in_args, BaseModel):
|
219
|
-
fmt_in_args
|
222
|
+
fmt_in_args = self._format_pydantic_prompt_args(in_args)
|
220
223
|
return fmt_in_args | fmt_usr_args
|
221
224
|
|
222
225
|
combined_args_str = self._in_args_type_adapter.dump_json(
|
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.3.6 → grasp_agents-0.3.8}/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
|
{grasp_agents-0.3.6 → grasp_agents-0.3.8}/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
|
File without changes
|
File without changes
|