acp-sdk 0.3.1__tar.gz → 0.3.2__tar.gz
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-0.3.1 → acp_sdk-0.3.2}/PKG-INFO +1 -1
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/examples/clients/advanced.py +1 -3
- acp_sdk-0.3.2/examples/clients/session.py +18 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/examples/clients/simple.py +1 -3
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/examples/clients/stream.py +1 -3
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/examples/servers/awaiting.py +3 -5
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/pyproject.toml +1 -1
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/models/models.py +32 -2
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/tests/e2e/test_suites/test_runs.py +1 -1
- acp_sdk-0.3.2/tests/unit/models/__init__.py +0 -0
- acp_sdk-0.3.2/tests/unit/models/test_models.py +37 -0
- acp_sdk-0.3.1/examples/clients/session.py +0 -22
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/.gitignore +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/.python-version +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/README.md +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/examples/servers/echo.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/examples/servers/standalone.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/pytest.ini +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/__init__.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/client/__init__.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/client/client.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/instrumentation.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/models/__init__.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/models/errors.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/models/schemas.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/py.typed +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/server/__init__.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/server/agent.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/server/app.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/server/bundle.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/server/context.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/server/errors.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/server/logging.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/server/server.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/server/session.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/server/telemetry.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/server/types.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/server/utils.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/src/acp_sdk/version.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/tests/conftest.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/tests/e2e/__init__.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/tests/e2e/config.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/tests/e2e/fixtures/__init__.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/tests/e2e/fixtures/client.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/tests/e2e/fixtures/server.py +0 -0
- {acp_sdk-0.3.1 → acp_sdk-0.3.2}/tests/e2e/test_suites/__init__.py +0 -0
@@ -13,9 +13,7 @@ async def example() -> None:
|
|
13
13
|
# Additional client configuration
|
14
14
|
)
|
15
15
|
) as client:
|
16
|
-
run = await client.run_sync(
|
17
|
-
agent="echo", inputs=[Message(parts=[MessagePart(content="Howdy!", content_type="text/plain")])]
|
18
|
-
)
|
16
|
+
run = await client.run_sync(agent="echo", inputs=[Message(parts=[MessagePart(content="Howdy!")])])
|
19
17
|
print(run)
|
20
18
|
|
21
19
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import asyncio
|
2
|
+
|
3
|
+
from acp_sdk.client import Client
|
4
|
+
from acp_sdk.models import (
|
5
|
+
Message,
|
6
|
+
MessagePart,
|
7
|
+
)
|
8
|
+
|
9
|
+
|
10
|
+
async def example() -> None:
|
11
|
+
async with Client(base_url="http://localhost:8000") as client, client.session() as session:
|
12
|
+
run = await session.run_sync(agent="echo", inputs=[Message(parts=[MessagePart(content="Howdy!")])])
|
13
|
+
run = await session.run_sync(agent="echo", inputs=[Message(parts=[MessagePart(content="Howdy again!")])])
|
14
|
+
print(run)
|
15
|
+
|
16
|
+
|
17
|
+
if __name__ == "__main__":
|
18
|
+
asyncio.run(example())
|
@@ -9,9 +9,7 @@ from acp_sdk.models import (
|
|
9
9
|
|
10
10
|
async def example() -> None:
|
11
11
|
async with Client(base_url="http://localhost:8000") as client:
|
12
|
-
run = await client.run_sync(
|
13
|
-
agent="echo", inputs=[Message(parts=[MessagePart(content="Howdy!", content_type="text/plain")])]
|
14
|
-
)
|
12
|
+
run = await client.run_sync(agent="echo", inputs=[Message(parts=[MessagePart(content="Howdy!")])])
|
15
13
|
print(run)
|
16
14
|
|
17
15
|
|
@@ -6,9 +6,7 @@ from acp_sdk.models import Message, MessagePart
|
|
6
6
|
|
7
7
|
async def example() -> None:
|
8
8
|
async with Client(base_url="http://localhost:8000") as client:
|
9
|
-
async for event in client.run_stream(
|
10
|
-
agent="echo", inputs=[Message(parts=[MessagePart(content="Howdy!", content_type="text/plain")])]
|
11
|
-
):
|
9
|
+
async for event in client.run_stream(agent="echo", inputs=[Message(parts=[MessagePart(content="Howdy!")])]):
|
12
10
|
print(event)
|
13
11
|
|
14
12
|
|
@@ -15,14 +15,12 @@ server = Server()
|
|
15
15
|
@server.agent()
|
16
16
|
async def awaiting(inputs: list[Message], context: Context) -> AsyncGenerator[RunYield, RunYieldResume]:
|
17
17
|
"""Greets and awaits for more data"""
|
18
|
-
yield MessagePart(content="Hello!"
|
18
|
+
yield MessagePart(content="Hello!")
|
19
19
|
resume = yield MessageAwaitRequest(
|
20
|
-
message=Message(
|
21
|
-
parts=[MessagePart(content="Can you provide me with additional configuration?", content_type="text/plain")]
|
22
|
-
)
|
20
|
+
message=Message(parts=[MessagePart(content="Can you provide me with additional configuration?")])
|
23
21
|
)
|
24
22
|
assert isinstance(resume, MessageAwaitResume)
|
25
|
-
yield MessagePart(content=f"Thanks for config: {resume.message}"
|
23
|
+
yield MessagePart(content=f"Thanks for config: {resume.message}")
|
26
24
|
|
27
25
|
|
28
26
|
server.run()
|
@@ -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
|
@@ -16,7 +16,7 @@ from acp_sdk.models import (
|
|
16
16
|
)
|
17
17
|
from acp_sdk.server import Server
|
18
18
|
|
19
|
-
inputs = [Message(parts=[MessagePart(content="Hello!"
|
19
|
+
inputs = [Message(parts=[MessagePart(content="Hello!")])]
|
20
20
|
await_resume = MessageAwaitResume(message=Message(parts=[]))
|
21
21
|
|
22
22
|
|
File without changes
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import pytest
|
2
|
+
from acp_sdk.models.models import Message, MessagePart
|
3
|
+
|
4
|
+
|
5
|
+
@pytest.mark.parametrize(
|
6
|
+
"uncompressed,compressed",
|
7
|
+
[
|
8
|
+
(
|
9
|
+
Message(
|
10
|
+
parts=[
|
11
|
+
MessagePart(content_type="text/plain", content="Foo"),
|
12
|
+
MessagePart(content_type="text/plain", content="Bar"),
|
13
|
+
]
|
14
|
+
),
|
15
|
+
Message(parts=[MessagePart(content_type="text/plain", content="FooBar")]),
|
16
|
+
),
|
17
|
+
(
|
18
|
+
Message(
|
19
|
+
parts=[
|
20
|
+
MessagePart(content_type="text/plain", content="Foo"),
|
21
|
+
MessagePart(content_type="text/html", content="<head>"),
|
22
|
+
MessagePart(content_type="text/plain", content="Foo"),
|
23
|
+
MessagePart(content_type="text/plain", content="Bar"),
|
24
|
+
]
|
25
|
+
),
|
26
|
+
Message(
|
27
|
+
parts=[
|
28
|
+
MessagePart(content_type="text/plain", content="Foo"),
|
29
|
+
MessagePart(content_type="text/html", content="<head>"),
|
30
|
+
MessagePart(content_type="text/plain", content="FooBar"),
|
31
|
+
]
|
32
|
+
),
|
33
|
+
),
|
34
|
+
],
|
35
|
+
)
|
36
|
+
def test_message_compress(uncompressed: Message, compressed: Message) -> None:
|
37
|
+
assert uncompressed.compress() == compressed
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import asyncio
|
2
|
-
|
3
|
-
from acp_sdk.client import Client
|
4
|
-
from acp_sdk.models import (
|
5
|
-
Message,
|
6
|
-
MessagePart,
|
7
|
-
)
|
8
|
-
|
9
|
-
|
10
|
-
async def example() -> None:
|
11
|
-
async with Client(base_url="http://localhost:8000") as client, client.session() as session:
|
12
|
-
run = await session.run_sync(
|
13
|
-
agent="echo", inputs=[Message(parts=[MessagePart(content="Howdy!", content_type="text/plain")])]
|
14
|
-
)
|
15
|
-
run = await session.run_sync(
|
16
|
-
agent="echo", inputs=[Message(parts=[MessagePart(content="Howdy again!", content_type="text/plain")])]
|
17
|
-
)
|
18
|
-
print(run)
|
19
|
-
|
20
|
-
|
21
|
-
if __name__ == "__main__":
|
22
|
-
asyncio.run(example())
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|