feat(ai): real retrieval — Ask AI answers from the docs - #13
Merged
oreofeolurin merged 1 commit intoJun 11, 2026
Merged
Conversation
Before: the model received only a section-name string ('you are viewing the
"Releases" section') and pickSources() returned hardcoded fake labels — so it
had no actual content and replied 'the provided context does not cover this',
even on the very page that answered the question.
Now lib/ai/retrieval.ts grounds every answer in real docs, client-side:
- Always includes the current page's text (read from the DOM: .docs-prose /
.api-doc), so on-page questions are answered from the page.
- Ranks the build-time llms-full.txt corpus against the question (saturating
tf·idf + title boost, with a light stemmer so 'create a service' matches the
'Services' page) and attaches the top pages — so off-page questions are
answered too (Mintlify-style).
- 'Used N sources' now reflects the pages actually retrieved, not placeholders.
Pure client-side (one cached fetch of /llms-full.txt) — works in BYOK mode and
on pure-static hosting; degrades to current-page-only if llms-full.txt is
absent. Proxy context cap raised 8k→16k to fit the grounding context.
Known gap: llms-full.txt is docs-only, so API-reference operation bodies aren't
in the corpus yet (the current API page's DOM text is still included).
oreofeolurin
merged commit Jun 11, 2026
dd3c2ec
into
feat/ai-composer-textarea-attachments
1 check passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #11 (
feat/ai-composer-textarea-attachments) — merge that first, or I'll rebase onto main once it lands.Problem
Ask AI couldn't answer even when the answer was on the current page. Root cause: it was handed no document content — only a section-name string (
"you are viewing the 'Releases' section"), andpickSources()returned hardcoded fake labels. So it replied "the provided context does not cover this." Mintlify, by contrast, retrieves the relevant page text and grounds on it.Fix —
lib/ai/retrieval.ts(client-side RAG).docs-prose/.api-doc). Fixes "on the Services page it still couldn't answer."llms-full.txtcorpus against the question with saturating tf·idf + title boost, plus a light stemmer (socreate a servicematches the Services page). Attaches the top 3 pages → answers off-page questions, Mintlify-style.Pure client-side (one cached fetch of
/llms-full.txt) → works in BYOK mode and on pure-static hosting; degrades to current-page-only ifllms-full.txtis absent. Proxycontextcap raised 8k→16k.Validation
Ranking unit-checked against a rune-like corpus:
tscclean ·next lintclean · production build prerenders all 25 pages.Known gap
llms-full.txtis docs-only, so API-reference operation bodies aren't in the corpus yet (the current API page's DOM text is still included). Follow-up: add API operations to the corpus.