aiflows.messages package

Submodules

aiflows.messages.abstract module

class aiflows.messages.abstract.Message(data: Dict[str, Any], created_by: str, private_keys: List[str] = None)

Bases: object

This class represents a message that is passed between nodes in a flow.

Parameters:
  • data (Dict[str, Any]) – The data content of the message

  • created_by (str) – The name of the flow that created the message

  • private_keys (List[str], optional) – A list of private keys that should not be serialized or logged

created_at: str
created_by: str
data: Dict[str, Any]
classmethod deserialize(encoded_data: bytes)

Deserializes the encoded data into a message

Parameters:

encoded_data (bytes) – The encoded message

Returns:

The deserialized message

Return type:

Message

message_id: str
message_type: str
private_keys: List[str]
serialize()

Returns the serialized message

Returns:

The serialized message

Return type:

bytes

to_dict()

Returns a dictionary representation of the message that can be serialized to JSON

to_string()

Returns a formatted string representation of the message that will be logged to the console

aiflows.messages.flow_message module

class aiflows.messages.flow_message.FlowMessage(data: Dict[str, Any], src_flow: str = 'unknown', src_flow_id: str = 'unknown', dst_flow: str = 'unknown', reply_data: Dict[str, Any] | None = {'mode': 'no_reply'}, created_by: str | None = None, private_keys: List[str] | None = None, input_message_id: str | None = None, is_reply: bool | None = False, user_id: str | None = None)

Bases: Message

to_string()

Returns a formatted string representation of the message that will be logged to the console

class aiflows.messages.flow_message.UpdateMessage_ChatMessage(content: str, role: str, updated_flow: str, **kwargs)

Bases: UpdateMessage_Generic

Updates the chat message of a flow.

Parameters:
  • content (str) – The content of the chat message

  • role (str) – The role of the chat message (typically “user”, “assistant”, “system”, “human” …)

  • updated_flow (str) – The name of the flow that should be updated

  • **kwargs – arguments that are passed to the UpdateMessage_Generic constructor

to_string()

Returns a string representation of the message.

Returns:

The string representation of the message.

Return type:

str

class aiflows.messages.flow_message.UpdateMessage_FullReset(updated_flow: str, created_by: str, keys_deleted_from_namespace: List[str])

Bases: Message

Resets the full message of a flow.

Parameters:

updated_flow – The name of the flow that should be updated

to_string()

Returns a string representation of the message.

Returns:

The string representation of the message.

Return type:

str

class aiflows.messages.flow_message.UpdateMessage_Generic(updated_flow: str, **kwargs)

Bases: Message

Updates the message of a flow.

Parameters:
  • updated_flow (str) – The name of the flow that should be updated

  • **kwargs – arguments that are passed to the Message constructor

to_string()

Returns a string representation of the message.

Returns:

The string representation of the message.

Return type:

str

class aiflows.messages.flow_message.UpdateMessage_NamespaceReset(updated_flow: str, created_by: str, keys_deleted_from_namespace: List[str])

Bases: Message

Resets the namespace of a flow’s message.

to_string()

Returns a string representation of the message.

Returns:

The string representation of the message.

Return type:

str

Module contents