Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(search): on-device Ask AI grounded on docs search#3284

Open
bartlomieju wants to merge 1 commit into
mainfrom
docs-ask-ai
Open

feat(search): on-device Ask AI grounded on docs search#3284
bartlomieju wants to merge 1 commit into
mainfrom
docs-ask-ai

Conversation

@bartlomieju

Copy link
Copy Markdown
Member

A first cut at the highest-leverage idea from the docs review: an in-docs
"Ask AI" that's grounded on our own content, free, and on-brand with the
existing AI-native affordances.

How it works. The search box already does site-wide retrieval via Orama,
so Ask AI reuses those hits as context rather than adding a second
retrieval path. When you run a search, an "Ask AI about " button
appears above the results. Clicking it builds a compact context from the
top hits and answers using the browser's built-in, on-device model (the
Chrome Prompt API) when available. The answer is grounded only on the
retrieved pages and lists them as sources. It is entirely client-side, so
there is no server endpoint, no API key, and no per-query cost.

When the on-device model isn't available (most browsers today), it falls
back to a one-click Claude hand-off with the question and the most
relevant doc links prefilled, so the button is always useful. Everything
is feature-detected and wrapped in try/catch, and the answer panel is
purely additive, so existing search behaviour is unchanged for everyone.

Caveats. The Chrome Prompt API is experimental and gated, so the
on-device path reaches a small set of users today; the rest get the
hand-off. I could not runtime-test the on-device model in this
environment, so the Prompt API call wants a real-browser check before
merge. The on-device context window is small, so retrieved context is
deliberately capped (top 5 hits, truncated). Future work: response
streaming, and widening retrieval beyond the current 8 search hits.

Add an 'Ask AI' action to the search results that synthesizes an answer
from the current site-wide search hits using the browser's built-in,
on-device model (Chrome Prompt API) when available. It is grounded only
on the retrieved docs, lists its sources, and is entirely client-side and
free (no server endpoint or API key). When the on-device model is
unavailable it falls back to a Claude hand-off with the question and the
most relevant pages prefilled. Everything is feature-detected and wrapped
in try/catch so existing search is never affected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant