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 Conversationis 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_messageLOP. - Create a Table DAT with an existing conversation and connect it to the first input of the
add_messageLOP. - Enable the
Use Input Conversationtoggle. - Set the
Message Roletouser. - Enter your message in the
Message to Injectfield. - Set the
Inject Locationtoend. - Toggle the
Insert Messageparameter 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_messageLOP. - Ensure the
Use Input Conversationtoggle is off. - Set the
Message Roletosystem. - Enter your message in the
Message to Injectfield. - Set the
Inject Locationtostart. - Toggle the
Insert Messageparameter 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.