acp-sdk 0.3.1__py3-none-any.whl → 0.3.2__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.
acp_sdk/models/models.py CHANGED
@@ -17,12 +17,12 @@ class AnyModel(BaseModel):
17
17
 
18
18
  class MessagePart(BaseModel):
19
19
  name: Optional[str] = None
20
- content_type: str
20
+ content_type: Optional[str] = "text/plain"
21
21
  content: Optional[str] = None
22
22
  content_encoding: Optional[Literal["plain", "base64"]] = "plain"
23
23
  content_url: Optional[AnyUrl] = None
24
24
 
25
- model_config = ConfigDict(extra="forbid")
25
+ model_config = ConfigDict(extra="allow")
26
26
 
27
27
  def model_post_init(self, __context: Any) -> None:
28
28
  if self.content is None and self.content_url is None:
@@ -48,6 +48,36 @@ class Message(BaseModel):
48
48
  part.content for part in self.parts if part.content is not None and part.content_type == "text/plain"
49
49
  )
50
50
 
51
+ def compress(self) -> "Message":
52
+ def can_be_joined(first: MessagePart, second: MessagePart) -> bool:
53
+ return (
54
+ first.name is None
55
+ and second.name is None
56
+ and first.content_type == "text/plain"
57
+ and second.content_type == "text/plain"
58
+ and first.content_encoding == "plain"
59
+ and second.content_encoding == "plain"
60
+ and first.content_url is None
61
+ and second.content_url is None
62
+ )
63
+
64
+ def join(first: MessagePart, second: MessagePart) -> MessagePart:
65
+ return MessagePart(
66
+ name=None,
67
+ content_type="text/plain",
68
+ content=first.content + second.content,
69
+ content_encoding="plain",
70
+ content_url=None,
71
+ )
72
+
73
+ parts: list[MessagePart] = []
74
+ for part in self.parts:
75
+ if len(parts) > 0 and can_be_joined(parts[-1], part):
76
+ parts[-1] = join(parts[-1], part)
77
+ else:
78
+ parts.append(part)
79
+ return Message(parts=parts)
80
+
51
81
 
52
82
  AgentName = str
53
83
  SessionId = uuid.UUID
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: acp-sdk
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: Agent Communication Protocol SDK
5
5
  Author: IBM Corp.
6
6
  Maintainer-email: Tomas Pilar <thomas7pilar@gmail.com>
@@ -6,7 +6,7 @@ acp_sdk/client/__init__.py,sha256=Bca1DORrswxzZsrR2aUFpATuNG2xNSmYvF1Z2WJaVbc,51
6
6
  acp_sdk/client/client.py,sha256=lEUs0Oc7MZbKkTF2E6e8Wn3dTW5cMVj6fD8TbuEOMDk,6584
7
7
  acp_sdk/models/__init__.py,sha256=numSDBDT1QHx7n_Y3Deb5VOvKWcUBxbOEaMwQBSRHxc,151
8
8
  acp_sdk/models/errors.py,sha256=rEyaMVvQuBi7fwWe_d0PGGySYsD3FZTluQ-SkC0yhAs,444
9
- acp_sdk/models/models.py,sha256=GjsVvP5NVlW_9pbi47vBZA94WRL8bcMzbWIebwZuJGs,4158
9
+ acp_sdk/models/models.py,sha256=J9hnaj5S8p4T3mlVb2iyGD1JuOw0R8JoKqBYDKeZXUw,5318
10
10
  acp_sdk/models/schemas.py,sha256=Kj7drJSR8d-N3KHzu_qTnLdagrMtAyhid5swluuhHTw,645
11
11
  acp_sdk/server/__init__.py,sha256=mxBBBFaZuMEUENRMLwp1XZkuLeT9QghcFmNvjnqvAAU,377
12
12
  acp_sdk/server/agent.py,sha256=fGky5MIuknw-Gy-THqhWLt9I9-gUyNIar8qEAvZb3uQ,6195
@@ -20,6 +20,6 @@ acp_sdk/server/session.py,sha256=0cDr924HC5x2bBNbK9NSKVHAt5A_mi5dK8P4jP_ugq0,629
20
20
  acp_sdk/server/telemetry.py,sha256=1BUxNg-xL_Vqgs27PDWNc3HikrQW2lidAtT_FKlp_Qk,1833
21
21
  acp_sdk/server/types.py,sha256=E0_9xWwgGzyvJjxtbeBBmSbIPhbbTSXLpHFL5dZDzxI,182
22
22
  acp_sdk/server/utils.py,sha256=EfrF9VCyVk3AM_ao-BIB9EzGbfTrh4V2Bz-VFr6f6Sg,351
23
- acp_sdk-0.3.1.dist-info/METADATA,sha256=Eng_oiR7OIfJK3XDKIAjlmlFX8eHoVqxkd_6XIVpXlQ,3119
24
- acp_sdk-0.3.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
25
- acp_sdk-0.3.1.dist-info/RECORD,,
23
+ acp_sdk-0.3.2.dist-info/METADATA,sha256=79mXTyM_99E4TYQIIMPEJ-R5WkImcl4IWSbhNe1fc5I,3119
24
+ acp_sdk-0.3.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
25
+ acp_sdk-0.3.2.dist-info/RECORD,,