Redefine Roles Operator
The Redefine Roles LOP allows you to dynamically change the role (e.g., ‘user’, ‘assistant’, ‘system’) of messages passing through it, based on specified patterns or conditions. This is useful for manipulating conversation history before sending it to an LLM.
Requirements
Section titled “Requirements”- None (standard TouchDesigner installation).
Input/Output
Section titled “Input/Output”Inputs
Section titled “Inputs”- Input Conversation (Table DAT): Table with conversation data. Required columns:
role,message. Optional:id,timestamp.
Outputs
Section titled “Outputs”- Output Conversation (Table DAT): Contains the conversation with redefined roles. Other columns are copied.
Parameters
Section titled “Parameters”Redefine Roles Page
Section titled “Redefine Roles Page”About Page
Section titled “About Page” Bypass (Bypass)
op('redefine_roles').par.Bypass Toggle - Default:
Off
Show Built In Pars (Showbuiltin)
op('redefine_roles').par.Showbuiltin Toggle - Default:
Off
Version (Version)
op('redefine_roles').par.Version String - Default:
None
Last Updated (Lastupdated)
op('redefine_roles').par.Lastupdated String - Default:
None
Creator (Creator)
op('redefine_roles').par.Creator String - Default:
None
Website (Website)
op('redefine_roles').par.Website String - Default:
None
ChatTD Operator (Chattd)
op('redefine_roles').par.Chattd OP - Default:
None
Performance Considerations
Section titled “Performance Considerations”- Generally fast due to simple table operations.
- Very large input tables might slightly impact network performance.
Usage Examples
Section titled “Usage Examples”Swapping User and Assistant Roles
Section titled “Swapping User and Assistant Roles”- Create a
redefine_rolesLOP. - Connect a Table DAT containing your conversation (with
roleandmessagecolumns) to the input of theredefine_rolesLOP. - On the
redefine_rolesLOP, setSet User Roletoassistant. - Set
Set Assistant Roletouser. - Keep
Set System Roleassystem(or change if desired). - The output DAT will now have the user and assistant roles swapped.
Reassigning System Messages
Section titled “Reassigning System Messages”- Create a
redefine_rolesLOP. - Connect a Table DAT containing your conversation to the input of the
redefine_rolesLOP. - Set
Set System Roletoassistant. - Keep
Set User RoleasuserandSet Assistant Roleasassistant. - The output DAT will now show original system messages as assistant messages.
Common Use Cases
Section titled “Common Use Cases”- Correcting mislabeled roles in conversation logs.
- Adapting conversations for models requiring different role structures.
- Experimenting with conversational dynamics.
- Preprocessing conversation data for other LOPs.