def __init__(self, agent_address) -> None: """ Initialize dialogues. :return: None """ FipaDialogues.__init__(self, agent_address)
def __init__(self, **kwargs) -> None: """ Initialize dialogues. :return: None """ Model.__init__(self, **kwargs) def role_from_first_message( # pylint: disable=unused-argument message: Message, receiver_address: Address) -> BaseDialogue.Role: """Infer the role of the agent from an incoming/outgoing first message :param message: an incoming/outgoing first message :param receiver_address: the address of the receiving agent :return: The role of the agent """ return BaseFipaDialogue.Role.SELLER BaseFipaDialogues.__init__( self, self_address=self.context.agent_address, role_from_first_message=role_from_first_message, dialogue_class=FipaDialogue, )
def __init__(self, **kwargs) -> None: """ Initialize dialogues. :return: None """ Model.__init__(self, **kwargs) FipaDialogues.__init__(self, self.context.agent_address)
def __init__(self, **kwargs) -> None: """ Initialize dialogues. :return: None """ Model.__init__(self, **kwargs) FipaDialogues.__init__(self)
def __init__(self, **kwargs: Any) -> None: """ Initialize dialogues. :return: None """ Model.__init__(self, **kwargs) def role_from_first_message( message: Message, receiver_address: Address) -> Dialogue.Role: """Infer the role of the agent from an incoming/outgoing first message :param message: an incoming/outgoing first message :param receiver_address: the address of the receiving agent :return: The role of the agent """ fipa_message = cast(FipaMessage, message) if fipa_message.performative != FipaMessage.Performative.CFP: raise ValueError( "First message must be a CFP!") # pragma: nocover query = fipa_message.query if query.model is None: raise ValueError( "Query must have a data model!") # pragma: nocover if query.model.name not in [ SUPPLY_DATAMODEL_NAME, DEMAND_DATAMODEL_NAME, ]: raise ValueError( # pragma: nocover "Query data model name must be in [{},{}]".format( SUPPLY_DATAMODEL_NAME, DEMAND_DATAMODEL_NAME)) if message.sender != receiver_address: # message is by other is_seller = ( query.model.name == SUPPLY_DATAMODEL_NAME ) # the counterparty is querying for supply/sellers (this agent is receiving their CFP so is the seller) else: # message is by self is_seller = ( query.model.name == DEMAND_DATAMODEL_NAME ) # the agent is querying for demand/buyers (this agent is sending the CFP so it is the seller) role = FipaDialogue.Role.SELLER if is_seller else FipaDialogue.Role.BUYER return role BaseFipaDialogues.__init__( self, self_address=self.context.agent_address, role_from_first_message=role_from_first_message, dialogue_class=FipaDialogue, )
def setup_class(cls): """Set up the test.""" cls.node = LocalNode() cls.node.start() cls.address_1 = "address_1" cls.multiplexer1 = Multiplexer( [_make_local_connection(cls.address_1, cls.node,)] ) cls.dialogues = FipaDialogues(cls.address_1)
def __init__(self, self_address: Address) -> None: """ Initialize dialogues. :return: None """ def role_from_first_message( # pylint: disable=unused-argument message: Message, receiver_address: Address) -> BaseDialogue.Role: """Infer the role of the agent from an incoming/outgoing first message :param message: an incoming/outgoing first message :param receiver_address: the address of the receiving agent :return: The role of the agent """ return FipaDialogue.Role.BUYER FipaDialogues.__init__( self, self_address=self_address, role_from_first_message=role_from_first_message, dialogue_class=BuyerDialogue, )
def setup_class(cls): """Set up the test.""" cls.node = LocalNode() cls.node.start() cls.address_1 = "address_1" cls.multiplexer1 = Multiplexer( [_make_local_connection( cls.address_1, cls.node, )]) def role_from_first_message( # pylint: disable=unused-argument message: Message, receiver_address: Address) -> BaseDialogue.Role: """Infer the role of the agent from an incoming/outgoing first message :param message: an incoming/outgoing first message :param receiver_address: the address of the receiving agent :return: The role of the agent """ return FipaDialogue.Role.SELLER cls.dialogues = FipaDialogues(cls.address_1, role_from_first_message)
def setup_class(cls): """Set up the test.""" cls.client_dialogues = FipaDialogues() cls.seller_dialogues = FipaDialogues() cls.client_addr = "client" cls.seller_addr = "seller"