OpenAI Assistant for File Retrieval with Citation Formatting
detail.loadingPreview
Automates generating structured metadata from OpenAI assistant responses, ensuring citations and file sources are correctly identified and formatted.
About This Workflow
This workflow leverages n8n to interact with an OpenAI Assistant configured for file retrieval (RAG). It focuses on extracting and formatting citations from the assistant's responses, ensuring that references to files within the vector store are clearly indicated. The workflow retrieves all thread messages, processes them to isolate citation details, fetches file names, and then formats the output to include these citations, optionally transforming them into Markdown or HTML links.
Key Features
- Utilizes n8n's Langchain nodes for seamless OpenAI assistant integration.
- Handles file retrieval and citation extraction from OpenAI assistant responses.
- Fetches file names associated with citations for better context.
- Formats the assistant's output to include source citations.
- Supports optional conversion of formatted citations to Markdown or HTML.
How To Use
- Setup OpenAI Key: Ensure your OpenAI API key is configured in n8n.
- Configure Assistant: Use an existing OpenAI Assistant ID that is set up with a vector store for file retrieval.
- Trigger Workflow: The
@n8n/n8n-nodes-langchain.chatTriggernode acts as a chat button within n8n, initiating the workflow. - Retrieve Thread Content: The
OpenAI Assistant with Vector Storenode sends queries to the assistant, andGet ALL Thread Contentretrieves all messages from the conversation thread. - Process Messages:
Split all message iterations from a thread,Split all content from a single message, andSplit all citations from a single messagenodes are used to parse the complex response structure and isolate citation annotations. - Fetch File Details:
Retrieve file name from a file IDmakes an API call to get the actual filename for each citation. - Regularize Output:
Regularize outputstandardizes the extracted citation information (ID, filename, text). - Aggregate and Format:
Aggregateconsolidates the processed citation data.Finnaly format the outputuses a JavaScript code node to replace the placeholder text in the assistant's response with the formatted citation (e.g.,_(filename)_). - Optional HTML Conversion: The
Optional Markdown to HTMLnode (disabled by default) can be enabled to convert Markdown-formatted citations to HTML.
Apps Used
Workflow JSON
{
"id": "6136129c-0403-4bed-b5fd-bc63d428ed8d",
"name": "OpenAI Assistant for File Retrieval with Citation Formatting",
"nodes": 18,
"category": "AI/ML",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: 6136129c-0403...
About the Author
N8N_Community_Pick
Curator
Hand-picked high quality workflows from the global community.
Statistics
Related Workflows
Discover more workflows you might like
RAG AI Agent with Milvus and Cohere
Automates the creation of a Retrieval-Augmented Generation (RAG) AI agent. It ingests documents from Google Drive, processes them, embeds them using Cohere, stores them in Milvus, and enables chat-based interaction for context-aware responses.
RAG Document Update and Management with Qdrant and Google Drive
Automates RAG system updates using Qdrant vector store and Google Drive documents.
Crop Anomaly Detection Tool
Detects if an input image depicts an anomalous crop not present in the trained dataset.