goose-py 0.9.13__py3-none-any.whl → 0.9.15__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.
goose/_internal/agent.py CHANGED
@@ -153,11 +153,7 @@ class Agent:
153
153
  response = await acompletion(
154
154
  model=model.value,
155
155
  messages=rendered_messages,
156
- response_format={
157
- "type": "json_object",
158
- "response_schema": response_model.model_json_schema(),
159
- "enforce_validation": True,
160
- },
156
+ response_format=response_model,
161
157
  )
162
158
  parsed_response = response_model.model_validate_json(response.choices[0].message.content)
163
159
 
@@ -1,19 +1,8 @@
1
1
  import base64
2
2
  from enum import StrEnum
3
- from typing import Any, Literal, NotRequired, TypedDict
3
+ from typing import Literal, NotRequired, TypedDict
4
4
 
5
- from pydantic import BaseModel, GetCoreSchemaHandler
6
- from pydantic_core import CoreSchema, core_schema
7
-
8
-
9
- class Base64MediaContent(str):
10
- @classmethod
11
- def __get_pydantic_core_schema__(cls, source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema:
12
- return core_schema.no_info_after_validator_function(cls, handler(str))
13
-
14
- @classmethod
15
- def from_bytes(cls, content: bytes, /) -> "Base64MediaContent":
16
- return cls(base64.b64encode(content).decode())
5
+ from pydantic import BaseModel
17
6
 
18
7
 
19
8
  class AIModel(StrEnum):
@@ -30,7 +19,10 @@ class AIModel(StrEnum):
30
19
  GEMINI_FLASH_2_0 = "gemini/gemini-2.0-flash"
31
20
 
32
21
 
33
- class UserMediaContentType(StrEnum):
22
+ class ContentType(StrEnum):
23
+ # text
24
+ TEXT = "text/plain"
25
+
34
26
  # images
35
27
  JPEG = "image/jpeg"
36
28
  PNG = "image/png"
@@ -64,33 +56,30 @@ class LLMMessage(TypedDict):
64
56
  cache_control: NotRequired[CacheControl]
65
57
 
66
58
 
67
- class TextMessagePart(BaseModel):
68
- text: str
69
-
70
- def render(self) -> LLMTextMessagePart:
71
- return {"type": "text", "text": self.text}
72
-
59
+ class MessagePart(BaseModel):
60
+ content: str
61
+ content_type: ContentType = ContentType.TEXT
73
62
 
74
- class MediaMessagePart(BaseModel):
75
- content_type: UserMediaContentType
76
- content: Base64MediaContent
63
+ @classmethod
64
+ def from_media(cls, *, content: bytes, content_type: ContentType) -> "MessagePart":
65
+ return cls(content=base64.b64encode(content).decode(), content_type=content_type)
77
66
 
78
- def render(self) -> LLMMediaMessagePart:
79
- return {
80
- "type": "image_url",
81
- "image_url": f"data:{self.content_type};base64,{self.content}",
82
- }
67
+ def render(self) -> LLMTextMessagePart | LLMMediaMessagePart:
68
+ if self.content_type == ContentType.TEXT:
69
+ return {"type": "text", "text": self.content}
70
+ else:
71
+ return {"type": "image_url", "image_url": f"data:{self.content_type};base64,{self.content}"}
83
72
 
84
73
 
85
74
  class UserMessage(BaseModel):
86
- parts: list[TextMessagePart | MediaMessagePart]
75
+ parts: list[MessagePart]
87
76
 
88
77
  def render(self) -> LLMMessage:
89
78
  content: LLMMessage = {
90
79
  "role": "user",
91
80
  "content": [part.render() for part in self.parts],
92
81
  }
93
- if any(isinstance(part, MediaMessagePart) for part in self.parts):
82
+ if any(part.content_type != ContentType.TEXT for part in self.parts):
94
83
  content["cache_control"] = {"type": "ephemeral"}
95
84
  return content
96
85
 
@@ -103,7 +92,7 @@ class AssistantMessage(BaseModel):
103
92
 
104
93
 
105
94
  class SystemMessage(BaseModel):
106
- parts: list[TextMessagePart | MediaMessagePart]
95
+ parts: list[MessagePart]
107
96
 
108
97
  def render(self) -> LLMMessage:
109
98
  return {
goose/agent.py CHANGED
@@ -2,14 +2,12 @@ from ._internal.agent import AgentResponse, IAgentLogger
2
2
  from ._internal.types.agent import (
3
3
  AIModel,
4
4
  AssistantMessage,
5
- Base64MediaContent,
5
+ ContentType,
6
6
  LLMMediaMessagePart,
7
7
  LLMMessage,
8
8
  LLMTextMessagePart,
9
- MediaMessagePart,
9
+ MessagePart,
10
10
  SystemMessage,
11
- TextMessagePart,
12
- UserMediaContentType,
13
11
  UserMessage,
14
12
  )
15
13
 
@@ -18,13 +16,11 @@ __all__ = [
18
16
  "AIModel",
19
17
  "IAgentLogger",
20
18
  "AssistantMessage",
21
- "Base64MediaContent",
22
19
  "LLMMediaMessagePart",
23
20
  "LLMMessage",
24
21
  "LLMTextMessagePart",
25
- "MediaMessagePart",
26
22
  "SystemMessage",
27
- "TextMessagePart",
28
- "UserMediaContentType",
23
+ "MessagePart",
24
+ "ContentType",
29
25
  "UserMessage",
30
26
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: goose-py
3
- Version: 0.9.13
3
+ Version: 0.9.15
4
4
  Summary: A tool for AI workflows based on human-computer collaboration and structured output.
5
5
  Author-email: Nash Taylor <nash@chelle.ai>, Joshua Cook <joshua@chelle.ai>, Michael Sankur <michael@chelle.ai>
6
6
  Requires-Python: >=3.12
@@ -1,11 +1,11 @@
1
1
  goose/__init__.py,sha256=wjGDgWzKcD6S8loVr0n-rLCpRwg-ZKAixcUaw1wobMc,243
2
- goose/agent.py,sha256=3T5hobYzro2tmYaUd_kNfIxpmnioLOYy9HaYT0XttIA,632
2
+ goose/agent.py,sha256=u6daAnn4fPgP4Jk9cHANyCEku3RmUqKLdqtyGSr8ljI,510
3
3
  goose/errors.py,sha256=-0OyZQJWYTRw5YgnCB2_uorVaUsL6Z0QYQO2FqzCiyg,32
4
4
  goose/flow.py,sha256=YsZLBa5I1W27_P6LYGWbtFX8ZYx9vJG3KtENYChHm5E,111
5
5
  goose/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  goose/runs.py,sha256=ub-r_gzbUbaIzWXX-jc-dncNxEh6zTfzIkmnDfCSbRI,160
7
7
  goose/task.py,sha256=95rspdxETJoY12IHBl3KjnVIdqQnf1jDKlnGWNWOTvQ,53
8
- goose/_internal/agent.py,sha256=VRDEhBDTpKZS09B6xnWsOqLsxP7D5NHKVGlxwayPdoo,6030
8
+ goose/_internal/agent.py,sha256=x3uyPrV5gezsjslm_9NFuakufkhQhcireY8GkHniZSs,5859
9
9
  goose/_internal/conversation.py,sha256=zbMvP4oxhKAzATVEXZfGVKXWfEjh472MYKhmyJzSLgI,1172
10
10
  goose/_internal/flow.py,sha256=RShMsxgt49g1fZJ3rlwDHtI1j39lZzewx8hZ7DGN5kg,4124
11
11
  goose/_internal/result.py,sha256=-eZJn-2sPo7rHZ38Sz6IAHXqiJ-Ss39esEoFGimJEBI,155
@@ -13,7 +13,7 @@ goose/_internal/state.py,sha256=pI-C37Ybazo7EJPbZklxbiCYFy3u4I031NKBr8Jm_CI,6534
13
13
  goose/_internal/store.py,sha256=tWmKfa1-yq1jU6lT3l6kSOmVt2m3H7I1xLMTrxnUDI8,889
14
14
  goose/_internal/task.py,sha256=qjpX_wIQ2jKreMjrRy1SVedsuVzLXuOLgcyPstrgWfE,6176
15
15
  goose/_internal/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- goose/_internal/types/agent.py,sha256=DEDu2BZ4nmiU0J8GqYJtxq_VBjR-aXRjYkjmeSEX9OQ,3013
17
- goose_py-0.9.13.dist-info/METADATA,sha256=tg0tK_QC2E_GBMA-bh7Wu24GzBu1v-moWe1dZkST-Vw,442
18
- goose_py-0.9.13.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
19
- goose_py-0.9.13.dist-info/RECORD,,
16
+ goose/_internal/types/agent.py,sha256=g0KD-aPWZlUGBx72AwQd3LeniFxHATeflZ7191QjFZA,2696
17
+ goose_py-0.9.15.dist-info/METADATA,sha256=b87H2JP5nAIuYiit4wb_QXDK9JmZClQy9HlWjYZWRrA,442
18
+ goose_py-0.9.15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
19
+ goose_py-0.9.15.dist-info/RECORD,,