Table of Contents
Retrieval Augmented Generation (RAG) Configuration
Community Edition
Please note: we've renamed our products! SWIRL AI Connect is now SWIRL AI Search π and SWIRL AI Co-Pilot is now SWIRL AI Search Assistant π€
SWIRL supports Real-Time Retrieval Augmented Generation (RAG) out of the box, using result snippets and/or the full text of fetched result pages.
Configuring RAG
-
Install SWIRL as noted in the Quick Start Guide, including the latest version of the Galaxy UI.
-
Add your OpenAI API key or Azure OpenAI credentials to the
.env
file:OPENAI_API_KEY='your-key-here'
Check out OpenAI's YouTube video if you don't have an OpenAI API Key.
AZURE_OPENAI_KEY=<your-key> AZURE_OPENAI_ENDPOINT=<your-azure-openai-endpoint-url> AZURE_MODEL=<your-azure-openai-model>
SWIRL AI Search Community Edition supports RAG only with OpenAI and Azure OpenAI.
The Enterprise Edition supports additional providers. -
For PRODUCTION use, update
static/api/config/default
:Change this:
"webSocketConfig": { "url": "ws://<yourhost>:<your-port>/chatgpt-data" }
β¦to this:
"webSocketConfig": { "url": "wss://<yourhost>:<your-port>/chatgpt-data" }
Using
ws://
locally is fine, but it is not secure for production! -
Configure SearchProviders for RAG:
Modify the
page_fetch_config_json
parameter for each SearchProvider:"page_fetch_config_json": { "cache": "false", "headers": { "User-Agent": "Swirlbot/1.0 (+http://swirl.today)" }, "timeout": 10 }
- Adjust
timeout
if needed. - Change
User-Agent
if required. - Authorize SWIRL to fetch pages from internal applications.
To override the timeout via the Galaxy UI, use:
http://localhost:8000/galaxy/?q=gig%20economics&rag=true&rag_timeout=90
- Adjust
-
Restart SWIRL:
python swirl.py restart
-
Run a Search in the Galaxy UI:
- Open http://localhost:8000/galaxy/.
- Ensure the "Generate AI Response" switch is off.
- Search for:
http://localhost:8000/galaxy/?q=SWIRL+AI+Connect
Results appear:
-
Manually Select Results for RAG (Optional):
- Click "Select Items" to enable manual selection.
- Pre-selected results indicate SWIRL's best matches for RAG.
- Check/uncheck results, sort, or filter.
- Click "Generate AI Response".
- A spinner appears; results follow within seconds.
-
Verify citations under the RAG response.
To cancel a RAG process, toggle "Generate AI Summary" off.
By default, SWIRL's RAG uses the first 10 selected results (auto or manual).
To adjust this, setSWIRL_RAG_MAX_TO_CONSIDER
in.env
, as noted in the AI Search Guide.
SWIRL RAG Process:
SWIRL's RAG workflow is shown above, and explained below:
- Search - SWIRL sends the users query to one or more SearchProviders, then aggregates and normalizes the results
- Re-Rank - The last step of the Search workflow re-ranks the aggregated, normalized results to find the most relevant results across all sources
- Review - SWIRL supports presenting re-ranked results for review and optional adjustment, prior to executing the rest of the workflow
- Fetch - This involves following the result link and downloading the full text or data set of the result
- Read - SWIRL extracts text from 1,500 file formats then identifies the most relevant passages while chunking it for the next step
- Prompt - SWIRL binds the chunked text to the appropriate prompt, connects to the configured LLM, sends the prompt and waits patiently for the response
- Package - Finally, SWIRL compiles the results, prompt and response and returns it in a neat JSON package, ready for visualization in SWIRL's Galaxy Search UI
Enterprise RAG Support
- The Community Edition can fetch publicly accessible sources.
- For RAG with enterprise services (e.g., Microsoft 365, ServiceNow, Salesforce, Atlassian) with OAuth2 and SSO, contact us for SWIRL Enterprise.
Preloaded RAG Configurations
The following SearchProviders come pre-configured for RAG:
β
European PMC
β
Google Web
β
Google News
β
LinkedIn
β
SWIRL Documentation
API-Based RAG Processing
RAG processing is available via a single API call:
?qs=metasearch&rag=true
For details, see the Developer Guide.
Configuring Timeout Behavior
- The default timeout is 60 seconds.
- To modify the timeout and error message, update:
"webSocketConfig": {
"url": "ws://localhost:8000/chatgpt-data",
"timeout": 60000,
"timeoutText": "Timeout: No response from Generative AI."
}