# Knowledge Base Test Page ## Overview A sandbox for testing knowledge base retrieval by selecting a KB, running a query, and inspecting returned chunks. ## Route `/utilities/testing/kb` Optional query parameter `?kb=` pre-selects the KB on load (used when navigating from a KB's detail page). ## Page Name "Retrieval" for title and breadcrumb ## Page Layout ``` [Retrieval] (page title / breadcrumb) ┌─────────────────────────────────────────────────────────────┐ │ Knowledge Base │ │ [Selected KB button] [Select KB] │ └─────────────────────────────────────────────────────────────┘ (no selection) (KB selected) ┌──────────────┐ ┌──────────────────────────────────────┐ │ Select a │ → │ Query panel │ │ KB above │ │ │ └──────────────┘ └──────────────────────────────────────┘ ``` ## KB Selector The selected KB is shown in the top selector button (icon + name). If no KB is selected, the page shows a placeholder prompt to select one. ## Query Panel Sends a query to the test endpoint and displays returned chunks ranked by relevance. ``` ┌─────────────────────────────────────────────────────────────┐ │ Query │ │ │ │ ┌───────────────────────────────────────────────────────┐ │ │ │ Enter your query… (textarea, min 3 rows) │ │ │ └───────────────────────────────────────────────────────┘ │ │ │ │ ▸ Parameters (collapsible) │ │ Top K [ 5 ] │ │ Threshold [ 0.7 ] │ │ [Query →] │ │ │ │ Result │ │ ┌───────────────────────────────────────────────────────┐ │ │ │ Chunks: 4 Latency: 87 ms │ │ │ │ ┌─────────────────────────────────────────────────┐ │ │ │ │ │ #1 [0.94] doc-id │ │ │ │ │ │ "The quick brown fox…" │ │ │ │ │ ├─────────────────────────────────────────────────┤ │ │ │ │ │ #2 [0.81] doc-id │ │ │ │ │ │ "Lorem ipsum dolor…" │ │ │ │ │ ├─────────────────────────────────────────────────┤ │ │ │ │ │ #3 [0.67] doc-id │ │ │ │ │ │ "Sit amet consectetur…" │ │ │ │ │ └─────────────────────────────────────────────────┘ │ │ │ └───────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────┘ ``` Behavior: - Query is disabled when the query text is empty. - Top K and threshold are editable query parameters. - Results show latency and chunk count. - Each chunk shows rank, score, document id, and content. - If there are no chunks, the result shows `No results`. - Request errors are shown inline. ## API Behavior ### `POST /api/workspaces/[workspaceId]/kbs/[id]/test` Runs retrieval against the selected KB and returns ranked chunks with latency. If the KB endpoint is unavailable or the request fails, an error is returned.