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 = 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]
message_id: str
message_type: str
private_keys: List[str]
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.InputMessage(data_dict: Dict[str, Any], src_flow: str, dst_flow: str, created_by: str | None = None, private_keys: List[str] | None = None)

Bases: Message

This class represents an input message that is passed from one flow to another.

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

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

  • dst_flow (str) – The name of the flow that should receive 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

static build(data_dict: Dict[str, Any], src_flow: str, dst_flow: str, private_keys: List[str] | None = None, created_by: str | None = None) InputMessage

Static method that builds an InputMessage object.

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

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

  • dst_flow (str) – The name of the flow that should receive 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

Returns:

The built InputMessage object

Return type:

InputMessage

created_at: str
created_by: str
data: Dict[str, Any]
message_id: str
message_type: str
private_keys: List[str]
to_string()

Returns a string representation of the message.

Returns:

The string representation of the message.

Return type:

str

class aiflows.messages.flow_message.OutputMessage(src_flow: str, dst_flow: str, output_data: Dict[str, Any], raw_response: Dict[str, Any] | None, input_message_id: str, history: FlowHistory, created_by: str, **kwargs)

Bases: Message

This class represents an output message that is passed from one flow to another.

Parameters:
  • src_flow (str) – The name of the flow that created the message

  • dst_flow (str) – The name of the flow that should receive the message

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

  • raw_response (Dict[str, Any]) – The raw response of the message

  • input_message_id (str) – The unique identification of the input message

  • history (FlowHistory) – The history of the flow

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

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

created_at: str
created_by: str
data: Dict[str, Any]
get_output_data()

Returns the output data of the message.

Returns:

The output data of the message.

Return type:

Dict[str, Any]

message_id: str
message_type: str
private_keys: List[str]
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_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

created_at: str
created_by: str
data: Dict[str, Any]
message_id: str
message_type: str
private_keys: List[str]
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

created_at: str
created_by: str
data: Dict[str, Any]
message_id: str
message_type: str
private_keys: List[str]
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

created_at: str
created_by: str
data: Dict[str, Any]
message_id: str
message_type: str
private_keys: List[str]
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.

created_at: str
created_by: str
data: Dict[str, Any]
message_id: str
message_type: str
private_keys: List[str]
to_string()

Returns a string representation of the message.

Returns:

The string representation of the message.

Return type:

str

Module contents