コード例 #1
0
ファイル: dialogues.py プロジェクト: hame58gp/agents-aea
    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,
        )
コード例 #2
0
    def __init__(self, agent_address) -> None:
        """
        Initialize dialogues.

        :return: None
        """
        FipaDialogues.__init__(self, agent_address)
コード例 #3
0
ファイル: dialogues.py プロジェクト: yangjue-han/agents-aea
    def __init__(self, **kwargs) -> None:
        """
        Initialize dialogues.

        :return: None
        """
        Model.__init__(self, **kwargs)
        FipaDialogues.__init__(self, self.context.agent_address)
コード例 #4
0
ファイル: dialogues.py プロジェクト: pbukva/agents-aea
    def __init__(self, **kwargs) -> None:
        """
        Initialize dialogues.

        :return: None
        """
        Model.__init__(self, **kwargs)
        FipaDialogues.__init__(self)
コード例 #5
0
    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,
        )
コード例 #6
0
    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,
        )