Add Message Operator
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.
- 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:
Off
Message to Inject (Message)
op('add_message').par.Message
String - Default:
None
Text From Dat [ in2 ] (Fromin2)
op('add_message').par.Fromin2
Toggle - Default:
Off
Use Input Conversation (Useinput)
op('add_message').par.Useinput
Toggle - Default:
Off
Insert Index (Index)
op('add_message').par.Index
Integer - Default:
0
Inject ID (Injectid)
op('add_message').par.Injectid
String - Default:
None
Spacer Header
About Page
Section titled “About Page” Bypass (Bypass)
op('add_message').par.Bypass
Toggle - Default:
Off
Show Built In Pars (Showbuiltin)
op('add_message').par.Showbuiltin
Toggle - Default:
Off
Version (Version)
op('add_message').par.Version
String - Default:
None
Last Updated (Lastupdated)
op('add_message').par.Lastupdated
String - Default:
None
Creator (Creator)
op('add_message').par.Creator
String - Default:
None
Website (Website)
op('add_message').par.Website
String - Default:
None
ChatTD Operator (Chattd)
op('add_message').par.Chattd
OP - Default:
None
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”- Create an
add_message
LOP. - Create a Table DAT with an existing conversation and connect it to the first input of the
add_message
LOP. - Enable the
Use Input Conversation
toggle. - Set the
Message Role
touser
. - Enter your message in the
Message to Inject
field. - Set the
Inject Location
toend
. - Toggle the
Insert Message
parameter on. - The output DAT will now have the new message appended to the conversation.
Injecting System Message at Start (New Conversation)
Section titled “Injecting System Message at Start (New Conversation)”- Create an
add_message
LOP. - Ensure the
Use Input Conversation
toggle is off. - Set the
Message Role
tosystem
. - Enter your message in the
Message to Inject
field. - Set the
Inject Location
tostart
. - Toggle the
Insert Message
parameter on. - The output DAT will contain only the new 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.