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.
- Multiple LLM Providers: Support for Ollama (self-hosted), OpenAI, Anthropic Claude, Azure OpenAI, and Google Gemini
- Vector-Based Semantic Search: Uses high-dimensional embeddings for intelligent content retrieval with configurable similarity thresholds
- Dual Search Strategy: Automatic fallback from vector search to text-based search for reliability
- Floating Chat Widget: Always-accessible chat button on all pages
- Editing: Allowed users can additionally create and edit pages via natural-language queries
- Image Analysis: Ask questions about images that have been uploaded to the wiki
- Additional Text Querying: Query text data from local files, or external wikis
- Structured Data Querying: Query structured data from the MediaWiki extensions Cargo and Semantic MediaWiki, or Wikibase installations (e.g. Wikidata)
- Special Page: Dedicated chat interface at Special:Wanda
- Responsive Design: Works on desktop and mobile devices
- Secure Configuration: API key management and timeout controls
- Clone or download this extension to your MediaWiki
extensions/directory - Add the following to your
LocalSettings.php:
wfLoadExtension( 'Wanda' );- Configure your preferred LLM provider (see Configuration section)
- Run MediaWiki update script:
php maintenance/update.phpAdd these configuration variables to your LocalSettings.php:
// Choose your LLM provider
$wgWandaLLMProvider = 'ollama'; // Options: 'ollama', 'openai', 'anthropic', 'azure', 'gemini'
// 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
// Search engine (Elasticsearch or OpenSearch) configuration
$wgWandaSearchEngineUrl = 'http://localhost:9200';
// Embedding model configuration (for semantic search)
$wgWandaLLMEmbeddingModel = 'text-embedding-004'; // Model for generating embeddings
// Vector search configuration
$wgWandaVectorSearchMinScore = 1.7; // Minimum similarity score threshold (1.0-2.0, default: 1.7)
// UI and interface settings
$wgWandaShowPopup = true; // Show/hide the floating chat widget on all pages
$wgWandaEnableAttachments = true; // Show/hide the "Attach images" icon
// Editing (experimental) — see the "Editing" section below
$wgWandaEnableEditing = false; // Allow authorized users to edit pages via Wanda
// 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
// Cargo structured data integration
$wgWandaCargoExcludedTables = []; // Array of Cargo table names to exclude from queriesThe Wanda extension provides a MediaWiki API module called wandachat for programmatic access to the AI chat functionality. This API allows you to send questions and receive AI-generated responses based on your wiki's content.
Required Parameters:
action(string) - Must be set towandachatmessage(string) - The user's question or query
Optional Parameters:
-
format(string) - Response format, recommended:json -
sources(string) - A pipe-delimited list of sources to query (default:wiki) -
temperature(float) - Creativity/randomness setting for this request (0.0-1.0). Ignored when the provider isgemini, which no longer accepts sampling parameters
The module must be called with POST and requires the wanda-chat user right, which is
granted to everyone by default. To restrict the chatbot to logged-in users:
$wgGroupPermissions['*']['wanda-chat'] = false;
$wgGroupPermissions['user']['wanda-chat'] = true;The LLM provider, model, API key, endpoint, token limit, timeout and custom prompt are taken only from the wiki configuration and cannot be overridden per request.
Ollama (Self-hosted)
$wgWandaLLMProvider = 'ollama';
$wgWandaLLMApiEndpoint = 'http://localhost:11434/api/';
$wgWandaLLMModel = 'gemma:2b';OpenAI
$wgWandaLLMProvider = 'openai';
$wgWandaLLMApiKey = 'sk-your-openai-api-key';
$wgWandaLLMModel = 'gpt-3.5-turbo';Anthropic Claude
$wgWandaLLMProvider = 'anthropic';
$wgWandaLLMApiKey = 'sk-ant-your-anthropic-key';
$wgWandaLLMModel = 'claude-3-haiku-20240307';Google Gemini (Generative Language API)
$wgWandaLLMProvider = 'gemini';
$wgWandaLLMApiKey = 'your-gemini-api-key'; // Obtain from Google AI Studio
$wgWandaLLMModel = 'gemini-1.5-flash'; // Or gemini-1.5-pro, etc.
// Optional: override endpoint (default used if omitted)
$wgWandaLLMApiEndpoint = 'https://generativelanguage.googleapis.com/v1';For detailed configuration options, see LLM-CONFIG.md.
The floating chat widget appears on all pages (except Special:Wanda) as a blue 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;Visit Special:Wanda on your wiki to access the full-featured chat interface.
To enable the chatbot to answer questions about your wiki content, you need to index your pages in Elasticsearch. Use the maintenance script:
php extensions/Wanda/maintenance/ReindexAllPages.phpYou can configure a custom prompt in two ways:
- Use a custom prompt directly
$wgWandaCustomPrompt = "Custom_Prompt_to_be_used";- Use a custom prompt from a wiki page
$wgWandaCustomPromptTitle = "Title_of_the_page";Note: If both $wgWandaCustomPrompt and $wgWandaCustomPromptTitle are set, $wgWandaCustomPrompt will take precedence.
This extension now schedules a full reindex automatically after you run php maintenance/update.php by registering the maintenance script as a post-update task. On large wikis this may be time-consuming. If you prefer to disable auto reindexing, remove the LoadExtensionSchemaUpdates hook entry from extension.json or replace the full reindex with a lighter custom script.
To keep indexing continuously fresh without large batch jobs, the extension also updates the index on page saves and file uploads via hooks.
You can also control this behavior via a configuration flag. Add to LocalSettings.php:
// Disable automatic full reindex after update.php
$wgWandaAutoReindex = false;When set to false, the hook will skip scheduling the maintenance script; you can still run it manually:
php extensions/Wanda/maintenance/ReindexAllPages.phpWanda can query structured data stored in Cargo tables alongside its Elasticsearch-based search. When enabled, Wanda uses the LLM to generate structured queries against Cargo tables based on the user's natural language question.
- Install and configure the Cargo extension
- (Optional) Exclude specific tables in
LocalSettings.php:
// Optionally exclude specific tables
$wgWandaCargoExcludedTables = ['InternalTable', 'TempData'];- Wanda auto-discovers all Cargo tables and their schemas
- When a user asks a question, the LLM receives the table schemas and generates a structured Cargo query (or determines no query is relevant)
- The query is validated and executed against the Cargo database
- Results are combined with Elasticsearch results and fed to the LLM for the final answer
Cargo results include source links:
- Row-level: Links to
PageName?action=pagevaluesshowing the page's stored Cargo data - Table-level: Links to
Special:CargoTables/TableNameshowing the full table
To disable Cargo querying, add the following to LocalSettings.php:
$wgWandaDisabledSources[] = 'cargo';If the Semantic MediaWiki (SMW) extension is installed, then by default Wanda will include its data as a source that can be queried.
The following configuration variables exist for SMW querying:
$wgWandaSMWExcludedProperties- an array holding the names of properties to not query on$wgWandaSMWMaxQuerySteps- the maximum number of steps to use for querying (default is 3)$wgWandaSMWMaxResults- the maximum number of results to show (default is 50)
To disable Semantic MediaWiki querying, add the following to LocalSettings.php:
$wgWandaDisabledSources[] = 'smw';If the Approved Revs extension is installed, Wanda can index only the approved revision of each approvable page, so that answers are never based on unreviewed content. To enable this, add the following to LocalSettings.php:
$wgWandaIndexApprovedOnly = true;When enabled:
- Approvable pages are indexed using their approved revision; approving a different revision reindexes the page.
- Approvable pages with no approved revision are removed from the index.
- Pages that are not approvable (including files) are indexed using their latest revision, as before.
After changing this setting, run ReindexAllPages.php to bring the existing index in line.
Wanda supports querying Wikibase installations (such as Wikidata) as sources, allowing users to query facts with natural-language queries.
By default, Wikidata is configured via $wgWandaWikibaseSources:
$wgWandaWikibaseSources = [
'wikidata' => [
'apiUrl' => 'https://www.wikidata.org/w/api.php',
'sparqlEndpoint' => 'https://query.wikidata.org/sparql',
'lang' => 'en',
],
];Wanda can query local files (text, PDF, etc.) using retrieval-augmented generation (RAG). To add a group of files as a single source for querying, add something like the following to LocalSettings.php:
$wgWandaRAGSources['Financial records'] = [ '2025 financials.txt', '2026 financials.pdf' ];To add an external wiki as a data source, add something like the following to LocalSettings.php:
$wgWandaExternalWikis['Ballotpedia'] = [ 'url' => 'https://ballotpedia.org', 'namespaces' => [0] ];The Wanda interface enables users to specify images that have been previously uploaded to the wiki and ask questions about them.
The following configuration variables exist for image analysis:
$wgWandaMaxImageSize- the maxiumum size for an image that can be analyzed, in bytes (default is 5242880)$wgWandaMaxImageCount- the maximum number of images that can be analyzed at one time (default is 10)
Wanda can edit wiki pages on request. This is delivered incrementally; the current phase supports free-text and infobox / template field edits on a single page (for example, "Change the value of John Smith's 'Phone number' field to 555-1212" or "Reword the first sentence to mention she is a marine biologist"). The page does not need to contain an infobox. If the target page does not exist yet, Wanda proposes the full wikitext for the new page and creates it when the user confirms.
Editing is disabled by default and gated by two layers:
-
The feature flag
$wgWandaEnableEditing = true;inLocalSettings.php. -
The
wanda-edituser right, granted to thesysopgroup by default. Grant it to other groups as needed:$wgGroupPermissions['editor']['wanda-edit'] = true;
Wanda also respects each page's own edit permissions (protection, Lockdown, etc.), so it can never edit a page the requesting user could not edit manually.
- In
Special:Wandaor the floating widget, authorized users see an Edit mode checkbox. - With edit mode on, a Page to edit input appears next to the checkbox, prefilled with the current page. The user adjusts it as needed (entering a title that does not exist yet creates that page) and types an editing instruction.
- Wanda asks the LLM for the proposed wikitext and shows a diff preview. Nothing is saved yet.
- The user clicks Apply edit to save. The revision is attributed to the requesting user with an edit summary noting it was AI-assisted via Wanda.
A write API module wandaedit powers the feature (requires a CSRF token and POST):
| Parameter | Description |
|---|---|
message |
Natural-language editing instruction |
title |
Page to edit (created if it does not exist) |
confirm |
false (default) returns a preview diff without saving; true saves newtext |
newtext |
The previewed wikitext to save (required when confirm=true) |
- MediaWiki 1.36.0 or later
- PHP 7.4 or later
- Elasticsearch (with dense_vector support for semantic search)
- One of the supported LLM providers:
- Ollama (self-hosted)
- OpenAI API access
- Anthropic Claude API access
- Azure OpenAI service
- Google Gemini (Generative Language API)
- Cargo extension (optional, for structured data queries)
- Content Indexing: Wiki pages (and extracted PDF text) are chunked and stored in Elasticsearch with semantic embeddings
- Query Processing: User queries are converted to embeddings using the configured embedding model
- Vector Search: Elasticsearch performs cosine similarity search with configurable threshold
- Similarity Score Range: 1.0 (no similarity) to 2.0 (perfect match)
- Default Threshold: 1.7 (cosine similarity ≥ 0.7)
- Configuration: Adjustable via
$wgWandaVectorSearchMinScore
- Fallback Strategy: If vector search fails or returns no results, falls back to text-based BM25 search
- Cargo Queries: If enabled, the LLM generates structured queries against Cargo tables in parallel; results are merged with Elasticsearch context
- Response Generation: The LLM generates answers based on the combined context from Elasticsearch and Cargo
- Incremental Updates: Page save and file upload hooks automatically regenerate embeddings and update the index
- API keys are stored securely in MediaWiki configuration
- Content is processed by your chosen LLM provider
- For sensitive wikis, consider using self-hosted Ollama
- Configure appropriate timeouts and rate limits
Contributions are welcome! Please feel free to submit issues and pull requests.
This extension is licensed under the MIT License.