acp-sdk 0.3.2__py3-none-any.whl → 0.4.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/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,11 +8,62 @@ from pydantic import AnyUrl, BaseModel, ConfigDict, Field
7
8
  from acp_sdk.models.errors import Error
8
9
 
9
10
 
10
- class Metadata(BaseModel):
11
+ class AnyModel(BaseModel):
11
12
  model_config = ConfigDict(extra="allow")
12
13
 
13
14
 
14
- class AnyModel(BaseModel):
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
 
acp_sdk/server/agent.py CHANGED
@@ -129,7 +129,7 @@ def agent(
129
129
 
130
130
  @property
131
131
  def description(self) -> str:
132
- return description or fn.__doc__ or ""
132
+ return description or inspect.getdoc(fn) or ""
133
133
 
134
134
  @property
135
135
  def metadata(self) -> Metadata:
acp_sdk/server/errors.py CHANGED
@@ -33,7 +33,7 @@ def status_code_to_error_code(status_code: int) -> ErrorCode:
33
33
  async def acp_error_handler(request: Request, exc: ACPError, *, status_code: int | None = None) -> JSONResponse:
34
34
  error = exc.error
35
35
  return JSONResponse(
36
- status_code=status_code or error_code_to_status_code(error.code), content=error.model_dump_json()
36
+ status_code=status_code or error_code_to_status_code(error.code), content=error.model_dump(mode="json")
37
37
  )
38
38
 
39
39
 
@@ -0,0 +1,63 @@
1
+ Metadata-Version: 2.4
2
+ Name: acp-sdk
3
+ Version: 0.4.0
4
+ Summary: Agent Communication Protocol SDK
5
+ Author: IBM Corp.
6
+ Maintainer-email: Tomas Pilar <thomas7pilar@gmail.com>
7
+ License-Expression: Apache-2.0
8
+ Requires-Python: <4.0,>=3.11
9
+ Requires-Dist: fastapi[standard]>=0.115.8
10
+ Requires-Dist: httpx-sse>=0.4.0
11
+ Requires-Dist: httpx>=0.28.1
12
+ Requires-Dist: janus>=2.0.0
13
+ Requires-Dist: opentelemetry-api>=1.31.1
14
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.31.1
15
+ Requires-Dist: opentelemetry-instrumentation-fastapi>=0.52b1
16
+ Requires-Dist: opentelemetry-instrumentation-httpx>=0.52b1
17
+ Requires-Dist: opentelemetry-sdk>=1.31.1
18
+ Requires-Dist: pydantic>=2.11.1
19
+ Description-Content-Type: text/markdown
20
+
21
+ # Agent Communication Protocol SDK for Python
22
+
23
+ Agent Communication Protocol SDK for Python provides allows developers to serve and consume agents over the Agent Communication Protocol.
24
+
25
+ ## Prerequisites
26
+
27
+ ✅ Python >= 3.11
28
+
29
+ ## Installation
30
+
31
+ Install with:
32
+
33
+ ```shell
34
+ pip install acp-sdk
35
+ ```
36
+
37
+ ## Quickstart
38
+
39
+ Register an agent and run the server:
40
+
41
+ ```py
42
+ server = Server()
43
+
44
+ @server.agent()
45
+ async def echo(inputs: list[Message]):
46
+ """Echoes everything"""
47
+ for message in inputs:
48
+ yield message
49
+
50
+ server.run(port=8000)
51
+ ```
52
+
53
+ From another process, connect to the server and run the agent:
54
+
55
+ ```py
56
+ async with Client(base_url="http://localhost:8000") as client:
57
+ run = await client.run_sync(agent="echo", inputs=[Message(parts=[MessagePart(content="Howdy!")])])
58
+ print(run)
59
+
60
+ ```
61
+
62
+
63
+ ➡️ Explore more in our [examples library](/examples/python).
@@ -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=J9hnaj5S8p4T3mlVb2iyGD1JuOw0R8JoKqBYDKeZXUw,5318
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=fGky5MIuknw-Gy-THqhWLt9I9-gUyNIar8qEAvZb3uQ,6195
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
16
- acp_sdk/server/errors.py,sha256=IGtpPpb2ChtYvCac8kf_P-RkcY71gBvX0yq97uZWa-w,2104
16
+ acp_sdk/server/errors.py,sha256=GSO8yYIqEeX8Y4Lz86ks35dMTHiQiXuOrLYYx0eXsbI,2110
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
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.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,,
23
+ acp_sdk-0.4.0.dist-info/METADATA,sha256=mkVdNgaCzH9x76Farbq9WTFf0ZFVFfPTVdPDsTGCMao,1546
24
+ acp_sdk-0.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
25
+ acp_sdk-0.4.0.dist-info/RECORD,,
@@ -1,99 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: acp-sdk
3
- Version: 0.3.2
4
- Summary: Agent Communication Protocol SDK
5
- Author: IBM Corp.
6
- Maintainer-email: Tomas Pilar <thomas7pilar@gmail.com>
7
- License-Expression: Apache-2.0
8
- Requires-Python: <4.0,>=3.11
9
- Requires-Dist: fastapi[standard]>=0.115.8
10
- Requires-Dist: httpx-sse>=0.4.0
11
- Requires-Dist: httpx>=0.28.1
12
- Requires-Dist: janus>=2.0.0
13
- Requires-Dist: opentelemetry-api>=1.31.1
14
- Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.31.1
15
- Requires-Dist: opentelemetry-instrumentation-fastapi>=0.52b1
16
- Requires-Dist: opentelemetry-instrumentation-httpx>=0.52b1
17
- Requires-Dist: opentelemetry-sdk>=1.31.1
18
- Requires-Dist: pydantic>=2.11.1
19
- Description-Content-Type: text/markdown
20
-
21
- # Agent Communication Protocol SDK for Python
22
-
23
- Agent Communication Protocol SDK for Python provides allows developers to serve and consume agents over the Agent Communication Protocol.
24
-
25
- ## Prerequisites
26
-
27
- ✅ Python >= 3.11
28
-
29
- ## Installation
30
-
31
- Install with:
32
-
33
- ```shell
34
- pip install acp-sdk
35
- ```
36
-
37
- ## Overview
38
-
39
- ### Core
40
-
41
- The core of the SDK exposes [pydantic](https://docs.pydantic.dev/) data models corresponding to REST API requests, responses, resources, events and errors.
42
-
43
-
44
- ### Client
45
-
46
- The `client` submodule exposes [httpx](https://www.python-httpx.org/) based client with simple methods for communication over ACP.
47
-
48
- ```python
49
- async with Client(base_url="http://localhost:8000") as client:
50
- run = await client.run_sync(agent="echo", inputs=[Message(parts=[MessagePart(content="Howdy!")])])
51
- print(run)
52
-
53
- ```
54
-
55
- ### Server
56
-
57
- The `server` submodule exposes `Agent` class and `agent` decorator together with [fastapi](https://fastapi.tiangolo.com/) application factory, making it easy to expose agents over ACP. Additionaly, it exposes [uvicorn](https://www.uvicorn.org/) based server to serve agents with set up logging, [opentelemetry](https://opentelemetry.io/) and more.
58
-
59
- ```python
60
- server = Server()
61
-
62
- @server.agent()
63
- async def echo(inputs: list[Message], context: Context) -> AsyncGenerator[RunYield, RunYieldResume]:
64
- """Echoes everything"""
65
- for message in inputs:
66
- yield {"thought": "I should echo everyting"}
67
- await asyncio.sleep(0.5)
68
- yield message
69
-
70
-
71
- server.run()
72
- ```
73
-
74
- ➡️ Explore more in our [examples library](/python/examples).
75
-
76
- ## Architecture
77
-
78
- The architecture of the SDK is outlined in the following segment. It focuses on central parts of the SDK without going into much detail.
79
-
80
- ### Models
81
-
82
- The core of the SDK contains pydantic models for requests, responses, resources, events and errors. Users of the SDK are meant to use these models directly or indirectly.
83
-
84
- ### Server
85
-
86
- The server module consists of 3 parts:
87
-
88
- 1. Agent interface
89
- 2. FastAPI application factory
90
- 3. Uvicorn based server
91
-
92
- Each part builds on top of the previous one. Not all parts need to be used, e.g. users are advised to bring their own ASGI server for production deployments.
93
-
94
- ### Client
95
-
96
- The client module consists of httpx based client with session support. The client is meant to be thin and mimic the REST API. Exception is session management which has been abstracted into a context manager.
97
-
98
-
99
-