pyagentic-core 2.3.0a2__tar.gz → 2.3.0a4__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.
Files changed (46) hide show
  1. {pyagentic_core-2.3.0a2/pyagentic_core.egg-info → pyagentic_core-2.3.0a4}/PKG-INFO +1 -1
  2. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/_base/_agent/_agent.py +8 -3
  3. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/_utils/_image.py +1 -1
  4. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/llm/_openai.py +6 -3
  5. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/models/llm.py +3 -4
  6. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/models/response.py +3 -1
  7. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4/pyagentic_core.egg-info}/PKG-INFO +1 -1
  8. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyproject.toml +1 -1
  9. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/LICENSE +0 -0
  10. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/README.md +0 -0
  11. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/__init__.py +0 -0
  12. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/_base/__init__.py +0 -0
  13. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/_base/_agent/__init__.py +0 -0
  14. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/_base/_agent/_agent_linking.py +0 -0
  15. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/_base/_agent/_agent_state.py +0 -0
  16. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/_base/_exceptions.py +0 -0
  17. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/_base/_info.py +0 -0
  18. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/_base/_metaclasses.py +0 -0
  19. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/_base/_ref.py +0 -0
  20. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/_base/_spec.py +0 -0
  21. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/_base/_state.py +0 -0
  22. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/_base/_tool.py +0 -0
  23. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/_base/_validation.py +0 -0
  24. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/_utils/_typing.py +0 -0
  25. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/_utils/_warnings.py +0 -0
  26. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/llm/__init__.py +0 -0
  27. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/llm/_anthropic.py +0 -0
  28. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/llm/_gemini.py +0 -0
  29. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/llm/_mock.py +0 -0
  30. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/llm/_openaiv1.py +0 -0
  31. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/llm/_provider.py +0 -0
  32. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/logging.py +0 -0
  33. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/models/tracing.py +0 -0
  34. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/policies/__init__.py +0 -0
  35. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/policies/_events.py +0 -0
  36. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/policies/_policy.py +0 -0
  37. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/tracing/__init__.py +0 -0
  38. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/tracing/_basic.py +0 -0
  39. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/tracing/_langfuse.py +0 -0
  40. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/tracing/_tracer.py +0 -0
  41. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic/updates.py +0 -0
  42. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic_core.egg-info/SOURCES.txt +0 -0
  43. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic_core.egg-info/dependency_links.txt +0 -0
  44. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic_core.egg-info/requires.txt +0 -0
  45. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/pyagentic_core.egg-info/top_level.txt +0 -0
  46. {pyagentic_core-2.3.0a2 → pyagentic_core-2.3.0a4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyagentic-core
3
- Version: 2.3.0a2
3
+ Version: 2.3.0a4
4
4
  Summary: Build LLM Agents in a Pythonic way
5
5
  Author-email: Ryan Mikulec <rmikulec.dev@gmail.com>
6
6
  License: MIT
@@ -38,7 +38,7 @@ from pyagentic.llm._provider import LLMProvider
38
38
  from pyagentic.llm import LLMProviders
39
39
  from pyagentic.tracing._tracer import AgentTracer, traced
40
40
  from pyagentic.tracing import BasicTracer
41
-
41
+ from pyagentic._utils._image import _encode_image
42
42
 
43
43
  logger = get_logger(__name__)
44
44
 
@@ -437,8 +437,11 @@ class BaseAgent(metaclass=AgentMeta):
437
437
  stringified_result = f"[Image returned by {tool_call.name}]"
438
438
  # Add tool result message
439
439
  self.state._messages.append(
440
- self.provider.to_tool_call_result_message(result=stringified_result, id_=tool_call.id)
440
+ self.provider.to_tool_call_result_message(
441
+ result=stringified_result, id_=tool_call.id
442
+ )
441
443
  )
444
+ result = _encode_image(result)
442
445
  # Add the image as a user message so the LLM can see it
443
446
  self.state._messages.append(
444
447
  Message(role="user", content=f"Image from {tool_call.name}:", image=result)
@@ -451,7 +454,9 @@ class BaseAgent(metaclass=AgentMeta):
451
454
  )
452
455
  # Add tool result to conversation history for LLM
453
456
  self.state._messages.append(
454
- self.provider.to_tool_call_result_message(result=stringified_result, id_=tool_call.id)
457
+ self.provider.to_tool_call_result_message(
458
+ result=stringified_result, id_=tool_call.id
459
+ )
455
460
  )
456
461
 
457
462
  if self.phases:
@@ -17,4 +17,4 @@ def _encode_image(image: Image) -> str:
17
17
  image.save(buffer, format="PNG")
18
18
  image_bytes = buffer.getvalue()
19
19
  base64_image = base64.b64encode(image_bytes).decode("utf-8")
20
- return f"data:image/png;base64,{base64_image}"
20
+ return base64_image
@@ -106,13 +106,16 @@ class OpenAIProvider(LLMProvider):
106
106
 
107
107
  # If message has an image, convert to OpenAI's content array format
108
108
  if message.image is not None:
109
- image_url = _encode_image(message.image)
110
-
111
109
  # Build content array with text and image
112
110
  content = []
113
111
  if message.content:
114
112
  content.append({"type": "text", "text": message.content})
115
- content.append({"type": "image_url", "image_url": {"url": image_url}})
113
+ content.append(
114
+ {
115
+ "type": "image_url",
116
+ "image_url": {"url": f"data:image/png;base64,{message.image}"},
117
+ }
118
+ )
116
119
 
117
120
  msg_dict["content"] = content
118
121
  # Remove the image field as it's now in content
@@ -1,8 +1,7 @@
1
- from typing import Any, List, Optional, TYPE_CHECKING
1
+ from typing import Any, List, Optional
2
2
  from pydantic import BaseModel, ConfigDict
3
3
 
4
- if TYPE_CHECKING:
5
- from PIL.Image import Image
4
+ from PIL.Image import Image
6
5
 
7
6
 
8
7
  class Message(BaseModel):
@@ -18,7 +17,7 @@ class Message(BaseModel):
18
17
  type: Optional[str] = None
19
18
  role: Optional[str] = None
20
19
  content: Optional[str] = None
21
- image: Optional["Image"] = None
20
+ image: Optional[str] = None
22
21
 
23
22
  def to_dict(self, exclude_none: bool = True):
24
23
  """
@@ -69,8 +69,10 @@ class ToolResponse(BaseModel):
69
69
  case _:
70
70
  raise Exception(f"Unsupported type: {param_type}")
71
71
 
72
+ return_type = str if tool_def.return_type == Image else tool_def.return_type
73
+
72
74
  return create_model(
73
- f"ToolResponse[{tool_def.name}]", __base__=cls, output=tool_def.return_type, **fields
75
+ f"ToolResponse[{tool_def.name}]", __base__=cls, output=return_type, **fields
74
76
  )
75
77
 
76
78
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyagentic-core
3
- Version: 2.3.0a2
3
+ Version: 2.3.0a4
4
4
  Summary: Build LLM Agents in a Pythonic way
5
5
  Author-email: Ryan Mikulec <rmikulec.dev@gmail.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pyagentic-core"
3
- version = "2.3.0-a.2"
3
+ version = "2.3.0-a.4"
4
4
  description = "Build LLM Agents in a Pythonic way"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"