import { useState } from "react"; import { api } from "../api"; import type { QueryResultItem } from "../types"; import { useApiCall } from "../hooks/useApiCall"; import ScoreBar from "./ScoreBar"; import StatusMessage from "./StatusMessage"; import DocumentViewer from "./DocumentViewer"; export default function SemanticSearch() { const [query, setQuery] = useState(""); const [topK, setTopK] = useState(10); const { data: results, loading, error, run } = useApiCall(); async function handleSearch() { if (!query.trim()) return; await run(() => api.query({ text: query, top_k: topK }).then((r) => r.results)); } return (

Semantic Search

Find passages most semantically similar to your query across the entire corpus.

setQuery(e.target.value)} placeholder="e.g. a place where children learn and take tests" onKeyDown={(e) => e.key === "Enter" && handleSearch()} />
setTopK(+e.target.value)} min={1} max={50} />
{error && } {results && (

Results ({results.length})

{results.map((r) => (
#{r.rank}{" "} {r.doc_id}{" "} chunk {r.chunk_index}
{r.text}
))}
)}
); }