OAI Assistant Operator
The OAI Assistant operator (previously AssistantOperator) interfaces with the OpenAI Assistants API. It allows you to create, modify, and interact with AI assistants directly within TouchDesigner. This operator simplifies managing assistants, threads, messages, and runs, enabling interactive and intelligent applications.
Requirements
Section titled “Requirements”- OpenAI API key configured in the main AssistantExtension (usually part of ChatTD or a dedicated OpenAI setup).
- No specific Python package requirements beyond standard TouchDesigner.
Input/Output
Section titled “Input/Output”Inputs
Section titled “Inputs”None
Outputs
Section titled “Outputs”- Conversation DAT (
conversation_dat): Table containing the conversation history for the current thread. Columns:role,message,id,timestamp,assistant_id,thread_id. - History Table (
history_table): Table logging completed runs. Columns:assistant_id,thread_id,run_id,status,created_at,completed_at,model,response_time,tokens_used. - Active Runs Table (
active_runs_table): Table listing currently active runs. Columns:run_id,thread_id,created_at,last_checked,status.
Parameters
Section titled “Parameters”Thread Page
Section titled “Thread Page” Active (Active)
op('oai_assistant').par.Active Toggle - Default:
Off
Status (Status)
op('oai_assistant').par.Status String - Default:
Thread messages loaded
Send Message (Sendmessage)
op('oai_assistant').par.Sendmessage Pulse - Default:
None
Message (Message)
op('oai_assistant').par.Message String - Default:
tell me a test story
Create New Thread (Createthread)
op('oai_assistant').par.Createthread Pulse - Default:
None
Current Thread ID (Threadid)
op('oai_assistant').par.Threadid String - Default:
None
Switch Thread (Switchthread)
op('oai_assistant').par.Switchthread Pulse - Default:
None
Custom Thread (Customthread)
op('oai_assistant').par.Customthread String - Default:
None
Create Run (Createrun)
op('oai_assistant').par.Createrun Pulse - Default:
None
Current Run ID (Runid)
op('oai_assistant').par.Runid String - Default:
None
Cancel Run (Cancelrun)
op('oai_assistant').par.Cancelrun Pulse - Default:
None
Assistant Page
Section titled “Assistant Page” Active Assistant Header
Load Assistant Settings (Getassistantpars)
op('oai_assistant').par.Getassistantpars Pulse - Default:
None
Create / Modify Assistant Header
Create Assistant (Createassistant)
op('oai_assistant').par.Createassistant Pulse - Default:
None
Modify Assistant (Modifyassistant)
op('oai_assistant').par.Modifyassistant Pulse - Default:
None
Assistant Name (Assistantname)
op('oai_assistant').par.Assistantname String - Default:
Bobby Grace
Instructions (Instructions)
op('oai_assistant').par.Instructions String - Default:
Im Bobby Grace
Update Models (Updatemodels)
op('oai_assistant').par.Updatemodels Pulse - Default:
None
About Page
Section titled “About Page” Bypass (Bypass)
op('oai_assistant').par.Bypass Toggle - Default:
Off
Show Built-in Parameters (Showbuiltin)
op('oai_assistant').par.Showbuiltin Toggle - Default:
Off
Version (Version)
op('oai_assistant').par.Version String - Default:
1.0.0
Last Updated (Lastupdated)
op('oai_assistant').par.Lastupdated String - Default:
2025-01-31
Creator (Creator)
op('oai_assistant').par.Creator String - Default:
dotsimulate
Website (Website)
op('oai_assistant').par.Website String - Default:
https://dotsimulate.com
ChatTD Operator (Chattd)
op('oai_assistant').par.Chattd OP - Default:
/dot_lops/ChatTD
Performance Considerations
Section titled “Performance Considerations”- API calls (creating/modifying assistants, creating runs, sending messages) consume OpenAI credits.
- Frequent polling or updates can increase API usage.
- Long threads require more processing by the assistant.
Usage Examples
Section titled “Usage Examples”Creating a New Assistant
Section titled “Creating a New Assistant”oai_op = op('oai_assistant1')
oai_op.par.Assistantname = 'Helpful Tutor'oai_op.par.Instructions = 'You are a helpful tutor explaining complex topics simply.'oai_op.par.Model = 'gpt-4o-mini'oai_op.par.Tools = 'file_search' # Example tooloai_op.par.Createassistant.pulse()
# New assistant ID will appear in oai_op.par.AssistantidSending a Message
Section titled “Sending a Message”oai_op = op('oai_assistant1')
# Ensure an Assistant ID and Thread ID are selected/active# If no thread exists, create one:# oai_op.par.CreateNewThread.pulse()
oai_op.par.Message = "Explain quantum entanglement."oai_op.par.Sendmessage.pulse()
# Response will appear in oai_op.op('conversation_dat') after run completesModifying an Assistant
Section titled “Modifying an Assistant”oai_op = op('oai_assistant1')
# Select the assistant to modify via oai_op.par.Assistantid
# Change instructions or other parametersoai_op.par.Instructions = 'You are now a very sarcastic tutor.'oai_op.par.Modifyassistant.pulse()Common Use Cases
Section titled “Common Use Cases”- Building chatbots using OpenAI Assistants.
- Automating tasks requiring persistent context (threads).
- Integrating AI assistants with file search or code execution capabilities.
- Creating complex AI workflows within TouchDesigner.