pw.xpacks.llm.utils

combine_metadata(table, from_column='text', to_column='metadata', clean_from_column=True)

sourceCombines metadata from one column with another column. It is often the case that some UDFs return tuples with text and metadata e.g. (“This is manul”, {“color”: “grayish”}). This function moves metadata from one column to another (which possibly already contains some previous metadata), and optionally cleans the original column. If there is no to_column in the original table, it will be created as an empty dictionary.

  • Parameters
    • table (pw.Table) – Table to operate on.
    • from_column (str) – Column name with text and metadata.
    • to_column (str) – Column name where metadata should be moved.
    • clean_from_column (bool) – If True, the original column will be cleaned from metadata. Only text will remain.
  • Returns
    pw.Table – Table with combined metadata.