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.
Files changed (30) hide show
  1. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/PKG-INFO +1 -1
  2. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/examples/servers/awaiting.py +1 -1
  3. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/examples/servers/echo.py +1 -1
  4. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/examples/servers/multi-echo.py +4 -6
  5. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/pyproject.toml +1 -1
  6. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/server.py +17 -15
  7. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/.gitignore +0 -0
  8. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/.python-version +0 -0
  9. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/README.md +0 -0
  10. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/examples/clients/advanced.py +0 -0
  11. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/examples/clients/simple.py +0 -0
  12. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/examples/clients/stream.py +0 -0
  13. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/__init__.py +0 -0
  14. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/client/__init__.py +0 -0
  15. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/client/client.py +0 -0
  16. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/models/__init__.py +0 -0
  17. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/models/errors.py +0 -0
  18. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/models/models.py +0 -0
  19. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/models/schemas.py +0 -0
  20. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/py.typed +0 -0
  21. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/__init__.py +0 -0
  22. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/agent.py +0 -0
  23. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/app.py +0 -0
  24. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/bundle.py +0 -0
  25. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/context.py +0 -0
  26. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/errors.py +0 -0
  27. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/logging.py +0 -0
  28. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/telemetry.py +0 -0
  29. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/types.py +0 -0
  30. {acp_sdk-0.1.0rc5 → acp_sdk-0.1.0rc6}/src/acp_sdk/server/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: acp-sdk
3
- Version: 0.1.0rc5
3
+ Version: 0.1.0rc6
4
4
  Summary: Agent Communication Protocol SDK
5
5
  Requires-Python: <4.0,>=3.11
6
6
  Requires-Dist: opentelemetry-api>=1.31.1
@@ -20,4 +20,4 @@ async def awaiting(input: Message, context: Context) -> AsyncGenerator[Message |
20
20
  yield Message(TextMessagePart(content=f"Thanks for {data}"))
21
21
 
22
22
 
23
- server.run()
23
+ server()
@@ -19,4 +19,4 @@ async def echo(input: Message, context: Context) -> AsyncGenerator[RunYield, Run
19
19
  yield Message(part)
20
20
 
21
21
 
22
- server.run()
22
+ server()
@@ -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, context: Context) -> AsyncGenerator[RunYield, RunYieldResume]:
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, context: Context) -> Generator[RunYield, RunYieldResume]:
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 "class_echo"
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.run()
57
+ server()
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "acp-sdk"
3
- version = "0.1.0rc5"
3
+ version = "0.1.0rc6"
4
4
  description = "Agent Communication Protocol SDK"
5
5
  readme = "README.md"
6
6
  authors = []
@@ -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
- # validate agent's function
27
- if inspect.isasyncgenfunction(fn):
28
- if len(parameters) != 2:
29
- raise TypeError(
30
- "The agent generator function must have one 'input' argument and one 'context' argument"
31
- )
32
- else:
33
- if len(parameters) != 2:
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] = fn(input, context)
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 run(self, configure_logger: bool = True, configure_telemetry: bool = False, **kwargs: dict[str, Any]) -> None:
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