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
Section titled “Parameters”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
Query Phrase (Queryphrase)
op('rag_retriever').par.Queryphrase Str - Default:
None
Add Text (Addtext)
op('rag_retriever').par.Addtext Str - Default:
None
Status Log (Statuslog)
op('rag_retriever').par.Statuslog Str - Default:
None
Active Index (Indexstatus)
op('rag_retriever').par.Indexstatus Toggle - Default:
None
Top Result Only (Topresultonly)
op('rag_retriever').par.Topresultonly Toggle - Default:
Off
Top K Results (Topk)
op('rag_retriever').par.Topk Int - Default:
0- Range:
- 0 to 10
Similarity Threshold (Similaritythreshold)
op('rag_retriever').par.Similaritythreshold Float - Default:
0- Range:
- 0 to 1
Display Results (Displayresults)
op('rag_retriever').par.Displayresults Toggle - Default:
Off
Clear Results (Clearresults)
op('rag_retriever').par.Clearresults Pulse - Default:
None
ChatTD (Chattd)
op('rag_retriever').par.Chattd OP - Default:
None
Show Built In Pars (Showbuiltin)
op('rag_retriever').par.Showbuiltin Toggle - Default:
Off
Bypass (Bypass)
op('rag_retriever').par.Bypass Toggle - Default:
Off
Version (Version)
op('rag_retriever').par.Version Str - Default:
None
Lastupdated (Lastupdated)
op('rag_retriever').par.Lastupdated Str - Default:
None
Creator (Creator)
op('rag_retriever').par.Creator Str - Default:
None
Website (Website)
op('rag_retriever').par.Website Str - Default:
None
Callbacks
Section titled “Callbacks” Available Callbacks:
onRetrievalCompleteonErroronStatusUpdate
Usage Examples
Section titled “Usage Examples”Basic Retrieval with Custom Query
Section titled “Basic Retrieval with Custom Query”- Point ‘RAG Index OP’ to a configured Rag Index LOP.
- Set ‘Search Mode’ to
Custom. - Enter your query in ‘Query Phrase’.
- Adjust ‘Top K Results’ and ‘Similarity Threshold’.
- Pulse ‘Query Index’.
- Results appear in
output1(raw text) andoutput_table(chat format).
Retrieval from Chat History
Section titled “Retrieval from Chat History”- Connect a chat table (DAT) to Input 1.
- Point ‘RAG Index OP’ to a configured Rag Index LOP.
- Set ‘Search Mode’ to
Last UserorFull Chat. - Pulse ‘Query Index’.
output_tablewill contain the original chat plus a system message with context.
Technical Notes
Section titled “Technical Notes”- 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, andSimilarity Threshold. - Ensure the specified
RAG Index OPcontains 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---.