Skip to content

Commit 4b269cf

Browse files
committed
feat: 4 new search providers — Tavily, Google CSE, Wikipedia, Wikidata
- Added Tavily AI-optimized search (POST API, AI summary, 1,000/mo free) - Added Google Custom Search Engine (GET API, key:cx format, 100/day free) - Added Wikipedia API (free, MediaWiki action=query, HTML-stripped snippets) - Added Wikidata API (free, wbsearchentities, structured knowledge) - Added API_KEY_TAVILY and API_KEY_GOOGLE_CSE storage keys - Updated dropdowns in ai-docgen.js (3 locations), modal-templates.js, help-mode.js - Wikipedia/Wikidata skip API key prompt (free providers)
1 parent 8bc8b51 commit 4b269cf

7 files changed

Lines changed: 265 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
| **AI Document Tags** | `{{@AI:}}` text generation, `{{@Think:}}` deep reasoning, `{{@Image:}}` image generation (Gemini Imagen), `{{@OCR:}}` image-to-text extraction (Text/Math/Table modes via Granite Docling 258M or Florence-2 230M, PDF page rendering via pdf.js), `{{@TTS:}}` text-to-speech playback (Kokoro TTS per card, language selector, ▶ Play / ⬇ Save WAV), `{{@STT:}}` speech-to-text dictation (engine selector: Whisper/Voxtral/Web Speech API, 11 languages, Record/Stop/Insert/Clear), `{{@Translate:}}` translation (target language selector, integrated TTS pronunciation, cloud model routing), `{{@Game:}}` game builder (AI-generated or pre-built, Canvas 2D/Three.js/P5.js, import/export HTML) — `@` prefix syntax on all tag types + metadata fields (`@name`, `@use`, `@think`, `@search`, `@prompt`, `@step`, `@upload`, `@model`, `@engine`, `@lang`, `@prebuilt`); `@model:` field persists selected model per card with intelligent defaults (OCR→`granite-docling`, TTS→`kokoro-tts`, STT→`voxtral-stt`, Image→`imagen-ultra`); editable `@prompt:` textarea and `@step:` inputs in preview cards; description/prompt separation (bare text = label, `@prompt:` = AI instruction); 📎 image/PDF upload for multimodal vision analysis; per-card model selector with document-portable model persistence, concurrent block operations |
4040
| **🔌 API Calls** | `{{API:}}` REST API integration — GET/POST/PUT/DELETE methods, custom headers, JSON body, response stored in `$(api_varName)` variables; inline review panel; toolbar GET/POST buttons |
4141
| **🔗 Agent Flow** | `{{Agent:}}` multi-step pipeline — define Step 1/2/3, chain outputs, per-card model + search provider selector, live step status indicators (⏳/✅/❌), review combined output |
42-
| **🔍 Web Search** | Toggle web search for AI — DuckDuckGo (free), Brave Search, Serper.dev; search results injected into LLM context; source citations in responses; per-agent-card search provider selector |
42+
| **🔍 Web Search** | Toggle web search for AI — 7 providers: DuckDuckGo (free), Brave Search, Serper.dev, Tavily (AI-optimized), Google CSE, Wikipedia, Wikidata; search results injected into LLM context; source citations in responses; per-agent-card search provider selector |
4343
| **🎮 Game Builder** | `{{@Game:}}` tag — AI-generated games (Canvas 2D / Three.js / P5.js) or instant pre-built games via `@prebuilt:` field (chess, snake, shooter, pong, breakout, maths quiz); engine selector pills; per-card model picker; 📋 Import button for pasting/uploading external HTML game code with source viewer; 📥 Export as standalone HTML; ⛶ fullscreen; single-line field parsing; "Games for Kids" template with 6 playable games |
4444
| **🐧 Linux Terminal** | `{{Linux:}}` tag — two modes: (1) Terminal mode opens full Debian Linux ([WebVM](https://webvm.io)) in new window with `Packages:` field; (2) Compile & Run mode (`Language:` + `Script:`) compiles/executes 25+ languages (C++, Rust, Go, Java, Python, TypeScript, Kotlin, Scala…) via [Judge0 CE](https://ce.judge0.com) with inline output, execution time & memory stats |
4545
| **❓ Help Mode** | Interactive learning mode — click ❓ Help to highlight all buttons, click any button for description + keyboard shortcut + animated demo video; 50% screen demo panel with fullscreen expand; 16 dedicated demo videos mapped to every toolbar button |
@@ -459,6 +459,7 @@ TextAgent has undergone significant evolution since its inception. What started
459459

460460
| Date | Commits | Feature / Update |
461461
|------|---------|-----------------|
462+
| **2026-03-13** | | 🔍 **4 New Search Providers** — added Tavily (AI-optimized, returns clean summarized results for LLM injection, 1,000/mo free), Google Custom Search Engine (official Google results, 100/day free), Wikipedia API (free encyclopedia search), and Wikidata API (free structured knowledge); total providers now 7; updated all dropdown selectors (AI panel, AI cards, Agent cards); Wikipedia/Wikidata skip API key prompt |
462463
| **2026-03-13** | | 🔍 **Search thinking block** — web search results now appear in a collapsible "thinking" `<details>` block *before* the AI response streams; two-phase UX: spinner appears instantly when search starts, populates with results (or "no results") when complete; source citation pills below; removed duplicate inline search details from AI response bubbles; fixed duplicate user message bug in `sendToAi()` dedup check |
463464
| **2026-03-13** | | 📐 **LaTeX coding block** — new `📐 LaTeX` toolbar button in Coding dropdown inserts `$$...$$` display math blocks; default template `\frac{\sqrt{2025} + \sqrt{3025}}{\sqrt{25}}` evaluates to 20 via Nerdamer; MathJax renders in preview; Playwright test added |
464465
| **2026-03-13** | | 🐛 **Run All output fix**`▶ Run All` now renders output for every block (bash, JS, SQL, math); fixed `findBlockContainer` producing wrong CSS selectors for bash/JS containers; added `renderBlockOutput()` for DOM rendering during Run All; SQL default template changed to `CREATE TABLE IF NOT EXISTS` for idempotent re-runs; math default template now pre-assigns `x = 5` before `x^2 + 2*x + 1` |
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Search Providers — Tavily, Google CSE, Wikipedia, Wikidata
2+
3+
- Added Tavily search provider (AI-optimized, POST API, `include_answer` for AI summary, 1,000/month free)
4+
- Added Google Custom Search Engine (CSE) provider (GET API, key:cx format, 100/day free, 429 quota error handling)
5+
- Added Wikipedia API provider (free, no API key, MediaWiki `action=query` search with HTML tag stripping)
6+
- Added Wikidata API provider (free, no API key, `wbsearchentities` endpoint for structured knowledge)
7+
- Added `API_KEY_TAVILY` and `API_KEY_GOOGLE_CSE` localStorage key constants to `storage-keys.js`
8+
- Updated search provider dropdowns in 3 locations in `ai-docgen.js` (Agent card, AI card, generic)
9+
- Updated AI panel search provider dropdown in `modal-templates.js` with 4 new options
10+
- Updated API key prompt guard to skip key modal for `wikipedia` and `wikidata` (free providers)
11+
- Updated Agent Flow help description in `help-mode.js` to list all 7 providers
12+
13+
---
14+
15+
## Summary
16+
17+
Expands the web search system from 3 providers (DuckDuckGo, Brave, Serper) to 7 by adding Tavily (AI-optimized results with AI summary), Google Custom Search Engine (official Google results), Wikipedia (free encyclopedia search), and Wikidata (structured knowledge base). All search functions follow the existing `{title, url, snippet}` result format. Wikipedia and Wikidata are free with no API key; Tavily and Google CSE require keys stored via the existing API key modal.
18+
19+
---
20+
21+
## 1. Search Engine Core — 4 New Provider Functions
22+
**Files:** `js/ai-web-search.js`
23+
**What:** Added 4 provider config objects to `PROVIDERS` and 4 `async` search functions: `searchTavily()` (POST to `api.tavily.com/search` with `include_answer: true`), `searchGoogleCSE()` (GET to `googleapis.com/customsearch/v1` with `key:cx` splitting), `searchWikipedia()` (GET to `en.wikipedia.org/w/api.php` with HTML tag stripping from snippets), `searchWikidata()` (GET to `wikidata.org/w/api.php` with `wbsearchentities`). Updated `performSearch()` switch with 4 new cases.
24+
**Impact:** 7 search providers now available. Tavily is recommended for AI agents — it returns clean, summarized results optimized for LLM context injection.
25+
26+
## 2. Storage Keys
27+
**Files:** `js/storage-keys.js`
28+
**What:** Added `API_KEY_TAVILY: 'md-viewer-tavily-api-key'` and `API_KEY_GOOGLE_CSE: 'md-viewer-google-cse-key'` constants.
29+
**Impact:** API keys for Tavily and Google CSE persist in localStorage following the existing pattern.
30+
31+
## 3. Dropdown Options — 3 Locations
32+
**Files:** `js/ai-docgen.js`
33+
**What:** Added 4 new `<option>` entries (🤖 Tavily, 🔍 Google CSE, 📖 Wikipedia, 📊 Wikidata) to Agent card search dropdown (~line 548), AI card search dropdown (~line 799), and updated the API key prompt guard (~line 1818) to skip key prompts for `wikipedia` and `wikidata`.
34+
**Impact:** Users can select the new providers from any AI or Agent card in the preview.
35+
36+
## 4. AI Panel Provider Bar
37+
**Files:** `js/modal-templates.js`
38+
**What:** Added 4 new `<option>` entries to `#ai-search-provider-select` dropdown.
39+
**Impact:** New providers appear in the global AI panel search selector.
40+
41+
## 5. Help Text
42+
**Files:** `js/help-mode.js`
43+
**What:** Updated Agent Flow help description to list all 7 providers.
44+
**Impact:** Help mode accurately documents available search providers.
45+
46+
---
47+
48+
## Files Changed (5 total)
49+
50+
| File | Lines Changed | Type |
51+
|------|:---:|------|
52+
| `js/ai-web-search.js` | +185 −2 | 4 new provider configs + search functions |
53+
| `js/storage-keys.js` | +2 −0 | Tavily + Google CSE key constants |
54+
| `js/ai-docgen.js` | +9 −3 | 4 new options in 3 dropdowns + key guard |
55+
| `js/modal-templates.js` | +4 −0 | AI panel dropdown options |
56+
| `js/help-mode.js` | +1 −1 | Help text update |

js/ai-docgen.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,11 @@
548548
var searchOpts = '<option value="off"' + (agentSearchVal === 'off' ? ' selected' : '') + '>🔍 Off</option>'
549549
+ '<option value="duckduckgo"' + (agentSearchVal === 'duckduckgo' ? ' selected' : '') + '>🦆 DuckDuckGo</option>'
550550
+ '<option value="brave"' + (agentSearchVal === 'brave' ? ' selected' : '') + '>🦁 Brave</option>'
551-
+ '<option value="serper"' + (agentSearchVal === 'serper' ? ' selected' : '') + '>🔎 Serper</option>';
551+
+ '<option value="serper"' + (agentSearchVal === 'serper' ? ' selected' : '') + '>🔎 Serper</option>'
552+
+ '<option value="tavily"' + (agentSearchVal === 'tavily' ? ' selected' : '') + '>🤖 Tavily</option>'
553+
+ '<option value="google_cse"' + (agentSearchVal === 'google_cse' ? ' selected' : '') + '>🔍 Google CSE</option>'
554+
+ '<option value="wikipedia"' + (agentSearchVal === 'wikipedia' ? ' selected' : '') + '>📖 Wikipedia</option>'
555+
+ '<option value="wikidata"' + (agentSearchVal === 'wikidata' ? ' selected' : '') + '>📊 Wikidata</option>';
552556

553557
// Build upload thumbnail strip for Agent card
554558
var agentUploadThumbs = '';
@@ -799,7 +803,11 @@
799803
var aiSearchOpts = '<option value="off"' + (cardSearchVal === 'off' ? ' selected' : '') + '>🔍 Off</option>'
800804
+ '<option value="duckduckgo"' + (cardSearchVal === 'duckduckgo' ? ' selected' : '') + '>🦆 DuckDuckGo</option>'
801805
+ '<option value="brave"' + (cardSearchVal === 'brave' ? ' selected' : '') + '>🦁 Brave</option>'
802-
+ '<option value="serper"' + (cardSearchVal === 'serper' ? ' selected' : '') + '>🔎 Serper</option>';
806+
+ '<option value="serper"' + (cardSearchVal === 'serper' ? ' selected' : '') + '>🔎 Serper</option>'
807+
+ '<option value="tavily"' + (cardSearchVal === 'tavily' ? ' selected' : '') + '>🤖 Tavily</option>'
808+
+ '<option value="google_cse"' + (cardSearchVal === 'google_cse' ? ' selected' : '') + '>🔍 Google CSE</option>'
809+
+ '<option value="wikipedia"' + (cardSearchVal === 'wikipedia' ? ' selected' : '') + '>📖 Wikipedia</option>'
810+
+ '<option value="wikidata"' + (cardSearchVal === 'wikidata' ? ' selected' : '') + '>📊 Wikidata</option>';
803811

804812
// Build upload thumbnail strip if images are already attached
805813
var uploadThumbs = '';
@@ -1815,7 +1823,7 @@
18151823
container.querySelectorAll('.ai-agent-search-select').forEach(function (sel) {
18161824
sel.addEventListener('change', function () {
18171825
var providerId = this.value;
1818-
if (!M.webSearch || providerId === 'off' || providerId === 'duckduckgo') return;
1826+
if (!M.webSearch || providerId === 'off' || providerId === 'duckduckgo' || providerId === 'wikipedia' || providerId === 'wikidata') return;
18191827

18201828
var p = M.webSearch.PROVIDERS[providerId];
18211829
if (!p || !p.requiresKey) return;

0 commit comments

Comments
 (0)