grasp_agents 0.4.0__py3-none-any.whl → 0.4.3__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/llm.py CHANGED
@@ -106,7 +106,9 @@ class LLM(ABC, Generic[SettingsT_co, ConvertT_co]):
106
106
  for message in completion.messages:
107
107
  if not message.tool_calls:
108
108
  validate_obj_from_json_or_py_string(
109
- message.content or "", adapter=self._response_format_adapter
109
+ message.content or "",
110
+ adapter=self._response_format_adapter,
111
+ from_substring=True,
110
112
  )
111
113
 
112
114
  def _validate_tool_calls(self, completion: Completion) -> None:
grasp_agents/llm_agent.py CHANGED
@@ -221,7 +221,7 @@ class LLMAgent(
221
221
  return validate_obj_from_json_or_py_string(
222
222
  str(conversation[-1].content or ""),
223
223
  adapter=self._out_type_adapter,
224
- from_substring=False,
224
+ from_substring=True,
225
225
  )
226
226
 
227
227
  async def _process(
@@ -366,9 +366,13 @@ class LLMPolicyExecutor(AutoInstanceAttributesMixin, Generic[_FinalAnswerT, CtxT
366
366
  # If we are not in ReAct mode, we set tool_choice to "auto" to allow
367
367
  # the LLM to choose freely whether to call tools.
368
368
 
369
- tool_choice = (
370
- "none" if (self._react_mode and gen_message.tool_calls) else "required"
371
- )
369
+ if self._react_mode and gen_message.tool_calls:
370
+ tool_choice = "none"
371
+ elif gen_message.tool_calls:
372
+ tool_choice = "auto"
373
+ else:
374
+ tool_choice = "required"
375
+
372
376
  gen_message = (
373
377
  await self.generate_messages(
374
378
  memory, tool_choice=tool_choice, run_id=run_id, ctx=ctx
@@ -430,9 +434,12 @@ class LLMPolicyExecutor(AutoInstanceAttributesMixin, Generic[_FinalAnswerT, CtxT
430
434
 
431
435
  self._manage_memory(memory, ctx=ctx, num_turns=turns)
432
436
 
433
- tool_choice = (
434
- "none" if (self._react_mode and gen_message.tool_calls) else "required"
435
- )
437
+ if self._react_mode and gen_message.tool_calls:
438
+ tool_choice = "none"
439
+ elif gen_message.tool_calls:
440
+ tool_choice = "auto"
441
+ else:
442
+ tool_choice = "required"
436
443
  async for event in self.generate_messages_stream(
437
444
  memory, tool_choice=tool_choice, run_id=run_id, ctx=ctx
438
445
  ):
@@ -66,6 +66,7 @@ class Content(BaseModel):
66
66
  def from_formatted_prompt(
67
67
  cls,
68
68
  prompt_template: str,
69
+ /,
69
70
  **prompt_args: str | int | bool | ImageData | None,
70
71
  ) -> "Content":
71
72
  prompt_args = prompt_args or {}
@@ -45,9 +45,7 @@ class UserMessage(MessageBase):
45
45
  name: str | None = None,
46
46
  prompt_args: Mapping[str, str | int | bool | ImageData] | None = None,
47
47
  ) -> "UserMessage":
48
- content = Content.from_formatted_prompt(
49
- prompt_template=prompt_template, **(prompt_args or {})
50
- )
48
+ content = Content.from_formatted_prompt(prompt_template, **(prompt_args or {}))
51
49
 
52
50
  return cls(content=content, name=name)
53
51
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: grasp_agents
3
- Version: 0.4.0
3
+ Version: 0.4.3
4
4
  Summary: Grasp Agents Library
5
5
  License-File: LICENSE.md
6
6
  Requires-Python: <4,>=3.11.4
@@ -45,7 +45,7 @@ Description-Content-Type: text/markdown
45
45
  - Workflows (static communication topology), including loops
46
46
  - Agents-as-tools for task delegation
47
47
  - Freeform A2A communication via the in-process actor model
48
- - Batch processing support outside of agentic loops
48
+ - Parallel processing with flexible retries and rate limiting
49
49
  - Simple logging and usage/cost tracking
50
50
 
51
51
  ## Project Structure
@@ -6,10 +6,10 @@ grasp_agents/errors.py,sha256=u-P8NZ3S7THQP5Bjv9SFC_JbHd3CKhX3dTWUObEBzmo,461
6
6
  grasp_agents/generics_utils.py,sha256=5Pw3I9dlnKC2VGqYKC4ZZUO3Z_vTNT-NPFovNfPkl6I,6542
7
7
  grasp_agents/grasp_logging.py,sha256=H1GYhXdQvVkmauFDZ-KDwvVmPQHZUUm9sRqX_ObK2xI,1111
8
8
  grasp_agents/http_client.py,sha256=Es8NXGDkp4Nem7g24-jW0KFGA9Hp_o2Cv3cOvjup-iU,859
9
- grasp_agents/llm.py,sha256=S5muzwTbbT048YyASG_BrMcGYX7IGB0q3KZwL3H26wo,5193
10
- grasp_agents/llm_agent.py,sha256=tK6cOIPTQzH8GO_xDSLMwRiZX_YrGYNbHzZnURRs8NQ,13835
9
+ grasp_agents/llm.py,sha256=4eNB89WNJwby7Umt1Khfr8eVm_yFzXqGdN7i_xHtP_c,5255
10
+ grasp_agents/llm_agent.py,sha256=w5KM9EPhs4nsEET8AdSI69API-R3pWgb80uSp7zGr1o,13834
11
11
  grasp_agents/llm_agent_memory.py,sha256=KPVnwF68acVNdSObSaRcO905YYx8vLHJ-kAEfZYs0sA,1860
12
- grasp_agents/llm_policy_executor.py,sha256=Fzu5tXXbB-60vEzvlFOwC3IcEKq-2_rPh54E06neYro,17488
12
+ grasp_agents/llm_policy_executor.py,sha256=WtmDo_WwptfZeu_fOz6jPVgmg3v_hmwo9fxD4BWejvY,17697
13
13
  grasp_agents/memory.py,sha256=QSWjpGTn_t3XFKDxycWUCNFFueQcajzduQGU1vkJFWQ,720
14
14
  grasp_agents/packet.py,sha256=PZ1EpclniAoLk7z4ieZbWzgYH3JSRgnlTe_WfbJYG_4,707
15
15
  grasp_agents/packet_pool.py,sha256=F29EWkKM-305Qqf3hK9jriYXj4vgAx9iAWTg-hfZONs,3035
@@ -34,17 +34,17 @@ grasp_agents/rate_limiting/utils.py,sha256=oEDWDNHYMUdxOOG49PlAJochkZq8nnVBCo6Jx
34
34
  grasp_agents/typing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
35
  grasp_agents/typing/completion.py,sha256=KrvdFZqOcw5GePdMhDoFuwCkMJ86nqRdz9mT9s2lFv4,2445
36
36
  grasp_agents/typing/completion_chunk.py,sha256=eo9h2f3BphBz-sgnCetB9o6Ol6MOl6VH89fMM-NtxtE,6050
37
- grasp_agents/typing/content.py,sha256=rP6_PnkBqDrto6kDEubzNwCvUkXosSqnxQwfw2r35yA,3648
37
+ grasp_agents/typing/content.py,sha256=XFmLpNWkGhkw5JujO6UsYwhzTHkU67PfhzaXH2waLcQ,3659
38
38
  grasp_agents/typing/converters.py,sha256=kHlocHQS8QnduZOzNPbj3aRD8JpvJd53oudYqWdOxKE,2978
39
39
  grasp_agents/typing/events.py,sha256=QbrvXnDmXFr9_cSsdqL9f35eQLOfZ2O0h3a6yCRtKwY,2625
40
40
  grasp_agents/typing/io.py,sha256=RtBnxOiEJkfCPz7bEu1T1JXU7o71MhHK3RkeedzWwX0,237
41
- grasp_agents/typing/message.py,sha256=IhWBJeXhzMEm3SNYPtcYUebFaKlTCwv-ePPtHlIAyUA,2388
41
+ grasp_agents/typing/message.py,sha256=vB94CLGfNJOZ3pTKneVP_mbZpWrhC_981K5OhHUiLW4,2350
42
42
  grasp_agents/typing/tool.py,sha256=mHodyJYbiGQAG7exyDh04n5eqpDEUnV3pFAbC23LHQM,1754
43
43
  grasp_agents/workflow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
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.0.dist-info/METADATA,sha256=wXLHFglzchCwgLmvqiRKofLkydOoT65B2bP1kOR8xHE,6858
48
- grasp_agents-0.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
49
- grasp_agents-0.4.0.dist-info/licenses/LICENSE.md,sha256=-nNNdWqGB8gJ2O-peFQ2Irshv5tW5pHKyTcYkwvH7CE,1201
50
- grasp_agents-0.4.0.dist-info/RECORD,,
47
+ grasp_agents-0.4.3.dist-info/METADATA,sha256=cKnmhyENkWagGfbGGAkSDeAh6rNWKMEGirBcmUnBprg,6868
48
+ grasp_agents-0.4.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
49
+ grasp_agents-0.4.3.dist-info/licenses/LICENSE.md,sha256=-nNNdWqGB8gJ2O-peFQ2Irshv5tW5pHKyTcYkwvH7CE,1201
50
+ grasp_agents-0.4.3.dist-info/RECORD,,