Skip to content

Rag Retriever Operator

The RAG Retriever LOP retrieves relevant context from a pre-built index (created by a Rag Index LOP) based on a given query. It enhances the capabilities of Language Model Operators (LOPs) by providing contextual information to improve the accuracy and relevance of generated text. The operator supports various search modes, similarity thresholds, and output formats, making it a versatile tool for Retrieval Augmented Generation (RAG) workflows within TouchDesigner.

Note: This operator requires the llama-index Python library and access to a running Rag Index LOP.

Parameters are organized into pages.

Query Index (Query) op('rag_retriever').par.Query Pulse
Default:
None
RAG Index OP (Indexsource) op('rag_retriever').par.Indexsource COMP
Default:
None
Search Mode (Searchmode) op('rag_retriever').par.Searchmode Menu
Default:
custom
Options:
last_user, full_chat, last_assistant, custom
Query Phrase (Queryphrase) op('rag_retriever').par.Queryphrase Str
Default:
None
Status Log (Statuslog) op('rag_retriever').par.Statuslog Str
Default:
"" (Empty String)
Clear Results (Clearresults) op('rag_retriever').par.Clearresults Pulse
Default:
None
Top K Results (Topk) op('rag_retriever').par.Topk Int
Default:
10
Range:
1 to 100
Slider Range:
1 to 20
Similarity Threshold (Similaritythreshold) op('rag_retriever').par.Similaritythreshold Float
Default:
0.5
Range:
0 to 1
Slider Range:
0 to 1
Top Result Only (Topresultonly) op('rag_retriever').par.Topresultonly Toggle
Default:
Off
Add Text (Addtext) op('rag_retriever').par.Addtext Str
Default:
Here is the relevant context for answering the user's question:
Active Index (Indexstatus) op('rag_retriever').par.Indexstatus Toggle
Default:
Off
Display Results (Displayresults) op('rag_retriever').par.Displayresults Toggle
Default:
On
Out1 Output Mode (Outputmode) op('rag_retriever').par.Outputmode Menu
Default:
chat
Options:
raw, chat
ChatTD (Chattd) op('rag_retriever').par.Chattd OP
Default:
/dot_lops/ChatTD
Show Built In Pars (Showbuiltin) op('rag_retriever').par.Showbuiltin Toggle
Default:
Off
Bypass (Bypass) op('rag_retriever').par.Bypass Toggle
Default:
Off
Available Callbacks:
  • onRetrievalComplete
  • onError
  • onStatusUpdate
1. Point 'RAG Index OP' to a configured Rag Index LOP.
2. Set 'Search Mode' to `custom`.
3. Enter query in 'Query Phrase'.
4. Adjust 'Top K' and 'Similarity Threshold'.
5. Pulse 'Query Index'.
6. Results appear in `output1` (raw text) and `output_table` (chat format).
1. Connect a chat table (DAT) to Input 1.
2. Point 'RAG Index OP' to a configured Rag Index LOP.
3. Set 'Search Mode' to `last_user` or `full_chat`.
4. Pulse 'Query Index'.
5. `output_table` will contain the original chat plus a system message with context.
  • Retrieval is performed asynchronously to avoid blocking the main TouchDesigner thread.
  • Performance depends on the size of the index, the complexity of the query, Top K, and Similarity Threshold.
  • Ensure the specified RAG Index OP contains a loaded and accessible index.
  • The output table (output_table) is formatted for direct use with downstream LLM operators like Agent or Chat.
  • The raw text output (output1) provides chunks separated by ---.