acp-sdk 0.1.0rc5__tar.gz → 0.1.0rc6__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.1.0rc5 → acp_sdk-0.1.0rc6}/PKG-INFO +1 -1
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/examples/servers/awaiting.py +1 -1
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/examples/servers/echo.py +1 -1
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/examples/servers/multi-echo.py +4 -6
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/pyproject.toml +1 -1
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/server.py +17 -15
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/.gitignore +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/.python-version +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/README.md +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/examples/clients/advanced.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/examples/clients/simple.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/examples/clients/stream.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/__init__.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/client/__init__.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/client/client.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/models/__init__.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/models/errors.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/models/models.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/models/schemas.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/py.typed +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/__init__.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/agent.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/app.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/bundle.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/context.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/errors.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/logging.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/telemetry.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/types.py +0 -0
- {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/utils.py +0 -0
@@ -5,13 +5,11 @@ from acp_sdk.models import (
|
|
5
5
|
)
|
6
6
|
from acp_sdk.server import Agent, Context, RunYield, RunYieldResume, Server
|
7
7
|
|
8
|
-
# This example showcases several ways to create echo agent using decoratos.
|
9
|
-
|
10
8
|
server = Server()
|
11
9
|
|
12
10
|
|
13
11
|
@server.agent()
|
14
|
-
async def async_gen_echo(input: Message
|
12
|
+
async def async_gen_echo(input: Message) -> AsyncGenerator[RunYield, RunYieldResume]:
|
15
13
|
"""Echoes everything"""
|
16
14
|
yield {"thought": "I should echo everyting"}
|
17
15
|
yield input
|
@@ -25,7 +23,7 @@ async def async_echo(input: Message, context: Context) -> RunYield:
|
|
25
23
|
|
26
24
|
|
27
25
|
@server.agent()
|
28
|
-
def gen_echo(input: Message
|
26
|
+
def gen_echo(input: Message) -> Generator[RunYield, RunYieldResume]:
|
29
27
|
"""Echoes everything"""
|
30
28
|
yield {"thought": "I should echo everyting"}
|
31
29
|
return input
|
@@ -41,7 +39,7 @@ def sync_echo(input: Message, context: Context) -> RunYield:
|
|
41
39
|
class EchoAgent(Agent):
|
42
40
|
@property
|
43
41
|
def name(self) -> str:
|
44
|
-
return "
|
42
|
+
return "instance_echo"
|
45
43
|
|
46
44
|
@property
|
47
45
|
def description(self) -> str:
|
@@ -56,4 +54,4 @@ class EchoAgent(Agent):
|
|
56
54
|
server.register(EchoAgent())
|
57
55
|
|
58
56
|
|
59
|
-
server
|
57
|
+
server()
|
@@ -19,19 +19,17 @@ class Server:
|
|
19
19
|
"""Decorator to register an agent."""
|
20
20
|
|
21
21
|
def decorator(fn: Callable) -> Callable:
|
22
|
-
# check agent's function signature
|
23
22
|
signature = inspect.signature(fn)
|
24
23
|
parameters = list(signature.parameters.values())
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
raise TypeError("The agent function must have one 'input' argument and one 'context' argument")
|
25
|
+
if len(parameters) == 0:
|
26
|
+
raise TypeError("The agent function must have at least 'input' argument")
|
27
|
+
if len(parameters) > 2:
|
28
|
+
raise TypeError("The agent function must have only 'input' and 'context' arguments")
|
29
|
+
if len(parameters) == 2 and parameters[1].name != "context":
|
30
|
+
raise TypeError("The second argument of the agent function must be 'context'")
|
31
|
+
|
32
|
+
has_context_param = len(parameters) == 2
|
35
33
|
|
36
34
|
agent: Agent
|
37
35
|
if inspect.isasyncgenfunction(fn):
|
@@ -47,7 +45,9 @@ class Server:
|
|
47
45
|
|
48
46
|
async def run(self, input: Message, context: Context) -> AsyncGenerator[RunYield, RunYieldResume]:
|
49
47
|
try:
|
50
|
-
gen: AsyncGenerator[RunYield, RunYieldResume] =
|
48
|
+
gen: AsyncGenerator[RunYield, RunYieldResume] = (
|
49
|
+
fn(input, context) if has_context_param else fn(input)
|
50
|
+
)
|
51
51
|
value = None
|
52
52
|
while True:
|
53
53
|
value = yield await gen.asend(value)
|
@@ -67,7 +67,7 @@ class Server:
|
|
67
67
|
return description or fn.__doc__ or ""
|
68
68
|
|
69
69
|
async def run(self, input: Message, context: Context) -> Coroutine[RunYield]:
|
70
|
-
return await fn(input, context)
|
70
|
+
return await (fn(input, context) if has_context_param else fn(input))
|
71
71
|
|
72
72
|
agent = DecoratedAgent()
|
73
73
|
elif inspect.isgeneratorfunction(fn):
|
@@ -82,7 +82,7 @@ class Server:
|
|
82
82
|
return description or fn.__doc__ or ""
|
83
83
|
|
84
84
|
def run(self, input: Message, context: Context) -> Generator[RunYield, RunYieldResume]:
|
85
|
-
yield from fn(input, context)
|
85
|
+
yield from (fn(input, context) if has_context_param else fn(input))
|
86
86
|
|
87
87
|
agent = DecoratedAgent()
|
88
88
|
else:
|
@@ -97,7 +97,7 @@ class Server:
|
|
97
97
|
return description or fn.__doc__ or ""
|
98
98
|
|
99
99
|
def run(self, input: Message, context: Context) -> RunYield:
|
100
|
-
return fn(input, context)
|
100
|
+
return fn(input, context) if has_context_param else fn(input)
|
101
101
|
|
102
102
|
agent = DecoratedAgent()
|
103
103
|
|
@@ -109,7 +109,9 @@ class Server:
|
|
109
109
|
def register(self, *agents: Agent) -> None:
|
110
110
|
self.agents.extend(agents)
|
111
111
|
|
112
|
-
def
|
112
|
+
def __call__(
|
113
|
+
self, configure_logger: bool = True, configure_telemetry: bool = False, **kwargs: dict[str, Any]
|
114
|
+
) -> None:
|
113
115
|
import uvicorn
|
114
116
|
|
115
117
|
if configure_logger:
|
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
|