acp-sdk 0.3.1__py3-none-any.whl → 0.3.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.
acp_sdk/models/models.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import uuid
|
2
|
+
from datetime import datetime
|
2
3
|
from enum import Enum
|
3
4
|
from typing import Any, Literal, Optional, Union
|
4
5
|
|
@@ -7,22 +8,73 @@ from pydantic import AnyUrl, BaseModel, ConfigDict, Field
|
|
7
8
|
from acp_sdk.models.errors import Error
|
8
9
|
|
9
10
|
|
10
|
-
class
|
11
|
+
class AnyModel(BaseModel):
|
11
12
|
model_config = ConfigDict(extra="allow")
|
12
13
|
|
13
14
|
|
14
|
-
class
|
15
|
+
class Author(BaseModel):
|
16
|
+
name: str
|
17
|
+
email: str | None = None
|
18
|
+
url: AnyUrl | None = None
|
19
|
+
|
20
|
+
|
21
|
+
class Contributor(BaseModel):
|
22
|
+
name: str
|
23
|
+
email: str | None = None
|
24
|
+
url: AnyUrl | None = None
|
25
|
+
|
26
|
+
|
27
|
+
class LinkType(str, Enum):
|
28
|
+
SOURCE_CODE = "source-code"
|
29
|
+
CONTAINER_IMAGE = "container-image"
|
30
|
+
HOMEPAGE = "homepage"
|
31
|
+
DOCUMENTATION = "documentation"
|
32
|
+
|
33
|
+
|
34
|
+
class Link(BaseModel):
|
35
|
+
type: LinkType
|
36
|
+
url: AnyUrl
|
37
|
+
|
38
|
+
|
39
|
+
class DependencyType(str, Enum):
|
40
|
+
AGENT = "agent"
|
41
|
+
TOOL = "tool"
|
42
|
+
MODEL = "model"
|
43
|
+
|
44
|
+
|
45
|
+
class Dependency(BaseModel):
|
46
|
+
type: DependencyType
|
47
|
+
name: str
|
48
|
+
|
49
|
+
|
50
|
+
class Metadata(BaseModel):
|
51
|
+
annotations: AnyModel | None = None
|
52
|
+
documentation: str | None = None
|
53
|
+
license: str | None = None
|
54
|
+
programming_language: str | None = None
|
55
|
+
natural_languages: list[str] | None = None
|
56
|
+
framework: str | None = None
|
57
|
+
use_cases: list[str] | None = None
|
58
|
+
tags: list[str] | None = None
|
59
|
+
created_at: datetime | None = None
|
60
|
+
updated_at: datetime | None = None
|
61
|
+
author: Author | None = None
|
62
|
+
contributors: list[Contributor] | None = None
|
63
|
+
links: list[Link] | None = None
|
64
|
+
dependencies: list[Dependency] | None = None
|
65
|
+
recommended_models: list[str] | None = None
|
66
|
+
|
15
67
|
model_config = ConfigDict(extra="allow")
|
16
68
|
|
17
69
|
|
18
70
|
class MessagePart(BaseModel):
|
19
71
|
name: Optional[str] = None
|
20
|
-
content_type: str
|
72
|
+
content_type: Optional[str] = "text/plain"
|
21
73
|
content: Optional[str] = None
|
22
74
|
content_encoding: Optional[Literal["plain", "base64"]] = "plain"
|
23
75
|
content_url: Optional[AnyUrl] = None
|
24
76
|
|
25
|
-
model_config = ConfigDict(extra="
|
77
|
+
model_config = ConfigDict(extra="allow")
|
26
78
|
|
27
79
|
def model_post_init(self, __context: Any) -> None:
|
28
80
|
if self.content is None and self.content_url is None:
|
@@ -48,6 +100,36 @@ class Message(BaseModel):
|
|
48
100
|
part.content for part in self.parts if part.content is not None and part.content_type == "text/plain"
|
49
101
|
)
|
50
102
|
|
103
|
+
def compress(self) -> "Message":
|
104
|
+
def can_be_joined(first: MessagePart, second: MessagePart) -> bool:
|
105
|
+
return (
|
106
|
+
first.name is None
|
107
|
+
and second.name is None
|
108
|
+
and first.content_type == "text/plain"
|
109
|
+
and second.content_type == "text/plain"
|
110
|
+
and first.content_encoding == "plain"
|
111
|
+
and second.content_encoding == "plain"
|
112
|
+
and first.content_url is None
|
113
|
+
and second.content_url is None
|
114
|
+
)
|
115
|
+
|
116
|
+
def join(first: MessagePart, second: MessagePart) -> MessagePart:
|
117
|
+
return MessagePart(
|
118
|
+
name=None,
|
119
|
+
content_type="text/plain",
|
120
|
+
content=first.content + second.content,
|
121
|
+
content_encoding="plain",
|
122
|
+
content_url=None,
|
123
|
+
)
|
124
|
+
|
125
|
+
parts: list[MessagePart] = []
|
126
|
+
for part in self.parts:
|
127
|
+
if len(parts) > 0 and can_be_joined(parts[-1], part):
|
128
|
+
parts[-1] = join(parts[-1], part)
|
129
|
+
else:
|
130
|
+
parts.append(part)
|
131
|
+
return Message(parts=parts)
|
132
|
+
|
51
133
|
|
52
134
|
AgentName = str
|
53
135
|
SessionId = uuid.UUID
|
acp_sdk/server/agent.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: acp-sdk
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.3
|
4
4
|
Summary: Agent Communication Protocol SDK
|
5
5
|
Author: IBM Corp.
|
6
6
|
Maintainer-email: Tomas Pilar <thomas7pilar@gmail.com>
|
@@ -63,7 +63,7 @@ server = Server()
|
|
63
63
|
async def echo(inputs: list[Message], context: Context) -> AsyncGenerator[RunYield, RunYieldResume]:
|
64
64
|
"""Echoes everything"""
|
65
65
|
for message in inputs:
|
66
|
-
yield {"thought": "I should echo
|
66
|
+
yield {"thought": "I should echo everything"}
|
67
67
|
await asyncio.sleep(0.5)
|
68
68
|
yield message
|
69
69
|
|
@@ -6,10 +6,10 @@ 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=
|
9
|
+
acp_sdk/models/models.py,sha256=eOoOfftPKbTaLlqZlE4gE1ZwDkrQ_FdRiDx4wSJILP4,6539
|
10
10
|
acp_sdk/models/schemas.py,sha256=Kj7drJSR8d-N3KHzu_qTnLdagrMtAyhid5swluuhHTw,645
|
11
11
|
acp_sdk/server/__init__.py,sha256=mxBBBFaZuMEUENRMLwp1XZkuLeT9QghcFmNvjnqvAAU,377
|
12
|
-
acp_sdk/server/agent.py,sha256=
|
12
|
+
acp_sdk/server/agent.py,sha256=DhcPDPDL9jpDST40K_bInvDXfpF1cwxIhqXzu8z0blU,6203
|
13
13
|
acp_sdk/server/app.py,sha256=3QJzGi05DKoIKyTeYYKKQhcYz4qorQKmVI94_guVkEY,6340
|
14
14
|
acp_sdk/server/bundle.py,sha256=6LZnxsP1rawxic9CwDAQCsOV1v31qNI9meKXMty_yWg,6260
|
15
15
|
acp_sdk/server/context.py,sha256=MgnLV6qcDIhc_0BjW7r4Jj1tHts4ZuwpdTGIBnz2Mgo,1036
|
@@ -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.
|
24
|
-
acp_sdk-0.3.
|
25
|
-
acp_sdk-0.3.
|
23
|
+
acp_sdk-0.3.3.dist-info/METADATA,sha256=X4iVzszNG3pWp7eOLPHz6cxaGI4rmMN8MrtCx1ICTOI,3120
|
24
|
+
acp_sdk-0.3.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
25
|
+
acp_sdk-0.3.3.dist-info/RECORD,,
|
File without changes
|