Extension:Wanda
Release status: stable |
|
|---|---|
| Implementation | Artificial intelligence, API, Data extraction, Page action, Search, Special page |
| Description | Wanda is a MediaWiki extension that provides an AI-powered chatbot interface for your wiki. It can answer questions about your wiki content using various LLM providers and includes both a dedicated special page and a floating chat widget. |
| Author(s) | Sanjay Thiyagarajan (Techwizzietalk) |
| Maintainer(s) | Techwizzietalk |
| Latest version | 2.0.0 (2025-10-24) |
| Compatibility policy | For every MediaWiki release that is a Long Term Support release there is a corresponding branch in the extension. |
| MediaWiki | 1.42+ |
| PHP | 7.4+ |
| Database changes | No |
| License | GNU General Public License 2.0 or later |
| Download | |
| Translate the Wanda extension if it is available at translatewiki.net | |
| Issues | Open tasks · Report a bug |
Wanda is a MediaWiki extension that provides an AI-powered chatbot interface for your wiki. It can answer questions about your wiki content using various LLM providers and includes both a dedicated special page and a floating chat widget.
Wanda also provides an API that allows other extensions and services to interact with the outside LLM as well, providing AI functionality based on the wiki content. Currently two other extensions make use of the Wanda API:
- WandaScore - provides feedback on the quality of any wiki page
- WandaScribe - offers suggestions on improving the writing of any selected text within a page.
Requirements
[edit]- MediaWiki 1.42.0 or later
- Elasticsearch server (for content indexing and search)
- CirrusSearch is the easiest approach
- One of the supported LLM providers:
- Ollama (self-hosted) - recommended for privacy
- OpenAI API access
- Anthropic Claude API access
- Azure OpenAI service
Installation
[edit]- Download and move the extracted
Wandafolder to yourextensions/directory.
Developers and code contributors should install the extension from Git instead, using:cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Wanda
- Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'Wanda' );
- Ensure the Requirements are met.
- If you are adding the extension to an existing wiki, reindex ElasticSearch:
php extensions/Wanda/maintenance/ReindexAllPages.php
Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Features
[edit]- Multiple LLM Providers: Support for Ollama (self-hosted), OpenAI, Anthropic Claude, and Azure OpenAI
- Text Search: Uses ElasticSearch's text-based search
- Floating Chat Widget: Always-accessible chat button on all pages
- Special Page: Dedicated chat interface at
Special:Wanda - Responsive Design: Works on desktop and mobile devices
- Secure Configuration: API key management and timeout controls
- Content Indexing: Automatic indexing of wiki pages and file uploads
Configuration
[edit]Basic Configuration
[edit]Add these configuration variables to your LocalSettings.php after loading the extension:
// Choose your LLM provider
$wgWandaLLMProvider = 'ollama'; // Options: 'ollama', 'openai', 'anthropic', 'azure'
// Provider-specific settings
$wgWandaLLMApiKey = 'your-api-key-here'; // Not needed for Ollama
$wgWandaLLMModel = 'gemma:2b'; // Model name to use for the LLM provider
$wgWandaLLMApiEndpoint = 'http://localhost:11434/api/'; // API endpoint URL for the LLM provider
// Elasticsearch configuration (required for content search)
$wgWandaLLMElasticsearchUrl = 'http://elasticsearch:9200';
// UI and interface settings
$wgWandaShowPopup = true; // Show/hide the floating chat widget on all pages
// Custom prompt settings
$wgWandaCustomPrompt = ''; // Custom prompt template to override default behavior
$wgWandaCustomPromptTitle = ''; // Wiki page title containing custom prompt template
// LLM behavior settings
$wgWandaLLMMaxTokens = 1000; // Maximum tokens in LLM responses
$wgWandaLLMTemperature = '0.7'; // Creativity/randomness setting (0.0-1.0)
$wgWandaLLMTimeout = 30; // Request timeout in seconds for LLM calls
// Indexing settings
$wgWandaAutoReindex = true; // Automatically reindex content after update.php
$wgWandaSkipESQuery = false; // Skip Elastic Search
$wgWandaMaxImageSize = 5242880; // Maximum size allowed for an image
$wgWandaMaxImageCount = 10; // Maximum number of images that can be attached with the single request
Provider-Specific Examples
[edit]Ollama (Self-hosted)
[edit]$wgWandaLLMProvider = 'ollama';
$wgWandaLLMApiEndpoint = 'http://localhost:11434/api/';
$wgWandaLLMModel = 'gemma:2b';
$wgWandaLLMEmbeddingModel = 'nomic-embed-text';
OpenAI
[edit]$wgWandaLLMProvider = 'openai';
$wgWandaLLMApiKey = 'sk-your-openai-api-key';
$wgWandaLLMModel = 'gpt-3.5-turbo';
$wgWandaLLMEmbeddingModel = 'text-embedding-ada-002';
Anthropic Claude
[edit]$wgWandaLLMProvider = 'anthropic';
$wgWandaLLMApiKey = 'sk-ant-your-anthropic-key';
$wgWandaLLMModel = 'claude-3-haiku-20240307';
Azure OpenAI
[edit]$wgWandaLLMProvider = 'azure';
$wgWandaLLMApiKey = 'your-azure-api-key';
$wgWandaLLMApiEndpoint = 'https://your-resource.openai.azure.com/';
$wgWandaLLMModel = 'gpt-35-turbo';
LLM Configuration Parameters
[edit]All configuration parameters with their default values:
| Variable | Default Value | Description |
|---|---|---|
$wgWandaLLMProvider |
'ollama' |
LLM provider to use |
$wgWandaLLMApiEndpoint |
'http://ollama:11434/api/' |
API endpoint URL |
$wgWandaLLMApiKey |
|
API key for external providers |
$wgWandaLLMModel |
'gemma:2b' |
Model name to use |
$wgWandaLLMEmbeddingModel |
'nomic-embed-text' |
Embedding model for vector search |
$wgWandaLLMElasticsearchUrl |
'http://elasticsearch:9200' |
Elasticsearch server URL |
$wgWandaLLMMaxTokens |
1000 |
Maximum tokens in responses |
$wgWandaLLMTemperature |
0.7 |
Response creativity (0.0-1.0) |
$wgWandaLLMTimeout |
30 |
API request timeout in seconds |
Usage
[edit]Special Page
[edit]Visit Special:Wanda on your wiki to access the full-featured chat interface.
Floating Chat Widget
[edit]The floating chat widget appears on all pages (except Special:Wanda) as a chat button in the bottom-right corner. Click it to open the chat interface.
Add the following configuration in LocalSettings.php to show/hide the floating chat widget.
$wgWandaShowPopup = true;
Content Indexing
[edit]To enable the chatbot to answer questions about your wiki content, you need to index your pages in Elasticsearch with embeddings. Use the maintenance script:
php maintenance/runScript.php extensions/Wanda/maintenance/ReindexAllPages.php
This script will:
- Process all pages in your wiki
- Generate embeddings for content chunks
- Store the indexed content in Elasticsearch
- Enable semantic search capabilities
API
[edit]The extension provides an API module accessible via api.php?action=wandachat.
Parameters
[edit]| Parameter | Required | Description |
|---|---|---|
action |
Yes | Must be set to wandachat
|
message |
Yes | The user's question or data to be processed |
format |
No | Response format, recommended: json
|
usepublicknowledge |
No | Allow fallback to public knowledge when wiki context is insufficient (default: false)
|
provider |
No | Override LLM provider (ollama, openai, anthropic, azure, gemini)
|
model |
No | Override the model name for the request |
apikey |
No | Override API key for the request |
apiendpoint |
No | Override API endpoint URL |
maxtokens |
No | Override maximum tokens in the response |
temperature |
No | Override creativity/randomness setting (0.0–1.0) |
timeout |
No | Override request timeout in seconds |
customprompt |
No | Override the default prompt template |
customprompttitle |
No | Override using content from a wiki page as prompt template |
skipesquery |
No | Skip Elastic search query |
Example Request
[edit]api.php?action=wandachat&question=How%20do%20I%20create%20a%20new%20page&format=json
Example Response
[edit]{
"wandachat": {
"response": "To create a new page in MediaWiki, you can...",
"success": true
}
}
Hooks
[edit]The extension uses several MediaWiki hooks:
PageSaveComplete
[edit]Automatically indexes pages when they are saved or updated.
UploadComplete
[edit]Indexes uploaded files for content search.
BeforePageDisplay
[edit]Adds the floating chat widget to pages.
Architecture
[edit]The extension follows this workflow:
- Content Indexing: Standard text-based Elasticsearch
- Query Processing: Standard text-based Elasticsearch
- Similarity Search: Standard text-based Elasticsearch
- Response Generation: The LLM generates responses based on the retrieved content
Future workflow for vector embeddings (once MW supports ElasticSearch 8 or another vector database is used):
- Content Indexing: Wiki pages are processed and stored in Elasticsearch with embeddings
- Query Processing: User queries are converted to embeddings (when available)
- Similarity Search: Elasticsearch finds the most relevant content using vector search
- Response Generation: The LLM generates responses based on the retrieved content
- Fallback Mechanism: Falls back to text-based search when embeddings are unavailable
Security Considerations
[edit]- API keys are stored securely in MediaWiki configuration files
- Content is processed by your chosen LLM provider - consider data privacy implications
- For sensitive wikis, consider using self-hosted Ollama instead of external services
- Configure appropriate timeouts and rate limits to prevent abuse
- The floating chat widget and special page respect MediaWiki user permissions
Troubleshooting
[edit]Common Issues
[edit]Chat not responding
- Verify your LLM provider configuration
- Check that the API endpoint is accessible
- Ensure API keys are correctly configured for external providers
No relevant results
- Run the content indexing script:
php maintenance/runScript.php extensions/Wanda/maintenance/ReindexAllPages.php - Verify Elasticsearch is running and accessible
- Check that pages contain sufficient content for indexing
Floating chat not appearing
- Ensure the extension is properly loaded in LocalSettings.php
- Check that JavaScript is enabled in the browser
- Verify the page is not Special:Wanda (widget is disabled there)
Version History
[edit]- 1.0.0
- Initial release with multi-provider LLM support, Elasticsearch integration, and floating chat widget.
- 2.0.0
- Implement public knowledge addition, OOUI to Codex migration, rename API action to 'wandachat', allow LLM parameters override using API parameters.
- Stable extensions
- Artificial intelligence extensions
- API extensions
- Data extraction extensions
- Page action extensions
- Search extensions
- Special page extensions
- GPL licensed extensions
- Extensions in Wikimedia version control
- PageSaveComplete extensions
- UploadComplete extensions
- BeforePageDisplay extensions
- All extensions
