mirror of
https://github.com/microsoft/autogen.git
synced 2025-11-14 17:13:29 +00:00
Add ID to subscription (#317)
This commit is contained in:
parent
1c95443db5
commit
37be630dd8
@ -1,3 +1,5 @@
|
|||||||
|
import uuid
|
||||||
|
|
||||||
from agnext.core.exceptions import CantHandleException
|
from agnext.core.exceptions import CantHandleException
|
||||||
|
|
||||||
from ..core import AgentId, Subscription, TopicId
|
from ..core import AgentId, Subscription, TopicId
|
||||||
@ -27,6 +29,11 @@ class TypeSubscription(Subscription):
|
|||||||
|
|
||||||
self._topic_type = topic_type
|
self._topic_type = topic_type
|
||||||
self._agent_type = agent_type
|
self._agent_type = agent_type
|
||||||
|
self._id = str(uuid.uuid4())
|
||||||
|
|
||||||
|
@property
|
||||||
|
def id(self) -> str:
|
||||||
|
return self._id
|
||||||
|
|
||||||
def is_match(self, topic_id: TopicId) -> bool:
|
def is_match(self, topic_id: TopicId) -> bool:
|
||||||
return topic_id.type == self._topic_type
|
return topic_id.type == self._topic_type
|
||||||
|
|||||||
@ -8,6 +8,17 @@ from ._topic import TopicId
|
|||||||
class Subscription(Protocol):
|
class Subscription(Protocol):
|
||||||
"""Subscriptions define the topics that an agent is interested in."""
|
"""Subscriptions define the topics that an agent is interested in."""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def id(self) -> str:
|
||||||
|
"""Get the ID of the subscription.
|
||||||
|
|
||||||
|
Implementations should return a unique ID for the subscription. Usually this is a UUID.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: ID of the subscription.
|
||||||
|
"""
|
||||||
|
...
|
||||||
|
|
||||||
def is_match(self, topic_id: TopicId) -> bool:
|
def is_match(self, topic_id: TopicId) -> bool:
|
||||||
"""Check if a given topic_id matches the subscription.
|
"""Check if a given topic_id matches the subscription.
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user