acp-sdk 0.3.0__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 +42 -6
- acp_sdk/server/app.py +10 -0
- acp_sdk/server/bundle.py +2 -0
- acp_sdk/server/types.py +1 -1
- {acp_sdk-0.3.0.dist-info → acp_sdk-0.3.2.dist-info}/METADATA +2 -14
- {acp_sdk-0.3.0.dist-info → acp_sdk-0.3.2.dist-info}/RECORD +7 -7
- {acp_sdk-0.3.0.dist-info → acp_sdk-0.3.2.dist-info}/WHEEL +0 -0
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="
|
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
|
@@ -75,12 +105,18 @@ class RunStatus(str, Enum):
|
|
75
105
|
return self in terminal_states
|
76
106
|
|
77
107
|
|
78
|
-
class
|
79
|
-
type: Literal["
|
108
|
+
class MessageAwaitRequest(BaseModel):
|
109
|
+
type: Literal["message"] = "message"
|
110
|
+
message: Message
|
111
|
+
|
112
|
+
|
113
|
+
class MessageAwaitResume(BaseModel):
|
114
|
+
type: Literal["message"] = "message"
|
115
|
+
message: Message
|
80
116
|
|
81
117
|
|
82
|
-
|
83
|
-
|
118
|
+
AwaitRequest = Union[MessageAwaitRequest]
|
119
|
+
AwaitResume = Union[MessageAwaitResume]
|
84
120
|
|
85
121
|
|
86
122
|
class Run(BaseModel):
|
acp_sdk/server/app.py
CHANGED
@@ -144,6 +144,16 @@ def create_app(*agents: Agent) -> FastAPI:
|
|
144
144
|
@app.post("/runs/{run_id}")
|
145
145
|
async def resume_run(run_id: RunId, request: RunResumeRequest) -> RunResumeResponse:
|
146
146
|
bundle = find_run_bundle(run_id)
|
147
|
+
|
148
|
+
if bundle.run.await_request is None:
|
149
|
+
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail=f"Run {run_id} has no await request")
|
150
|
+
|
151
|
+
if bundle.run.await_request.type != request.await_resume.type:
|
152
|
+
raise HTTPException(
|
153
|
+
status_code=status.HTTP_403_FORBIDDEN,
|
154
|
+
detail=f"Run {run_id} is expecting resume of type {bundle.run.await_request.type}",
|
155
|
+
)
|
156
|
+
|
147
157
|
await bundle.resume(request.await_resume)
|
148
158
|
match request.mode:
|
149
159
|
case RunMode.STREAM:
|
acp_sdk/server/bundle.py
CHANGED
acp_sdk/server/types.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.2
|
4
4
|
Summary: Agent Communication Protocol SDK
|
5
5
|
Author: IBM Corp.
|
6
6
|
Maintainer-email: Tomas Pilar <thomas7pilar@gmail.com>
|
@@ -28,19 +28,7 @@ Agent Communication Protocol SDK for Python provides allows developers to serve
|
|
28
28
|
|
29
29
|
## Installation
|
30
30
|
|
31
|
-
Install
|
32
|
-
|
33
|
-
```shell
|
34
|
-
pip install acp-sdk[client]
|
35
|
-
```
|
36
|
-
|
37
|
-
Install to use server:
|
38
|
-
|
39
|
-
```shell
|
40
|
-
pip install acp-sdk[server]
|
41
|
-
```
|
42
|
-
|
43
|
-
Install to use models only:
|
31
|
+
Install with:
|
44
32
|
|
45
33
|
```shell
|
46
34
|
pip install acp-sdk
|
@@ -6,20 +6,20 @@ 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=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
|
13
|
-
acp_sdk/server/app.py,sha256=
|
14
|
-
acp_sdk/server/bundle.py,sha256=
|
13
|
+
acp_sdk/server/app.py,sha256=3QJzGi05DKoIKyTeYYKKQhcYz4qorQKmVI94_guVkEY,6340
|
14
|
+
acp_sdk/server/bundle.py,sha256=6LZnxsP1rawxic9CwDAQCsOV1v31qNI9meKXMty_yWg,6260
|
15
15
|
acp_sdk/server/context.py,sha256=MgnLV6qcDIhc_0BjW7r4Jj1tHts4ZuwpdTGIBnz2Mgo,1036
|
16
16
|
acp_sdk/server/errors.py,sha256=IGtpPpb2ChtYvCac8kf_P-RkcY71gBvX0yq97uZWa-w,2104
|
17
17
|
acp_sdk/server/logging.py,sha256=Oc8yZigCsuDnHHPsarRzu0RX3NKaLEgpELM2yovGKDI,411
|
18
18
|
acp_sdk/server/server.py,sha256=-eT3fmnEsBUN44Spi2EP2eV0l4RAlKa8bzqxnhz16SM,5399
|
19
19
|
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
|
-
acp_sdk/server/types.py,sha256=
|
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.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,,
|
File without changes
|