Redefine Roles Operator
Overview
Section titled “Overview”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:
0
Show Built In Pars (Showbuiltin)
op('redefine_roles').par.Showbuiltin
Toggle - Default:
0
Version (Version)
op('redefine_roles').par.Version
String - Default:
1.0.0
Last Updated (Lastupdated)
op('redefine_roles').par.Lastupdated
String - Default:
2024-11-06
Creator (Creator)
op('redefine_roles').par.Creator
String - Default:
dotsimulate
Website (Website)
op('redefine_roles').par.Website
String - Default:
https://dotsimulate.com
ChatTD Operator (Chattd)
op('redefine_roles').par.Chattd
OP - Default:
/dot_lops/ChatTD
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”redef_op = op('redefine_roles1')conv_dat = op('conversation_log')
redef_op.inputConnectors[0].connect(conv_dat)
redef_op.par.Setuser = 'assistant'redef_op.par.Setassistant = 'user'redef_op.par.Setsystem = 'system' # Keep system role the same
# Output DAT has user and assistant roles swapped
Reassigning System Messages
Section titled “Reassigning System Messages”redef_op = op('redefine_roles1')conv_dat = op('conversation_log')
redef_op.inputConnectors[0].connect(conv_dat)
# Change original system messages to appear as assistant messagesredef_op.par.Setsystem = 'assistant'
# Keep original user and assistant rolesredef_op.par.Setuser = 'user'redef_op.par.Setassistant = 'assistant'
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.