diff --git a/web/src/pages/Explore.jsx b/web/src/pages/Explore.jsx index ea89488..40ef340 100644 --- a/web/src/pages/Explore.jsx +++ b/web/src/pages/Explore.jsx @@ -121,7 +121,7 @@ function Explore() { }, [datasetId, scopeId, setScope]); useEffect(() => { - fetchScopeMeta() + fetchScopeMeta() }, [datasetId, scopeId, fetchScopeMeta]); const [embedding, setEmbedding] = useState(null); @@ -147,7 +147,7 @@ function Explore() { const [scopeRows, setScopeRows] = useState([]) const [points, setPoints] = useState([]); const [drawPoints, setDrawPoints] = useState([]); // this is the points with the cluster number - const [hulls, setHulls] = useState([]); + const [hulls, setHulls] = useState([]); const [scopeToInputIndexMap, setScopeToInputIndexMap] = useState({}) const [inputToScopeIndexMap, setInputToScopeIndexMap] = useState({}) @@ -355,8 +355,20 @@ function Explore() { const [searchIndices, setSearchIndices] = useState([]); const [distances, setDistances] = useState([]); + const { dimensions: embeddingDimensions } = embedding ?? {}; + const searchQuery = useCallback((query) => { - fetch(`${apiUrl}/search/nn?dataset=${datasetId}&query=${query}&embedding_id=${searchModel}`) + + const searchParams = new URLSearchParams({ + dataset: datasetId, + query, + embedding_id: searchModel, + ...(embeddingDimensions !== undefined ? { dimensions: embeddingDimensions } : {} ) + }) + const nearestNeigborsUrl = new URL(`${apiUrl}/search/nn`); + nearestNeigborsUrl.search = searchParams.toString(); + + fetch(nearestNeigborsUrl) .then(response => response.json()) .then(data => { // console.log("search", data) @@ -365,7 +377,7 @@ function Explore() { setSearchIndices(indices); // scatter?.zoomToPoints(data.indices, { transition: true, padding: 0.2, transitionDuration: 1500 }) }); - }, [searchModel, datasetId, scatter, setDistances, setSearchIndices]); + }, [searchModel, datasetId, scatter, setDistances, setSearchIndices, embeddingDimensions]); const [searchAnnotations, setSearchAnnotations] = useState([]); useEffect(() => { @@ -529,10 +541,10 @@ const handleNewCluster = useCallback((label) => { // console.log("tagset", tagset[tag]) const filteredClusterIndices = scopeRows.filter(d => d.cluster == slide?.cluster).map(d => d.ls_index) const filteredTagset = filterInputIndices(tagset[tag] || []) - let indices = intersectMultipleArrays(selectedIndices || [], - searchIndices || [], - filteredClusterIndices || [], - filteredTagset || [], + let indices = intersectMultipleArrays(selectedIndices || [], + searchIndices || [], + filteredClusterIndices || [], + filteredTagset || [], columnIndices || []) if(indices.length == 0 && selectedIndices.length > 0) { indices = selectedIndices @@ -595,7 +607,7 @@ const handleNewCluster = useCallback((label) => {
{datasetId} {scope?.rows}/{dataset?.length} rows
- +
{/*
*/} @@ -694,12 +706,12 @@ const handleNewCluster = useCallback((label) => { } return ( - {key}: + {key}: {value} )})}
: null } -
+
@@ -786,9 +798,9 @@ const handleNewCluster = useCallback((label) => { console.log("new label", newLabel) handleNewCluster(newLabel) }}> - setNewClusterLabel(e.target.value)} + setNewClusterLabel(e.target.value)} placeholder="New Cluster" /> @@ -860,7 +872,7 @@ const handleNewCluster = useCallback((label) => { {columnFilters?.length ?
{columnFilters.map(column => ( - {column.column}: + {column.column}: