What is the purpose of the 'Data to Message' component in the RAG workflow, and what configuration does it require?
The Data to Message component converts the table output of the vector database search into plain text, which the LLM can use in the prompt. It requires a Template parameter that describes the output format by referencing column names in curly brackets, such as setting it to {text} to extract the chunk text column.
In the RAG workflow, the retrieval step returns a table with columns such as file_path and text, one row per retrieved chunk. Because the LLM needs a text-based prompt, the Data to Message component transforms this Data-format table into a Text-format string. Its key configuration is the Template parameter, which defines the output format using the column names inside curly brackets. Setting the template to {text} extracts only the chunk text from the table. The component's data input is connected to the Chroma DB's Search Results output, and its output can then be connected to the Prompt component's context input.
Key points
- Data to Message converts Data-format tables into Text-format strings.
- It is used after the vector DB retrieval to turn the table of retrieved chunks into plain text.
- The Template configuration specifies how to format the output by referencing column names in curly brackets.
- A template of {text} extracts the actual chunk text column from the retrieval results.
- The component's Data input receives the Search Results from the Chroma DB component.
Related questions
- In the Langflow flow described in the chapter, what is the exact prompt template used to combine the user query with the retrieved context, and what are the two input ports that appear on the Prompt component after entering this template?
- What is the purpose of the Chunk Overlap parameter in the Split Text component, and what value is set in the example?
AI Agents and Applications
Andrea De Mauro
MEAP Edition Version 7 · Manning Publications