Add Message Operator
Overview
Section titled “Overview”The Add Message operator allows you to dynamically insert messages into a conversation table within your TouchDesigner project. This is useful for simulating user input, testing chatbot responses, or pre-populating a conversation with system messages. The operator supports various message roles (user, assistant, system), injection locations (start, end, index), and can pull message text from an external DAT. It leverages a shared sidecar server for asynchronous tasks, ensuring smooth operation without blocking the main TouchDesigner thread.
Requirements
Section titled “Requirements”- Sidecar Server: Must be running (shared with other LOPs like Florence).
- No additional Python packages required.
Input/Output
Section titled “Input/Output”Inputs
Section titled “Inputs”- Input 1 (Conversation Table, DAT, Optional): If provided and
Use Input Conversation
is enabled, this table is the initial conversation. Columns:role
,message
,id
,timestamp
. - Input 2 (Text DAT, Optional): If
Text From Dat [ in2 ]
is enabled, text from this DAT is injected.
Outputs
Section titled “Outputs”- Output Conversation Table (DAT): Contains the injected message plus any input conversation messages. Columns:
role
,message
,id
,timestamp
.
Parameters
Section titled “Parameters”Inject Message Page
Section titled “Inject Message Page” Insert Message (Insert)
op('add_message').par.Insert
Toggle - Default:
1
Message to Inject (Message)
op('add_message').par.Message
String - Default:
i add message here
Text From Dat [ in2 ] (Fromin2)
op('add_message').par.Fromin2
Toggle - Default:
0
Use Input Conversation (Useinput)
op('add_message').par.Useinput
Toggle - Default:
1
Insert Index (Index)
op('add_message').par.Index
Integer - Default:
3
Inject ID (Injectid)
op('add_message').par.Injectid
String - Default:
add_message
Spacer Header
About Page
Section titled “About Page” Bypass (Bypass)
op('add_message').par.Bypass
Toggle - Default:
0
Show Built In Pars (Showbuiltin)
op('add_message').par.Showbuiltin
Toggle - Default:
0
Version (Version)
op('add_message').par.Version
String - Default:
1.0.0
Last Updated (Lastupdated)
op('add_message').par.Lastupdated
String - Default:
2025-01-13
Creator (Creator)
op('add_message').par.Creator
String - Default:
dotsimulate
Website (Website)
op('add_message').par.Website
String - Default:
https://dotsimulate.com
ChatTD Operator (Chattd)
op('add_message').par.Chattd
OP - Default:
/dot_lops/ChatTD
Performance Considerations
Section titled “Performance Considerations”- Lightweight operation.
- Frequent injections at the start of long conversations might have minor impact.
- Using Input 2 with large DATs might add slight delay.
Usage Examples
Section titled “Usage Examples”Injecting User Message at End
Section titled “Injecting User Message at End”add_msg = op('add_message1')conv_dat = op('existing_conversation')
add_msg.inputConnectors[0].connect(conv_dat)add_msg.par.Useinput = 1add_msg.par.Role = 'user'add_msg.par.Message = "This is my latest input."add_msg.par.Location = 'end'add_msg.par.Insert = 1
# Output DAT now has the new message appended
Injecting System Message at Start (New Conversation)
Section titled “Injecting System Message at Start (New Conversation)”add_msg = op('add_message1')
# No input connected to Input 1add_msg.par.Useinput = 0add_msg.par.Role = 'system'add_msg.par.Message = "Welcome to the system."add_msg.par.Location = 'start'add_msg.par.Insert = 1
# Output DAT contains only the system message
Common Use Cases
Section titled “Common Use Cases”- Simulating user input for chatbot testing.
- Pre-populating conversations with system messages.
- Injecting prompts or instructions into ongoing chats.
- Dynamically updating conversations based on events.