ai-search-web-components
v1.0.2
Published
AI-powered documentation search component with Fuse.js and Chrome Gemini Nano
Maintainers
Readme
ai-search-web-components
Web components for documentation search.
This package provides two components:
wg-doc-search(classic: Fuse.js-based retrieval)wg-rag-search(recommended: Orama + Transformers.js retrieval)
Install
pnpm add ai-search-web-componentsRecommended: wg-rag-search
Use this with vector-context.json generated by VectorDocIndexer.
<wg-rag-search
context-path="./vector-context.json"
placeholder="Ask docs..."
top-k="3"
max-results="10"
></wg-rag-search>
<script type="module">
import 'ai-search-web-components/rag-search';
</script>Props
context-path: path tovector-context.jsonplaceholder: input placeholder texttop-k: number of chunks used for grounded answer (3default)max-results: number of retrieval cards below answer (10default)
Classic: wg-doc-search
Use this with context.json generated by WebsiteIndexer.
<wg-doc-search context-path="./context.json"></wg-doc-search>
<script type="module">
import 'ai-search-web-components/doc-search';
</script>Browser AI behavior
Both components can use Chrome Prompt API (LanguageModel) for answer generation.
- If Prompt API is available: grounded answer is generated in-browser
- If unavailable: retrieval still works; fallback answer UI is shown
Local Demo
From repo root:
pnpm --dir packages/web-components devPages:
http://127.0.0.1:5173/-> classicwg-doc-searchhttp://127.0.0.1:5173/rag.html->wg-rag-search
Index Requirements
wg-doc-searchrequirescontext.jsonwg-rag-searchrequiresvector-context.json
Generate these with the ai-search-indexer package.
Tutorial
See full integration guide:
packages/web-components/TUTORIAL.md
License
MIT
