aiflows.data_transformations package

Submodules

aiflows.data_transformations.abstract module

class aiflows.data_transformations.abstract.DataTransformation(output_key=None)

Bases: ABC

This class is the base class for all data transformations.

Parameters:

output_key (str, optional) – The output key to apply the transformation to

aiflows.data_transformations.end_of_interaction module

class aiflows.data_transformations.end_of_interaction.EndOfInteraction(output_key: str, end_of_interaction_string: str, input_key: str)

Bases: DataTransformation

This class detects if the end of interaction string is in the input string.

Parameters:
  • output_key (str, optional) – The output key to apply the transformation to

  • end_of_interaction_string (str) – The end of interaction string to detect

  • input_key (str) – The input key to apply the transformation to

aiflows.data_transformations.json module

class aiflows.data_transformations.json.Json2Obj(input_key: str, output_key: str | None = None)

Bases: DataTransformation

This class converts a JSON string to a Python object.

Parameters:
  • input_key (str) – The input key to apply the transformation to

  • output_key (str, optional) – The output key to save the transformed data to

class aiflows.data_transformations.json.Obj2Json(input_key: str, output_key: str | None = None)

Bases: DataTransformation

This class converts a Python object to a JSON string.

Parameters:
  • input_key (str) – The input key to apply the transformation to

  • output_key (str, optional) – The output key to save the transformed data to

aiflows.data_transformations.key_copy module

class aiflows.data_transformations.key_copy.KeyCopy(old_key2new_key: Dict[str, str], flatten_data_dict: bool = True)

Bases: DataTransformation

This class copies the value of a key to a new key. It can be used to rename a key.

Parameters:
  • old_key2new_key (Dict[str, str]) – A dictionary mapping old keys to new keys

  • flatten_data_dict (bool, optional) – Whether to flatten the data dictionary before applying the transformation and unflatten it afterwards

aiflows.data_transformations.key_delete module

class aiflows.data_transformations.key_delete.KeyDelete(keys_to_delete: List[str], flatten_data_dict: bool = True)

Bases: DataTransformation

This class deletes a list of keys from the data dictionary.

Parameters:
  • keys_to_delete (List[str]) – A list of keys to delete

  • flatten_data_dict (bool, optional) – Whether to flatten the data dictionary before applying the transformation and unflatten it afterwards

aiflows.data_transformations.key_match_input module

class aiflows.data_transformations.key_match_input.KeyMatchInput

Bases: DataTransformation

This class extracts all keys from the data dictionary that are required by the destination flow.

aiflows.data_transformations.key_rename module

class aiflows.data_transformations.key_rename.KeyRename(old_key2new_key: Dict[str, str], nested_keys: bool = True)

Bases: DataTransformation

This class renames a list of keys from the data dictionary.

Parameters:
  • old_key2new_key (Dict[str, str]) – A dictionary mapping old keys to new keys

  • nested_keys (bool, optional) – Whether to use nested keys

aiflows.data_transformations.key_select module

class aiflows.data_transformations.key_select.KeySelect(keys_to_select: List[str], nested_keys: bool = True)

Bases: DataTransformation

This class selects a list of keys from the data dictionary.

Parameters:
  • keys_to_select (List[str]) – A list of keys to select

  • nested_keys (bool, optional) – Whether to use nested keys

aiflows.data_transformations.key_set module

class aiflows.data_transformations.key_set.KeySet(key2value: Dict[str, str], flatten_data_dict: bool = True)

Bases: DataTransformation

This class sets a list of keys to a given value in the data dictionary.

Parameters:
  • key2value (Dict[str, str]) – A dictionary mapping keys to values

  • flatten_data_dict (bool, optional) – Whether to flatten the data dictionary before applying the transformation and unflatten it afterwards

aiflows.data_transformations.print_previous_messages module

class aiflows.data_transformations.print_previous_messages.PrintPreviousMessages(last_message_only=False)

Bases: DataTransformation

This class prints the previous messages of the current flow.

Parameters:

last_message_only (bool, optional) – Whether to print only the last message or all previous messages

aiflows.data_transformations.regex_extractor_first module

class aiflows.data_transformations.regex_extractor_first.RegexFirstOccurrenceExtractor(regex: str, output_key: str, assert_unique: bool, strip: bool, input_key: str, regex_fallback: str = None, match_group: int = 0)

Bases: DataTransformation

This class extracts the first occurrence of a regex from a given input key and saves it to the output key.

Parameters:
  • regex (str) – The regex to search for

  • output_key (str, optional) – The output key to save the transformed data to

  • assert_unique (bool, optional) – Whether to assert that the regex has only one match

  • strip (bool, optional) – Whether to strip the result

  • input_key (str) – The input key to apply the transformation to

  • regex_fallback (str, optional) – A regex to use if the first regex was not found

  • match_group (int, optional) – The match group to return

aiflows.data_transformations.unnesting_dict module

class aiflows.data_transformations.unnesting_dict.UnNesting(input_key: str, output_key: str | None = None)

Bases: DataTransformation

This class unnests a dictionary from the data dictionary.

Parameters:
  • input_key (str) – The key of the dictionary to unnest

  • output_key (str, optional) – The output key to save the transformed data to

Module contents