Skip to content

Commit 2febfed

Browse files
msardaramicpapalkeraron
authored
doc(SLIM): slimrpc, slima2a and slimrpc-compiler (#228)
* doc(SLIM): slimrpc, slima2a and slimrpc-compiler Signed-off-by: Mauro Sardara <msardara@cisco.com> * doc(SLIM): fix broken links Signed-off-by: Mauro Sardara <msardara@cisco.com> * doc(SLIM): fix slimrpc Signed-off-by: Mauro Sardara <msardara@cisco.com> * doc(SLIM): fix slimrpc Signed-off-by: Mauro Sardara <msardara@cisco.com> * doc(SLIM): fix slimrpc Signed-off-by: Mauro Sardara <msardara@cisco.com> * docs: fixes Signed-off-by: Michele Papalini <micpapal@cisco.com> * doc(SLIM): fix slimrpc-compiler Signed-off-by: Mauro Sardara <msardara@cisco.com> * doc(SLIM): fix slimrpc-compiler Signed-off-by: Mauro Sardara <msardara@cisco.com> * doc(SLIM): fix slima2a Signed-off-by: Mauro Sardara <msardara@cisco.com> * doc(SLIM): fix slimrpc Signed-off-by: Mauro Sardara <msardara@cisco.com> * docs(SLIM): integrations menu Signed-off-by: Michele Papalini <micpapal@cisco.com> * doc(SLIM): index Signed-off-by: Mauro Sardara <msardara@cisco.com> * doc(SLIM): index Signed-off-by: Mauro Sardara <msardara@cisco.com> * docs (SLIM): fix list in a2a Signed-off-by: Michele Papalini <micpapal@cisco.com> * chore: formatting and minor edits Signed-off-by: Aron Kerekes <arkereke@cisco.com> * fix: fix review comment Signed-off-by: Michele Papalini <micpapal@cisco.com> --------- Signed-off-by: Mauro Sardara <msardara@cisco.com> Signed-off-by: Michele Papalini <micpapal@cisco.com> Signed-off-by: Aron Kerekes <arkereke@cisco.com> Co-authored-by: Michele Papalini <micpapal@cisco.com> Co-authored-by: Aron Kerekes <arkereke@cisco.com>
1 parent 6eb986e commit 2febfed

4 files changed

Lines changed: 955 additions & 1 deletion

File tree

docs/messaging/.index

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,10 @@ nav:
77
- SLIM Controller: slim-controller.md
88
- SLIM Group Management: slim-group.md
99
- SLIM Group Communication Tutorial: slim-group-tutorial.md
10-
- SLIM and MCP Integration: slim-mcp.md
10+
- SLIM Integrations:
11+
- SLIMRPC:
12+
- Overview: slim-rpc.md
13+
- Protoc Plugin: slim-slimrpc-compiler.md
14+
- SLIMA2A: slim-a2a.md
15+
- MCP over SLIM: slim-mcp.md
16+

docs/messaging/slim-a2a.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# SLIM A2A
2+
3+
SLIM A2A is a native integration of A2A built on top of SLIM. It utilizes SLIMRPC (SLIM Remote Procedure Call) and the SLIMRPC compiler to compile A2A protobuf file and generate the necessary code to enable A2A functionality on SLIM.
4+
5+
## What is SLIMRPC and SLIMRCP compiler
6+
7+
SLIMRPC is a framework that enables Protocol Buffers (protobuf) Remote Procedure Calls (RPC) over SLIM. This is similar to gRPC, which uses HTTP/2 as its transport layer for protobuf-based RPC. More information can be found [here](./slim-rpc.md)
8+
9+
To compile a protobuf file and generate the clients and service stub you can use the [SLIMRPC compiler](./slim-slimrpc-compiler.md). This works in a similar way to the protoc compiler.
10+
11+
For SLIM A2A we compiled the [a2a.proto](https://github.com/a2aproject/A2A/blob/main/specification/grpc/a2a.proto) file using the SLIM RPC compiler. The generated code is in [a2a_pb2_slimrpc.py](https://github.com/agntcy/slim/blob/main/data-plane/python/integrations/slima2a/slima2a/types/a2a_pb2_slimrpc.py).
12+
13+
## How to use SLIMA2A
14+
15+
Using SLIMA2A is very similar to using the standard A2A implementation. As a reference example here we use the [travel planner agent](https://github.com/a2aproject/a2a-samples/tree/main/samples/python/agents/travel_planner_agent) available on the A2A samples repository. The version adapted to use SLIM A2A can be found in [travel_planner_agent](https://github.com/agntcy/slim/tree/main/data-plane/python/integrations/slima2a/examples/travel_planner_agent) folder. In the following section, we highlight and explain the key difference between the standard and SLIM A2A implementations.
16+
17+
### Travel Planner: Server
18+
19+
In this section we highlight the main differences between the SLIM A2A [server](https://github.com/agntcy/slim/blob/main/data-plane/python/integrations/slima2a/examples/travel_planner_agent/server.py) implementation with respect to the original implementation in the A2A repository.
20+
21+
22+
1. Import the SLIMRPC package.
23+
```python
24+
import slimrpc
25+
```
26+
2. Create the SLIMRPCHandler. Notice that the definitions for `AgentCard` and `DefaultRequestHandler` remain unchanged from the original A2A example.
27+
```python
28+
agent_card = AgentCard(
29+
name="travel planner Agent",
30+
description="travel planner",
31+
url="http://localhost:10001/",
32+
version="1.0.0",
33+
default_input_modes=["text"],
34+
default_output_modes=["text"],
35+
capabilities=AgentCapabilities(streaming=True),
36+
skills=[skill],
37+
)
38+
request_handler = DefaultRequestHandler(
39+
agent_executor=TravelPlannerAgentExecutor(),
40+
task_store=InMemoryTaskStore(),
41+
)
42+
servicer = SLIMRPCHandler(agent_card, request_handler)
43+
```
44+
3. Setup the `slimrpc.Server`. This is the only place where you need to setup few parameters that are specific to SLIM.
45+
```python
46+
server = slimrpc.Server(
47+
local="agntcy/demo/travel_planner_agent",
48+
slim={
49+
"endpoint": "http://localhost:46357",
50+
"tls": {
51+
"insecure": True,
52+
},
53+
},
54+
shared_secret="secret",
55+
)
56+
```
57+
- local: Name of the local application.
58+
- slim: Dictionary specifying how to connect to the SLIM node.
59+
- shared_secret: Used to set up MLS (Message Layer Security).
60+
For more information about these settings, see the [SLIMRPC](./slim-rpc.md).
61+
4. Register the Service.
62+
```python
63+
add_A2AServiceServicer_to_server(
64+
servicer,
65+
server,
66+
)
67+
```
68+
69+
Your A2A server is now ready to run on SLIM.
70+
71+
### Travel Planner: Client
72+
73+
These are the main differences between the [client](https://github.com/agntcy/slim/blob/main/data-plane/python/integrations/slima2a/examples/travel_planner_agent/client.py) using SLIM A2A and the standard one.
74+
75+
1. Create a channel. This requires a configuration that is similar to the server
76+
```python
77+
def channel_factory(topic: str) -> slimrpc.Channel:
78+
channel = slimrpc.Channel(
79+
local="agntcy/demo/client",
80+
remote=topic,
81+
slim={
82+
"endpoint": "http://localhost:46357",
83+
"tls": {
84+
"insecure": True,
85+
},
86+
},
87+
shared_secret="secret",
88+
)
89+
return channel
90+
```
91+
2. Add SLIM RPC in the supported transports.
92+
```python
93+
client_config = ClientConfig(
94+
supported_transports=["JSONRPC", "slimrpc"],
95+
streaming=True,
96+
httpx_client=httpx_client,
97+
slimrpc_channel_factory=channel_factory,
98+
)
99+
client_factory = ClientFactory(client_config)
100+
client_factory.register("slimrpc", SLIMRPCTransport.create)
101+
agent_card = minimal_agent_card("agntcy/demo/travel_planner_agent", ["slimrpc"])
102+
client = client_factory.create(card=agent_card)
103+
```

0 commit comments

Comments
 (0)