acp-sdk 0.10.0__py3-none-any.whl → 0.11.0__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/client/client.py +133 -42
- acp_sdk/models/__init__.py +1 -0
- acp_sdk/models/models.py +75 -9
- acp_sdk/models/schemas.py +18 -3
- acp_sdk/models/types.py +9 -0
- acp_sdk/server/__init__.py +5 -1
- acp_sdk/server/agent.py +8 -84
- acp_sdk/server/app.py +87 -29
- acp_sdk/server/context.py +11 -3
- acp_sdk/server/executor.py +139 -14
- acp_sdk/server/server.py +31 -6
- acp_sdk/server/store/memory_store.py +4 -4
- acp_sdk/server/utils.py +1 -1
- acp_sdk/shared/__init__.py +2 -0
- acp_sdk/shared/resources.py +46 -0
- {acp_sdk-0.10.0.dist-info → acp_sdk-0.11.0.dist-info}/METADATA +2 -1
- acp_sdk-0.11.0.dist-info/RECORD +35 -0
- acp_sdk/server/session.py +0 -24
- acp_sdk-0.10.0.dist-info/RECORD +0 -33
- {acp_sdk-0.10.0.dist-info → acp_sdk-0.11.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
from datetime import timedelta
|
2
|
+
|
3
|
+
import cachetools
|
4
|
+
import cachetools.func
|
5
|
+
import httpx
|
6
|
+
import obstore
|
7
|
+
from obstore.store import AzureStore, GCSStore, HTTPStore, ObjectStore, S3Store
|
8
|
+
|
9
|
+
from acp_sdk.models.types import ResourceId, ResourceUrl
|
10
|
+
|
11
|
+
|
12
|
+
class ResourceLoader:
|
13
|
+
def __init__(self, *, client: httpx.AsyncClient | None = None) -> None:
|
14
|
+
self._client = client or httpx.AsyncClient(follow_redirects=False)
|
15
|
+
|
16
|
+
@cachetools.func.lfu_cache
|
17
|
+
async def load(self, url: ResourceUrl) -> bytes:
|
18
|
+
response = await self._client.get(str(url))
|
19
|
+
response.raise_for_status()
|
20
|
+
return await response.aread()
|
21
|
+
|
22
|
+
|
23
|
+
class ResourceStore:
|
24
|
+
def __init__(self, *, store: ObjectStore, presigned_url_expiration: timedelta = timedelta(days=7)) -> None:
|
25
|
+
self._store = store
|
26
|
+
self._presigned_url_expiration = presigned_url_expiration
|
27
|
+
|
28
|
+
async def load(self, id: ResourceId): # noqa: ANN201
|
29
|
+
result = await self._store.get_async(str(id))
|
30
|
+
return result
|
31
|
+
|
32
|
+
async def store(
|
33
|
+
self,
|
34
|
+
id: ResourceId,
|
35
|
+
data: bytes,
|
36
|
+
) -> None:
|
37
|
+
await self._store.put_async(str(id), data)
|
38
|
+
|
39
|
+
async def url(self, id: ResourceId) -> ResourceUrl:
|
40
|
+
if isinstance(self._store, (AzureStore, GCSStore, S3Store)):
|
41
|
+
url = await obstore.sign_async(self._store, "GET", str(id), self._presigned_url_expiration)
|
42
|
+
return ResourceUrl(url=url)
|
43
|
+
elif isinstance(self._store, HTTPStore):
|
44
|
+
return ResourceUrl(url=f"{self._store.url}/{id!s}")
|
45
|
+
else:
|
46
|
+
raise NotImplementedError("Unsupported store")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: acp-sdk
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.11.0
|
4
4
|
Summary: Agent Communication Protocol SDK
|
5
5
|
Author: IBM Corp.
|
6
6
|
Maintainer-email: Tomas Pilar <thomas7pilar@gmail.com>
|
@@ -11,6 +11,7 @@ Requires-Dist: fastapi[standard]>=0.115
|
|
11
11
|
Requires-Dist: httpx-sse>=0.4
|
12
12
|
Requires-Dist: httpx>=0.26
|
13
13
|
Requires-Dist: janus>=2.0
|
14
|
+
Requires-Dist: obstore>=0.6
|
14
15
|
Requires-Dist: opentelemetry-api>=1.31
|
15
16
|
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.31
|
16
17
|
Requires-Dist: opentelemetry-instrumentation-fastapi>=0.52b1
|
@@ -0,0 +1,35 @@
|
|
1
|
+
acp_sdk/__init__.py,sha256=tXdAUM9zcmdSKCAkVrOCrGcXcuVS-yuvQUoQwTe9pek,98
|
2
|
+
acp_sdk/instrumentation.py,sha256=JqSyvILN3sGAfOZrmckQq4-M_4_5alyPn95DK0o5lfA,161
|
3
|
+
acp_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
+
acp_sdk/version.py,sha256=Niy83rgvigB4hL_rR-O4ySvI7dj6xnqkyOe_JTymi9s,73
|
5
|
+
acp_sdk/client/__init__.py,sha256=Bca1DORrswxzZsrR2aUFpATuNG2xNSmYvF1Z2WJaVbc,51
|
6
|
+
acp_sdk/client/client.py,sha256=p6e5zmH9-hdx0t0zoQOCSkgSUgmH-YCTD5_1idcwTEQ,12763
|
7
|
+
acp_sdk/client/types.py,sha256=_H6zYt-2OHOOYRtssRnbDIiwmgsl2-KIXc9lb-mJLFA,133
|
8
|
+
acp_sdk/client/utils.py,sha256=2jhJyrPJmVFRoDJh0q_JMqOMlC3IxCh-6HXed-PIZS8,924
|
9
|
+
acp_sdk/models/__init__.py,sha256=_XDSvUwlHeRsqUayAxHusJ5s8Z1jWXV1ZcUKlJakOt4,200
|
10
|
+
acp_sdk/models/errors.py,sha256=rEyaMVvQuBi7fwWe_d0PGGySYsD3FZTluQ-SkC0yhAs,444
|
11
|
+
acp_sdk/models/models.py,sha256=0ODyzANVo4t1TOsTZPE-eKyxw9pLDCkMHzqGoTa49LQ,10635
|
12
|
+
acp_sdk/models/schemas.py,sha256=Vu3aO-6M0IW71I9thxAiphLGXXMvyZXFMJCdj7euUmc,915
|
13
|
+
acp_sdk/models/types.py,sha256=tH79qqpW3DrPJggZD1KFlLtGE_ZKT6eLtwiR3p3x2QM,145
|
14
|
+
acp_sdk/server/__init__.py,sha256=TfTOOI7G2nejjOB6RZB5ujynyh3bFeH51pfDIMzv3N4,627
|
15
|
+
acp_sdk/server/agent.py,sha256=tzdk9bXb4aKBKD3F1-QfI7zrjMZYEg6qm3gGRWJGC1E,3739
|
16
|
+
acp_sdk/server/app.py,sha256=KKjZcVxJxQvxAEP_cQna4f9ed1O5mN9Ldo1X_tXfFfI,11107
|
17
|
+
acp_sdk/server/context.py,sha256=Xz1am_HLNTgEvG0IPtS0tRJcPk-rEhLtNyTQGUAvLQw,1271
|
18
|
+
acp_sdk/server/errors.py,sha256=GSO8yYIqEeX8Y4Lz86ks35dMTHiQiXuOrLYYx0eXsbI,2110
|
19
|
+
acp_sdk/server/executor.py,sha256=ktM1FCwixtbjsU60VM7PHxwF_Saz15M_9fNXN4mItrU,12607
|
20
|
+
acp_sdk/server/logging.py,sha256=Oc8yZigCsuDnHHPsarRzu0RX3NKaLEgpELM2yovGKDI,411
|
21
|
+
acp_sdk/server/server.py,sha256=HJOub1ynHiJTQrfKq_bq0r9aqgL1kQeboZH_ArZcuh0,14651
|
22
|
+
acp_sdk/server/telemetry.py,sha256=lbB2ppijUcqbHUOn0e-15LGcVvT_qrMguq8qBokICac,2016
|
23
|
+
acp_sdk/server/types.py,sha256=gLb5wCkMYhmu2laj_ymK-TPfN9LSjRgKOP1H_893UzA,304
|
24
|
+
acp_sdk/server/utils.py,sha256=O9GUZ8SKqk8P5Vo-N4BD7hXS3XuE7l8wifOhvKMX3ws,2715
|
25
|
+
acp_sdk/server/store/__init__.py,sha256=zzKic0byQTM86cyC2whwZeNP4prfy_HZrbSriTaV5j8,282
|
26
|
+
acp_sdk/server/store/memory_store.py,sha256=ykGskORGJUhQNMxTmXuNB8tX8xCgukr5502PSZr14nk,1214
|
27
|
+
acp_sdk/server/store/postgresql_store.py,sha256=bHyAgf4vSn_07wGXXq6juFwm3JldYNOjU9RARcDSYQo,2717
|
28
|
+
acp_sdk/server/store/redis_store.py,sha256=IKXvDseOFMcoGjVYPOkOBhPnJAchy_RyeMayKLoVCGA,1378
|
29
|
+
acp_sdk/server/store/store.py,sha256=jGmYy9oiuVjhYYJY8QRo4g2J2Qyt1HLTmq_eHy4aI7c,1806
|
30
|
+
acp_sdk/server/store/utils.py,sha256=JumEOMs1h1uGlnHnUGeguee-srGzT7_Y2NVEYt01QuY,92
|
31
|
+
acp_sdk/shared/__init__.py,sha256=vZuhdQ6lrWVdyYPmIyXpPvs5eMnzemhNek3gfYPA3Bc,138
|
32
|
+
acp_sdk/shared/resources.py,sha256=3oPvevYv2B1YaHyoMH85B7fcHVyhgZDUaDCBVEflTlA,1592
|
33
|
+
acp_sdk-0.11.0.dist-info/METADATA,sha256=cVzemGKHjihYYsjeO30x9ff08TvrsJjVSTb6ug3k9N8,1713
|
34
|
+
acp_sdk-0.11.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
35
|
+
acp_sdk-0.11.0.dist-info/RECORD,,
|
acp_sdk/server/session.py
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
import uuid
|
2
|
-
|
3
|
-
from pydantic import BaseModel, Field
|
4
|
-
|
5
|
-
from acp_sdk.models import Message, RunId, RunStatus, SessionId
|
6
|
-
from acp_sdk.server.executor import RunData
|
7
|
-
from acp_sdk.server.store import Store
|
8
|
-
|
9
|
-
|
10
|
-
class Session(BaseModel):
|
11
|
-
id: SessionId = Field(default_factory=uuid.uuid4)
|
12
|
-
runs: list[RunId] = []
|
13
|
-
|
14
|
-
def append(self, run_id: RunId) -> None:
|
15
|
-
self.runs.append(run_id)
|
16
|
-
|
17
|
-
async def history(self, store: Store[RunData]) -> list[Message]:
|
18
|
-
history = []
|
19
|
-
for run_id in self.runs:
|
20
|
-
run_data = await store.get(run_id)
|
21
|
-
if run_data is not None and run_data.run.status == RunStatus.COMPLETED:
|
22
|
-
history.extend(run_data.input)
|
23
|
-
history.extend(run_data.run.output)
|
24
|
-
return history
|
acp_sdk-0.10.0.dist-info/RECORD
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
acp_sdk/__init__.py,sha256=tXdAUM9zcmdSKCAkVrOCrGcXcuVS-yuvQUoQwTe9pek,98
|
2
|
-
acp_sdk/instrumentation.py,sha256=JqSyvILN3sGAfOZrmckQq4-M_4_5alyPn95DK0o5lfA,161
|
3
|
-
acp_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
-
acp_sdk/version.py,sha256=Niy83rgvigB4hL_rR-O4ySvI7dj6xnqkyOe_JTymi9s,73
|
5
|
-
acp_sdk/client/__init__.py,sha256=Bca1DORrswxzZsrR2aUFpATuNG2xNSmYvF1Z2WJaVbc,51
|
6
|
-
acp_sdk/client/client.py,sha256=7GVD7eVlaSU78O3puMlyoOTqKjTwZYaBKLHyYvbvr3I,8504
|
7
|
-
acp_sdk/client/types.py,sha256=_H6zYt-2OHOOYRtssRnbDIiwmgsl2-KIXc9lb-mJLFA,133
|
8
|
-
acp_sdk/client/utils.py,sha256=2jhJyrPJmVFRoDJh0q_JMqOMlC3IxCh-6HXed-PIZS8,924
|
9
|
-
acp_sdk/models/__init__.py,sha256=numSDBDT1QHx7n_Y3Deb5VOvKWcUBxbOEaMwQBSRHxc,151
|
10
|
-
acp_sdk/models/errors.py,sha256=rEyaMVvQuBi7fwWe_d0PGGySYsD3FZTluQ-SkC0yhAs,444
|
11
|
-
acp_sdk/models/models.py,sha256=So5D9VjJxX2jdOF8BGc3f9D2ssbAyFEO2Rgr1KykI-M,7730
|
12
|
-
acp_sdk/models/schemas.py,sha256=_ah7_zHsQJGxDXvnzsBvASdRsQHVphFQ7Sum6A04iRw,759
|
13
|
-
acp_sdk/server/__init__.py,sha256=mxBBBFaZuMEUENRMLwp1XZkuLeT9QghcFmNvjnqvAAU,377
|
14
|
-
acp_sdk/server/agent.py,sha256=6VBKn_qVXqUl79G8T7grwhnuLMwr67d4UGagMGX1hMs,6586
|
15
|
-
acp_sdk/server/app.py,sha256=XeMn8hfU2J2O2QxSvsH5q6lowxCfwS1-DTWz-gUVotA,8733
|
16
|
-
acp_sdk/server/context.py,sha256=MgnLV6qcDIhc_0BjW7r4Jj1tHts4ZuwpdTGIBnz2Mgo,1036
|
17
|
-
acp_sdk/server/errors.py,sha256=GSO8yYIqEeX8Y4Lz86ks35dMTHiQiXuOrLYYx0eXsbI,2110
|
18
|
-
acp_sdk/server/executor.py,sha256=YL0J9cVY1QZtdTeqwjJaKDpB_T6_sByHlHc52kgNAJo,7742
|
19
|
-
acp_sdk/server/logging.py,sha256=Oc8yZigCsuDnHHPsarRzu0RX3NKaLEgpELM2yovGKDI,411
|
20
|
-
acp_sdk/server/server.py,sha256=lgpvokjd3f_dqEkyfLn3Nr4oKXNHPUkvV0uNimUmXU8,13497
|
21
|
-
acp_sdk/server/session.py,sha256=vGUVpKzUGefI1c7LeK08Bvd8zvJIRfsdJEt2KhYoEg0,764
|
22
|
-
acp_sdk/server/telemetry.py,sha256=lbB2ppijUcqbHUOn0e-15LGcVvT_qrMguq8qBokICac,2016
|
23
|
-
acp_sdk/server/types.py,sha256=gLb5wCkMYhmu2laj_ymK-TPfN9LSjRgKOP1H_893UzA,304
|
24
|
-
acp_sdk/server/utils.py,sha256=BYSn4Bd95Bn-oEH1W1yE_pWpYUOdtYPh-vMnou4nsdk,2721
|
25
|
-
acp_sdk/server/store/__init__.py,sha256=zzKic0byQTM86cyC2whwZeNP4prfy_HZrbSriTaV5j8,282
|
26
|
-
acp_sdk/server/store/memory_store.py,sha256=9hOoJiHdaDz-0hNHWhO_qZpp-I_pnTqYBIhQnlWilu4,1194
|
27
|
-
acp_sdk/server/store/postgresql_store.py,sha256=bHyAgf4vSn_07wGXXq6juFwm3JldYNOjU9RARcDSYQo,2717
|
28
|
-
acp_sdk/server/store/redis_store.py,sha256=IKXvDseOFMcoGjVYPOkOBhPnJAchy_RyeMayKLoVCGA,1378
|
29
|
-
acp_sdk/server/store/store.py,sha256=jGmYy9oiuVjhYYJY8QRo4g2J2Qyt1HLTmq_eHy4aI7c,1806
|
30
|
-
acp_sdk/server/store/utils.py,sha256=JumEOMs1h1uGlnHnUGeguee-srGzT7_Y2NVEYt01QuY,92
|
31
|
-
acp_sdk-0.10.0.dist-info/METADATA,sha256=wmPPGrdoeCoe7M8DM-r3qlLgpwVteHARkZpbKaVGk9I,1685
|
32
|
-
acp_sdk-0.10.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
33
|
-
acp_sdk-0.10.0.dist-info/RECORD,,
|
File without changes
|