acp-sdk 0.1.0rc5__py3-none-any.whl → 0.1.0rc6__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/server/server.py
CHANGED
@@ -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:
|
@@ -13,10 +13,10 @@ acp_sdk/server/bundle.py,sha256=ZVkIOwWfYgi-VyGYSMKr9WrG_WzYbej-LD-YPUWQdeg,4982
|
|
13
13
|
acp_sdk/server/context.py,sha256=MgnLV6qcDIhc_0BjW7r4Jj1tHts4ZuwpdTGIBnz2Mgo,1036
|
14
14
|
acp_sdk/server/errors.py,sha256=fWlgVsQ5hs_AXwzc-wvy6QgoDWEMRUBlSrfJfhHHMyE,2085
|
15
15
|
acp_sdk/server/logging.py,sha256=Oc8yZigCsuDnHHPsarRzu0RX3NKaLEgpELM2yovGKDI,411
|
16
|
-
acp_sdk/server/server.py,sha256=
|
16
|
+
acp_sdk/server/server.py,sha256=H-oh-cRpo9NR7_Mdt7ECRXrGnk8mfAAb7pp94XLGoAs,4637
|
17
17
|
acp_sdk/server/telemetry.py,sha256=EwmtUrWMYid7XHiX76V1J6CigJPa2NrzEPOX0fBoY3o,1838
|
18
18
|
acp_sdk/server/types.py,sha256=2yJPkfUzjVIhHmc0SegGTMqDROe2uFgycb-7CATvYVw,161
|
19
19
|
acp_sdk/server/utils.py,sha256=EfrF9VCyVk3AM_ao-BIB9EzGbfTrh4V2Bz-VFr6f6Sg,351
|
20
|
-
acp_sdk-0.1.
|
21
|
-
acp_sdk-0.1.
|
22
|
-
acp_sdk-0.1.
|
20
|
+
acp_sdk-0.1.0rc6.dist-info/METADATA,sha256=t5zWJsU-C67HQNzCFyo561s7epz4KQvsFjlqUIkF9xw,2147
|
21
|
+
acp_sdk-0.1.0rc6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
22
|
+
acp_sdk-0.1.0rc6.dist-info/RECORD,,
|
File without changes
|