From 44b9bff466f3becc5b1b6741f76badf507243623 Mon Sep 17 00:00:00 2001 From: Jack Gerrits Date: Thu, 23 Jan 2025 17:46:47 -0500 Subject: [PATCH] Update proto to include remove sub, move to rpc based operations (#5168) * Update proto to include remove sub, move to rpc based operations * dont add a breaking change * mypy fix --- protos/agent_worker.proto | 31 +++- .../autogen_core/_type_prefix_subscription.py | 4 +- .../src/autogen_core/_type_subscription.py | 4 +- .../runtimes/grpc/_worker_runtime.py | 10 +- .../grpc/_worker_runtime_host_servicer.py | 41 +++++- .../runtimes/grpc/protos/agent_worker_pb2.py | 40 +++--- .../runtimes/grpc/protos/agent_worker_pb2.pyi | 70 +++++++++- .../grpc/protos/agent_worker_pb2_grpc.py | 132 ++++++++++++++++++ .../grpc/protos/agent_worker_pb2_grpc.pyi | 68 +++++++++ 9 files changed, 368 insertions(+), 32 deletions(-) diff --git a/protos/agent_worker.proto b/protos/agent_worker.proto index 7e658699b47..0cf1581aff3 100644 --- a/protos/agent_worker.proto +++ b/protos/agent_worker.proto @@ -48,12 +48,12 @@ message Event { } message RegisterAgentTypeRequest { - string request_id = 1; + string request_id = 1; // TODO: remove once message based requests are removed string type = 2; } message RegisterAgentTypeResponse { - string request_id = 1; + string request_id = 1; // TODO: remove once message based requests are removed bool success = 2; optional string error = 3; } @@ -69,27 +69,46 @@ message TypePrefixSubscription { } message Subscription { + string id = 1; oneof subscription { - TypeSubscription typeSubscription = 1; - TypePrefixSubscription typePrefixSubscription = 2; + TypeSubscription typeSubscription = 2; + TypePrefixSubscription typePrefixSubscription = 3; } } message AddSubscriptionRequest { - string request_id = 1; + string request_id = 1; // TODO: remove once message based requests are removed Subscription subscription = 2; } message AddSubscriptionResponse { - string request_id = 1; + string request_id = 1; // TODO: remove once message based requests are removed bool success = 2; optional string error = 3; } +message RemoveSubscriptionRequest { + string id = 1; +} + +message RemoveSubscriptionResponse { + bool success = 1; + optional string error = 2; +} + +message GetSubscriptionsRequest {} +message GetSubscriptionsResponse { + repeated Subscription subscriptions = 1; +} + service AgentRpc { rpc OpenChannel (stream Message) returns (stream Message); rpc GetState(AgentId) returns (GetStateResponse); rpc SaveState(AgentState) returns (SaveStateResponse); + rpc RegisterAgent(RegisterAgentTypeRequest) returns (RegisterAgentTypeResponse); + rpc AddSubscription(AddSubscriptionRequest) returns (AddSubscriptionResponse); + rpc RemoveSubscription(RemoveSubscriptionRequest) returns (RemoveSubscriptionResponse); + rpc GetSubscriptions(GetSubscriptionsRequest) returns (GetSubscriptionsResponse); } message AgentState { diff --git a/python/packages/autogen-core/src/autogen_core/_type_prefix_subscription.py b/python/packages/autogen-core/src/autogen_core/_type_prefix_subscription.py index 9e0d5268398..1c458ed296a 100644 --- a/python/packages/autogen-core/src/autogen_core/_type_prefix_subscription.py +++ b/python/packages/autogen-core/src/autogen_core/_type_prefix_subscription.py @@ -31,13 +31,13 @@ class TypePrefixSubscription(Subscription): agent_type (str): Agent type to handle this subscription """ - def __init__(self, topic_type_prefix: str, agent_type: str | AgentType): + def __init__(self, topic_type_prefix: str, agent_type: str | AgentType, id: str | None = None): self._topic_type_prefix = topic_type_prefix if isinstance(agent_type, AgentType): self._agent_type = agent_type.type else: self._agent_type = agent_type - self._id = str(uuid.uuid4()) + self._id = id or str(uuid.uuid4()) @property def id(self) -> str: diff --git a/python/packages/autogen-core/src/autogen_core/_type_subscription.py b/python/packages/autogen-core/src/autogen_core/_type_subscription.py index 14d599b5630..0fc2a62ebe8 100644 --- a/python/packages/autogen-core/src/autogen_core/_type_subscription.py +++ b/python/packages/autogen-core/src/autogen_core/_type_subscription.py @@ -30,13 +30,13 @@ class TypeSubscription(Subscription): agent_type (str): Agent type to handle this subscription """ - def __init__(self, topic_type: str, agent_type: str | AgentType): + def __init__(self, topic_type: str, agent_type: str | AgentType, id: str | None = None): self._topic_type = topic_type if isinstance(agent_type, AgentType): self._agent_type = agent_type.type else: self._agent_type = agent_type - self._id = str(uuid.uuid4()) + self._id = id or str(uuid.uuid4()) @property def id(self) -> str: diff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py index e764b064419..21ec832c7b3 100644 --- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py +++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py @@ -807,25 +807,27 @@ async def add_subscription(self, subscription: Subscription) -> None: request_id = await self._get_new_request_id() match subscription: - case TypeSubscription(topic_type=topic_type, agent_type=agent_type): + case TypeSubscription(topic_type=topic_type, agent_type=agent_type, id=id): message = agent_worker_pb2.Message( addSubscriptionRequest=agent_worker_pb2.AddSubscriptionRequest( request_id=request_id, subscription=agent_worker_pb2.Subscription( + id=id, typeSubscription=agent_worker_pb2.TypeSubscription( topic_type=topic_type, agent_type=agent_type - ) + ), ), ) ) - case TypePrefixSubscription(topic_type_prefix=topic_type_prefix, agent_type=agent_type): + case TypePrefixSubscription(topic_type_prefix=topic_type_prefix, agent_type=agent_type, id=id): message = agent_worker_pb2.Message( addSubscriptionRequest=agent_worker_pb2.AddSubscriptionRequest( request_id=request_id, subscription=agent_worker_pb2.Subscription( + id=id, typePrefixSubscription=agent_worker_pb2.TypePrefixSubscription( topic_type_prefix=topic_type_prefix, agent_type=agent_type - ) + ), ), ) ) diff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime_host_servicer.py b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime_host_servicer.py index 0bb8ae0a8a2..3e1831abf71 100644 --- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime_host_servicer.py +++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime_host_servicer.py @@ -227,7 +227,9 @@ async def _process_add_subscription_request( add_subscription_req.subscription.typeSubscription ) subscription = TypeSubscription( - topic_type=type_subscription_msg.topic_type, agent_type=type_subscription_msg.agent_type + topic_type=type_subscription_msg.topic_type, + agent_type=type_subscription_msg.agent_type, + id=add_subscription_req.subscription.id, ) case "typePrefixSubscription": @@ -237,6 +239,7 @@ async def _process_add_subscription_request( subscription = TypePrefixSubscription( topic_type_prefix=type_prefix_subscription_msg.topic_type_prefix, agent_type=type_prefix_subscription_msg.agent_type, + id=add_subscription_req.subscription.id, ) case None: logger.warning("Received empty subscription message") @@ -260,6 +263,42 @@ async def _process_add_subscription_request( ) ) + def RegisterAgent( # type: ignore + self, + request: agent_worker_pb2.RegisterAgentTypeRequest, + context: grpc.aio.ServicerContext[ + agent_worker_pb2.RegisterAgentTypeRequest, agent_worker_pb2.RegisterAgentTypeResponse + ], + ) -> agent_worker_pb2.RegisterAgentTypeResponse: + raise NotImplementedError("Method not implemented.") + + def AddSubscription( # type: ignore + self, + request: agent_worker_pb2.AddSubscriptionRequest, + context: grpc.aio.ServicerContext[ + agent_worker_pb2.AddSubscriptionRequest, agent_worker_pb2.AddSubscriptionResponse + ], + ) -> agent_worker_pb2.AddSubscriptionResponse: + raise NotImplementedError("Method not implemented.") + + def RemoveSubscription( # type: ignore + self, + request: agent_worker_pb2.RemoveSubscriptionRequest, + context: grpc.aio.ServicerContext[ + agent_worker_pb2.RemoveSubscriptionRequest, agent_worker_pb2.RemoveSubscriptionResponse + ], + ) -> agent_worker_pb2.RemoveSubscriptionResponse: + raise NotImplementedError("Method not implemented.") + + def GetSubscriptions( # type: ignore + self, + request: agent_worker_pb2.GetSubscriptionsRequest, + context: grpc.aio.ServicerContext[ + agent_worker_pb2.GetSubscriptionsRequest, agent_worker_pb2.GetSubscriptionsResponse + ], + ) -> agent_worker_pb2.GetSubscriptionsResponse: + raise NotImplementedError("Method not implemented.") + async def GetState( # type: ignore self, request: agent_worker_pb2.AgentId, diff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.py b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.py index b4794f1eaba..8744a04a602 100644 --- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.py +++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.py @@ -16,7 +16,7 @@ from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12\x61gent_worker.proto\x12\x06\x61gents\x1a\x10\x63loudevent.proto\x1a\x19google/protobuf/any.proto\"\'\n\x07TopicId\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x0e\n\x06source\x18\x02 \x01(\t\"$\n\x07\x41gentId\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x0b\n\x03key\x18\x02 \x01(\t\"E\n\x07Payload\x12\x11\n\tdata_type\x18\x01 \x01(\t\x12\x19\n\x11\x64\x61ta_content_type\x18\x02 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\"\x89\x02\n\nRpcRequest\x12\x12\n\nrequest_id\x18\x01 \x01(\t\x12$\n\x06source\x18\x02 \x01(\x0b\x32\x0f.agents.AgentIdH\x00\x88\x01\x01\x12\x1f\n\x06target\x18\x03 \x01(\x0b\x32\x0f.agents.AgentId\x12\x0e\n\x06method\x18\x04 \x01(\t\x12 \n\x07payload\x18\x05 \x01(\x0b\x32\x0f.agents.Payload\x12\x32\n\x08metadata\x18\x06 \x03(\x0b\x32 .agents.RpcRequest.MetadataEntry\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\x42\t\n\x07_source\"\xb8\x01\n\x0bRpcResponse\x12\x12\n\nrequest_id\x18\x01 \x01(\t\x12 \n\x07payload\x18\x02 \x01(\x0b\x32\x0f.agents.Payload\x12\r\n\x05\x65rror\x18\x03 \x01(\t\x12\x33\n\x08metadata\x18\x04 \x03(\x0b\x32!.agents.RpcResponse.MetadataEntry\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\xe4\x01\n\x05\x45vent\x12\x12\n\ntopic_type\x18\x01 \x01(\t\x12\x14\n\x0ctopic_source\x18\x02 \x01(\t\x12$\n\x06source\x18\x03 \x01(\x0b\x32\x0f.agents.AgentIdH\x00\x88\x01\x01\x12 \n\x07payload\x18\x04 \x01(\x0b\x32\x0f.agents.Payload\x12-\n\x08metadata\x18\x05 \x03(\x0b\x32\x1b.agents.Event.MetadataEntry\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\x42\t\n\x07_source\"<\n\x18RegisterAgentTypeRequest\x12\x12\n\nrequest_id\x18\x01 \x01(\t\x12\x0c\n\x04type\x18\x02 \x01(\t\"^\n\x19RegisterAgentTypeResponse\x12\x12\n\nrequest_id\x18\x01 \x01(\t\x12\x0f\n\x07success\x18\x02 \x01(\x08\x12\x12\n\x05\x65rror\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x08\n\x06_error\":\n\x10TypeSubscription\x12\x12\n\ntopic_type\x18\x01 \x01(\t\x12\x12\n\nagent_type\x18\x02 \x01(\t\"G\n\x16TypePrefixSubscription\x12\x19\n\x11topic_type_prefix\x18\x01 \x01(\t\x12\x12\n\nagent_type\x18\x02 \x01(\t\"\x96\x01\n\x0cSubscription\x12\x34\n\x10typeSubscription\x18\x01 \x01(\x0b\x32\x18.agents.TypeSubscriptionH\x00\x12@\n\x16typePrefixSubscription\x18\x02 \x01(\x0b\x32\x1e.agents.TypePrefixSubscriptionH\x00\x42\x0e\n\x0csubscription\"X\n\x16\x41\x64\x64SubscriptionRequest\x12\x12\n\nrequest_id\x18\x01 \x01(\t\x12*\n\x0csubscription\x18\x02 \x01(\x0b\x32\x14.agents.Subscription\"\\\n\x17\x41\x64\x64SubscriptionResponse\x12\x12\n\nrequest_id\x18\x01 \x01(\t\x12\x0f\n\x07success\x18\x02 \x01(\x08\x12\x12\n\x05\x65rror\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x08\n\x06_error\"\x9d\x01\n\nAgentState\x12!\n\x08\x61gent_id\x18\x01 \x01(\x0b\x32\x0f.agents.AgentId\x12\x0c\n\x04\x65Tag\x18\x02 \x01(\t\x12\x15\n\x0b\x62inary_data\x18\x03 \x01(\x0cH\x00\x12\x13\n\ttext_data\x18\x04 \x01(\tH\x00\x12*\n\nproto_data\x18\x05 \x01(\x0b\x32\x14.google.protobuf.AnyH\x00\x42\x06\n\x04\x64\x61ta\"j\n\x10GetStateResponse\x12\'\n\x0b\x61gent_state\x18\x01 \x01(\x0b\x32\x12.agents.AgentState\x12\x0f\n\x07success\x18\x02 \x01(\x08\x12\x12\n\x05\x65rror\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x08\n\x06_error\"B\n\x11SaveStateResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\x12\n\x05\x65rror\x18\x02 \x01(\tH\x00\x88\x01\x01\x42\x08\n\x06_error\"\xad\x03\n\x07Message\x12%\n\x07request\x18\x01 \x01(\x0b\x32\x12.agents.RpcRequestH\x00\x12\'\n\x08response\x18\x02 \x01(\x0b\x32\x13.agents.RpcResponseH\x00\x12\x33\n\ncloudEvent\x18\x03 \x01(\x0b\x32\x1d.io.cloudevents.v1.CloudEventH\x00\x12\x44\n\x18registerAgentTypeRequest\x18\x04 \x01(\x0b\x32 .agents.RegisterAgentTypeRequestH\x00\x12\x46\n\x19registerAgentTypeResponse\x18\x05 \x01(\x0b\x32!.agents.RegisterAgentTypeResponseH\x00\x12@\n\x16\x61\x64\x64SubscriptionRequest\x18\x06 \x01(\x0b\x32\x1e.agents.AddSubscriptionRequestH\x00\x12\x42\n\x17\x61\x64\x64SubscriptionResponse\x18\x07 \x01(\x0b\x32\x1f.agents.AddSubscriptionResponseH\x00\x42\t\n\x07message2\xb2\x01\n\x08\x41gentRpc\x12\x33\n\x0bOpenChannel\x12\x0f.agents.Message\x1a\x0f.agents.Message(\x01\x30\x01\x12\x35\n\x08GetState\x12\x0f.agents.AgentId\x1a\x18.agents.GetStateResponse\x12:\n\tSaveState\x12\x12.agents.AgentState\x1a\x19.agents.SaveStateResponseB\x1e\xaa\x02\x1bMicrosoft.AutoGen.Contractsb\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12\x61gent_worker.proto\x12\x06\x61gents\x1a\x10\x63loudevent.proto\x1a\x19google/protobuf/any.proto\"\'\n\x07TopicId\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x0e\n\x06source\x18\x02 \x01(\t\"$\n\x07\x41gentId\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x0b\n\x03key\x18\x02 \x01(\t\"E\n\x07Payload\x12\x11\n\tdata_type\x18\x01 \x01(\t\x12\x19\n\x11\x64\x61ta_content_type\x18\x02 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\"\x89\x02\n\nRpcRequest\x12\x12\n\nrequest_id\x18\x01 \x01(\t\x12$\n\x06source\x18\x02 \x01(\x0b\x32\x0f.agents.AgentIdH\x00\x88\x01\x01\x12\x1f\n\x06target\x18\x03 \x01(\x0b\x32\x0f.agents.AgentId\x12\x0e\n\x06method\x18\x04 \x01(\t\x12 \n\x07payload\x18\x05 \x01(\x0b\x32\x0f.agents.Payload\x12\x32\n\x08metadata\x18\x06 \x03(\x0b\x32 .agents.RpcRequest.MetadataEntry\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\x42\t\n\x07_source\"\xb8\x01\n\x0bRpcResponse\x12\x12\n\nrequest_id\x18\x01 \x01(\t\x12 \n\x07payload\x18\x02 \x01(\x0b\x32\x0f.agents.Payload\x12\r\n\x05\x65rror\x18\x03 \x01(\t\x12\x33\n\x08metadata\x18\x04 \x03(\x0b\x32!.agents.RpcResponse.MetadataEntry\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\xe4\x01\n\x05\x45vent\x12\x12\n\ntopic_type\x18\x01 \x01(\t\x12\x14\n\x0ctopic_source\x18\x02 \x01(\t\x12$\n\x06source\x18\x03 \x01(\x0b\x32\x0f.agents.AgentIdH\x00\x88\x01\x01\x12 \n\x07payload\x18\x04 \x01(\x0b\x32\x0f.agents.Payload\x12-\n\x08metadata\x18\x05 \x03(\x0b\x32\x1b.agents.Event.MetadataEntry\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\x42\t\n\x07_source\"<\n\x18RegisterAgentTypeRequest\x12\x12\n\nrequest_id\x18\x01 \x01(\t\x12\x0c\n\x04type\x18\x02 \x01(\t\"^\n\x19RegisterAgentTypeResponse\x12\x12\n\nrequest_id\x18\x01 \x01(\t\x12\x0f\n\x07success\x18\x02 \x01(\x08\x12\x12\n\x05\x65rror\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x08\n\x06_error\":\n\x10TypeSubscription\x12\x12\n\ntopic_type\x18\x01 \x01(\t\x12\x12\n\nagent_type\x18\x02 \x01(\t\"G\n\x16TypePrefixSubscription\x12\x19\n\x11topic_type_prefix\x18\x01 \x01(\t\x12\x12\n\nagent_type\x18\x02 \x01(\t\"\xa2\x01\n\x0cSubscription\x12\n\n\x02id\x18\x01 \x01(\t\x12\x34\n\x10typeSubscription\x18\x02 \x01(\x0b\x32\x18.agents.TypeSubscriptionH\x00\x12@\n\x16typePrefixSubscription\x18\x03 \x01(\x0b\x32\x1e.agents.TypePrefixSubscriptionH\x00\x42\x0e\n\x0csubscription\"X\n\x16\x41\x64\x64SubscriptionRequest\x12\x12\n\nrequest_id\x18\x01 \x01(\t\x12*\n\x0csubscription\x18\x02 \x01(\x0b\x32\x14.agents.Subscription\"\\\n\x17\x41\x64\x64SubscriptionResponse\x12\x12\n\nrequest_id\x18\x01 \x01(\t\x12\x0f\n\x07success\x18\x02 \x01(\x08\x12\x12\n\x05\x65rror\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x08\n\x06_error\"\'\n\x19RemoveSubscriptionRequest\x12\n\n\x02id\x18\x01 \x01(\t\"K\n\x1aRemoveSubscriptionResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\x12\n\x05\x65rror\x18\x02 \x01(\tH\x00\x88\x01\x01\x42\x08\n\x06_error\"\x19\n\x17GetSubscriptionsRequest\"G\n\x18GetSubscriptionsResponse\x12+\n\rsubscriptions\x18\x01 \x03(\x0b\x32\x14.agents.Subscription\"\x9d\x01\n\nAgentState\x12!\n\x08\x61gent_id\x18\x01 \x01(\x0b\x32\x0f.agents.AgentId\x12\x0c\n\x04\x65Tag\x18\x02 \x01(\t\x12\x15\n\x0b\x62inary_data\x18\x03 \x01(\x0cH\x00\x12\x13\n\ttext_data\x18\x04 \x01(\tH\x00\x12*\n\nproto_data\x18\x05 \x01(\x0b\x32\x14.google.protobuf.AnyH\x00\x42\x06\n\x04\x64\x61ta\"j\n\x10GetStateResponse\x12\'\n\x0b\x61gent_state\x18\x01 \x01(\x0b\x32\x12.agents.AgentState\x12\x0f\n\x07success\x18\x02 \x01(\x08\x12\x12\n\x05\x65rror\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x08\n\x06_error\"B\n\x11SaveStateResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\x12\n\x05\x65rror\x18\x02 \x01(\tH\x00\x88\x01\x01\x42\x08\n\x06_error\"\xad\x03\n\x07Message\x12%\n\x07request\x18\x01 \x01(\x0b\x32\x12.agents.RpcRequestH\x00\x12\'\n\x08response\x18\x02 \x01(\x0b\x32\x13.agents.RpcResponseH\x00\x12\x33\n\ncloudEvent\x18\x03 \x01(\x0b\x32\x1d.io.cloudevents.v1.CloudEventH\x00\x12\x44\n\x18registerAgentTypeRequest\x18\x04 \x01(\x0b\x32 .agents.RegisterAgentTypeRequestH\x00\x12\x46\n\x19registerAgentTypeResponse\x18\x05 \x01(\x0b\x32!.agents.RegisterAgentTypeResponseH\x00\x12@\n\x16\x61\x64\x64SubscriptionRequest\x18\x06 \x01(\x0b\x32\x1e.agents.AddSubscriptionRequestH\x00\x12\x42\n\x17\x61\x64\x64SubscriptionResponse\x18\x07 \x01(\x0b\x32\x1f.agents.AddSubscriptionResponseH\x00\x42\t\n\x07message2\x90\x04\n\x08\x41gentRpc\x12\x33\n\x0bOpenChannel\x12\x0f.agents.Message\x1a\x0f.agents.Message(\x01\x30\x01\x12\x35\n\x08GetState\x12\x0f.agents.AgentId\x1a\x18.agents.GetStateResponse\x12:\n\tSaveState\x12\x12.agents.AgentState\x1a\x19.agents.SaveStateResponse\x12T\n\rRegisterAgent\x12 .agents.RegisterAgentTypeRequest\x1a!.agents.RegisterAgentTypeResponse\x12R\n\x0f\x41\x64\x64Subscription\x12\x1e.agents.AddSubscriptionRequest\x1a\x1f.agents.AddSubscriptionResponse\x12[\n\x12RemoveSubscription\x12!.agents.RemoveSubscriptionRequest\x1a\".agents.RemoveSubscriptionResponse\x12U\n\x10GetSubscriptions\x12\x1f.agents.GetSubscriptionsRequest\x1a .agents.GetSubscriptionsResponseB\x1e\xaa\x02\x1bMicrosoft.AutoGen.Contractsb\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) @@ -57,19 +57,27 @@ _globals['_TYPEPREFIXSUBSCRIPTION']._serialized_start=1129 _globals['_TYPEPREFIXSUBSCRIPTION']._serialized_end=1200 _globals['_SUBSCRIPTION']._serialized_start=1203 - _globals['_SUBSCRIPTION']._serialized_end=1353 - _globals['_ADDSUBSCRIPTIONREQUEST']._serialized_start=1355 - _globals['_ADDSUBSCRIPTIONREQUEST']._serialized_end=1443 - _globals['_ADDSUBSCRIPTIONRESPONSE']._serialized_start=1445 - _globals['_ADDSUBSCRIPTIONRESPONSE']._serialized_end=1537 - _globals['_AGENTSTATE']._serialized_start=1540 - _globals['_AGENTSTATE']._serialized_end=1697 - _globals['_GETSTATERESPONSE']._serialized_start=1699 - _globals['_GETSTATERESPONSE']._serialized_end=1805 - _globals['_SAVESTATERESPONSE']._serialized_start=1807 - _globals['_SAVESTATERESPONSE']._serialized_end=1873 - _globals['_MESSAGE']._serialized_start=1876 - _globals['_MESSAGE']._serialized_end=2305 - _globals['_AGENTRPC']._serialized_start=2308 - _globals['_AGENTRPC']._serialized_end=2486 + _globals['_SUBSCRIPTION']._serialized_end=1365 + _globals['_ADDSUBSCRIPTIONREQUEST']._serialized_start=1367 + _globals['_ADDSUBSCRIPTIONREQUEST']._serialized_end=1455 + _globals['_ADDSUBSCRIPTIONRESPONSE']._serialized_start=1457 + _globals['_ADDSUBSCRIPTIONRESPONSE']._serialized_end=1549 + _globals['_REMOVESUBSCRIPTIONREQUEST']._serialized_start=1551 + _globals['_REMOVESUBSCRIPTIONREQUEST']._serialized_end=1590 + _globals['_REMOVESUBSCRIPTIONRESPONSE']._serialized_start=1592 + _globals['_REMOVESUBSCRIPTIONRESPONSE']._serialized_end=1667 + _globals['_GETSUBSCRIPTIONSREQUEST']._serialized_start=1669 + _globals['_GETSUBSCRIPTIONSREQUEST']._serialized_end=1694 + _globals['_GETSUBSCRIPTIONSRESPONSE']._serialized_start=1696 + _globals['_GETSUBSCRIPTIONSRESPONSE']._serialized_end=1767 + _globals['_AGENTSTATE']._serialized_start=1770 + _globals['_AGENTSTATE']._serialized_end=1927 + _globals['_GETSTATERESPONSE']._serialized_start=1929 + _globals['_GETSTATERESPONSE']._serialized_end=2035 + _globals['_SAVESTATERESPONSE']._serialized_start=2037 + _globals['_SAVESTATERESPONSE']._serialized_end=2103 + _globals['_MESSAGE']._serialized_start=2106 + _globals['_MESSAGE']._serialized_end=2535 + _globals['_AGENTRPC']._serialized_start=2538 + _globals['_AGENTRPC']._serialized_end=3066 # @@protoc_insertion_point(module_scope) diff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.pyi b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.pyi index 79e384ab948..12f1a872866 100644 --- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.pyi +++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.pyi @@ -221,6 +221,7 @@ class RegisterAgentTypeRequest(google.protobuf.message.Message): REQUEST_ID_FIELD_NUMBER: builtins.int TYPE_FIELD_NUMBER: builtins.int request_id: builtins.str + """TODO: remove once message based requests are removed""" type: builtins.str def __init__( self, @@ -240,6 +241,7 @@ class RegisterAgentTypeResponse(google.protobuf.message.Message): SUCCESS_FIELD_NUMBER: builtins.int ERROR_FIELD_NUMBER: builtins.int request_id: builtins.str + """TODO: remove once message based requests are removed""" success: builtins.bool error: builtins.str def __init__( @@ -295,8 +297,10 @@ global___TypePrefixSubscription = TypePrefixSubscription class Subscription(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor + ID_FIELD_NUMBER: builtins.int TYPESUBSCRIPTION_FIELD_NUMBER: builtins.int TYPEPREFIXSUBSCRIPTION_FIELD_NUMBER: builtins.int + id: builtins.str @property def typeSubscription(self) -> global___TypeSubscription: ... @property @@ -304,11 +308,12 @@ class Subscription(google.protobuf.message.Message): def __init__( self, *, + id: builtins.str = ..., typeSubscription: global___TypeSubscription | None = ..., typePrefixSubscription: global___TypePrefixSubscription | None = ..., ) -> None: ... def HasField(self, field_name: typing.Literal["subscription", b"subscription", "typePrefixSubscription", b"typePrefixSubscription", "typeSubscription", b"typeSubscription"]) -> builtins.bool: ... - def ClearField(self, field_name: typing.Literal["subscription", b"subscription", "typePrefixSubscription", b"typePrefixSubscription", "typeSubscription", b"typeSubscription"]) -> None: ... + def ClearField(self, field_name: typing.Literal["id", b"id", "subscription", b"subscription", "typePrefixSubscription", b"typePrefixSubscription", "typeSubscription", b"typeSubscription"]) -> None: ... def WhichOneof(self, oneof_group: typing.Literal["subscription", b"subscription"]) -> typing.Literal["typeSubscription", "typePrefixSubscription"] | None: ... global___Subscription = Subscription @@ -320,6 +325,7 @@ class AddSubscriptionRequest(google.protobuf.message.Message): REQUEST_ID_FIELD_NUMBER: builtins.int SUBSCRIPTION_FIELD_NUMBER: builtins.int request_id: builtins.str + """TODO: remove once message based requests are removed""" @property def subscription(self) -> global___Subscription: ... def __init__( @@ -341,6 +347,7 @@ class AddSubscriptionResponse(google.protobuf.message.Message): SUCCESS_FIELD_NUMBER: builtins.int ERROR_FIELD_NUMBER: builtins.int request_id: builtins.str + """TODO: remove once message based requests are removed""" success: builtins.bool error: builtins.str def __init__( @@ -356,6 +363,67 @@ class AddSubscriptionResponse(google.protobuf.message.Message): global___AddSubscriptionResponse = AddSubscriptionResponse +@typing.final +class RemoveSubscriptionRequest(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + ID_FIELD_NUMBER: builtins.int + id: builtins.str + def __init__( + self, + *, + id: builtins.str = ..., + ) -> None: ... + def ClearField(self, field_name: typing.Literal["id", b"id"]) -> None: ... + +global___RemoveSubscriptionRequest = RemoveSubscriptionRequest + +@typing.final +class RemoveSubscriptionResponse(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + SUCCESS_FIELD_NUMBER: builtins.int + ERROR_FIELD_NUMBER: builtins.int + success: builtins.bool + error: builtins.str + def __init__( + self, + *, + success: builtins.bool = ..., + error: builtins.str | None = ..., + ) -> None: ... + def HasField(self, field_name: typing.Literal["_error", b"_error", "error", b"error"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["_error", b"_error", "error", b"error", "success", b"success"]) -> None: ... + def WhichOneof(self, oneof_group: typing.Literal["_error", b"_error"]) -> typing.Literal["error"] | None: ... + +global___RemoveSubscriptionResponse = RemoveSubscriptionResponse + +@typing.final +class GetSubscriptionsRequest(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + def __init__( + self, + ) -> None: ... + +global___GetSubscriptionsRequest = GetSubscriptionsRequest + +@typing.final +class GetSubscriptionsResponse(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + SUBSCRIPTIONS_FIELD_NUMBER: builtins.int + @property + def subscriptions(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Subscription]: ... + def __init__( + self, + *, + subscriptions: collections.abc.Iterable[global___Subscription] | None = ..., + ) -> None: ... + def ClearField(self, field_name: typing.Literal["subscriptions", b"subscriptions"]) -> None: ... + +global___GetSubscriptionsResponse = GetSubscriptionsResponse + @typing.final class AgentState(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor diff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.py b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.py index fc27021587f..4f5e4cd0a51 100644 --- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.py +++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.py @@ -29,6 +29,26 @@ def __init__(self, channel): request_serializer=agent__worker__pb2.AgentState.SerializeToString, response_deserializer=agent__worker__pb2.SaveStateResponse.FromString, ) + self.RegisterAgent = channel.unary_unary( + '/agents.AgentRpc/RegisterAgent', + request_serializer=agent__worker__pb2.RegisterAgentTypeRequest.SerializeToString, + response_deserializer=agent__worker__pb2.RegisterAgentTypeResponse.FromString, + ) + self.AddSubscription = channel.unary_unary( + '/agents.AgentRpc/AddSubscription', + request_serializer=agent__worker__pb2.AddSubscriptionRequest.SerializeToString, + response_deserializer=agent__worker__pb2.AddSubscriptionResponse.FromString, + ) + self.RemoveSubscription = channel.unary_unary( + '/agents.AgentRpc/RemoveSubscription', + request_serializer=agent__worker__pb2.RemoveSubscriptionRequest.SerializeToString, + response_deserializer=agent__worker__pb2.RemoveSubscriptionResponse.FromString, + ) + self.GetSubscriptions = channel.unary_unary( + '/agents.AgentRpc/GetSubscriptions', + request_serializer=agent__worker__pb2.GetSubscriptionsRequest.SerializeToString, + response_deserializer=agent__worker__pb2.GetSubscriptionsResponse.FromString, + ) class AgentRpcServicer(object): @@ -52,6 +72,30 @@ def SaveState(self, request, context): context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') + def RegisterAgent(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def AddSubscription(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def RemoveSubscription(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetSubscriptions(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + def add_AgentRpcServicer_to_server(servicer, server): rpc_method_handlers = { @@ -70,6 +114,26 @@ def add_AgentRpcServicer_to_server(servicer, server): request_deserializer=agent__worker__pb2.AgentState.FromString, response_serializer=agent__worker__pb2.SaveStateResponse.SerializeToString, ), + 'RegisterAgent': grpc.unary_unary_rpc_method_handler( + servicer.RegisterAgent, + request_deserializer=agent__worker__pb2.RegisterAgentTypeRequest.FromString, + response_serializer=agent__worker__pb2.RegisterAgentTypeResponse.SerializeToString, + ), + 'AddSubscription': grpc.unary_unary_rpc_method_handler( + servicer.AddSubscription, + request_deserializer=agent__worker__pb2.AddSubscriptionRequest.FromString, + response_serializer=agent__worker__pb2.AddSubscriptionResponse.SerializeToString, + ), + 'RemoveSubscription': grpc.unary_unary_rpc_method_handler( + servicer.RemoveSubscription, + request_deserializer=agent__worker__pb2.RemoveSubscriptionRequest.FromString, + response_serializer=agent__worker__pb2.RemoveSubscriptionResponse.SerializeToString, + ), + 'GetSubscriptions': grpc.unary_unary_rpc_method_handler( + servicer.GetSubscriptions, + request_deserializer=agent__worker__pb2.GetSubscriptionsRequest.FromString, + response_serializer=agent__worker__pb2.GetSubscriptionsResponse.SerializeToString, + ), } generic_handler = grpc.method_handlers_generic_handler( 'agents.AgentRpc', rpc_method_handlers) @@ -130,3 +194,71 @@ def SaveState(request, agent__worker__pb2.SaveStateResponse.FromString, options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def RegisterAgent(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/agents.AgentRpc/RegisterAgent', + agent__worker__pb2.RegisterAgentTypeRequest.SerializeToString, + agent__worker__pb2.RegisterAgentTypeResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def AddSubscription(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/agents.AgentRpc/AddSubscription', + agent__worker__pb2.AddSubscriptionRequest.SerializeToString, + agent__worker__pb2.AddSubscriptionResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def RemoveSubscription(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/agents.AgentRpc/RemoveSubscription', + agent__worker__pb2.RemoveSubscriptionRequest.SerializeToString, + agent__worker__pb2.RemoveSubscriptionResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def GetSubscriptions(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/agents.AgentRpc/GetSubscriptions', + agent__worker__pb2.GetSubscriptionsRequest.SerializeToString, + agent__worker__pb2.GetSubscriptionsResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.pyi b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.pyi index bf6bc1ba2d6..2d895360b29 100644 --- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.pyi +++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.pyi @@ -34,6 +34,26 @@ class AgentRpcStub: agent_worker_pb2.SaveStateResponse, ] + RegisterAgent: grpc.UnaryUnaryMultiCallable[ + agent_worker_pb2.RegisterAgentTypeRequest, + agent_worker_pb2.RegisterAgentTypeResponse, + ] + + AddSubscription: grpc.UnaryUnaryMultiCallable[ + agent_worker_pb2.AddSubscriptionRequest, + agent_worker_pb2.AddSubscriptionResponse, + ] + + RemoveSubscription: grpc.UnaryUnaryMultiCallable[ + agent_worker_pb2.RemoveSubscriptionRequest, + agent_worker_pb2.RemoveSubscriptionResponse, + ] + + GetSubscriptions: grpc.UnaryUnaryMultiCallable[ + agent_worker_pb2.GetSubscriptionsRequest, + agent_worker_pb2.GetSubscriptionsResponse, + ] + class AgentRpcAsyncStub: OpenChannel: grpc.aio.StreamStreamMultiCallable[ agent_worker_pb2.Message, @@ -50,6 +70,26 @@ class AgentRpcAsyncStub: agent_worker_pb2.SaveStateResponse, ] + RegisterAgent: grpc.aio.UnaryUnaryMultiCallable[ + agent_worker_pb2.RegisterAgentTypeRequest, + agent_worker_pb2.RegisterAgentTypeResponse, + ] + + AddSubscription: grpc.aio.UnaryUnaryMultiCallable[ + agent_worker_pb2.AddSubscriptionRequest, + agent_worker_pb2.AddSubscriptionResponse, + ] + + RemoveSubscription: grpc.aio.UnaryUnaryMultiCallable[ + agent_worker_pb2.RemoveSubscriptionRequest, + agent_worker_pb2.RemoveSubscriptionResponse, + ] + + GetSubscriptions: grpc.aio.UnaryUnaryMultiCallable[ + agent_worker_pb2.GetSubscriptionsRequest, + agent_worker_pb2.GetSubscriptionsResponse, + ] + class AgentRpcServicer(metaclass=abc.ABCMeta): @abc.abstractmethod def OpenChannel( @@ -72,4 +112,32 @@ class AgentRpcServicer(metaclass=abc.ABCMeta): context: _ServicerContext, ) -> typing.Union[agent_worker_pb2.SaveStateResponse, collections.abc.Awaitable[agent_worker_pb2.SaveStateResponse]]: ... + @abc.abstractmethod + def RegisterAgent( + self, + request: agent_worker_pb2.RegisterAgentTypeRequest, + context: _ServicerContext, + ) -> typing.Union[agent_worker_pb2.RegisterAgentTypeResponse, collections.abc.Awaitable[agent_worker_pb2.RegisterAgentTypeResponse]]: ... + + @abc.abstractmethod + def AddSubscription( + self, + request: agent_worker_pb2.AddSubscriptionRequest, + context: _ServicerContext, + ) -> typing.Union[agent_worker_pb2.AddSubscriptionResponse, collections.abc.Awaitable[agent_worker_pb2.AddSubscriptionResponse]]: ... + + @abc.abstractmethod + def RemoveSubscription( + self, + request: agent_worker_pb2.RemoveSubscriptionRequest, + context: _ServicerContext, + ) -> typing.Union[agent_worker_pb2.RemoveSubscriptionResponse, collections.abc.Awaitable[agent_worker_pb2.RemoveSubscriptionResponse]]: ... + + @abc.abstractmethod + def GetSubscriptions( + self, + request: agent_worker_pb2.GetSubscriptionsRequest, + context: _ServicerContext, + ) -> typing.Union[agent_worker_pb2.GetSubscriptionsResponse, collections.abc.Awaitable[agent_worker_pb2.GetSubscriptionsResponse]]: ... + def add_AgentRpcServicer_to_server(servicer: AgentRpcServicer, server: typing.Union[grpc.Server, grpc.aio.Server]) -> None: ...