-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added vectors view to the collection info tab * format * getting accuracy * fixes and tests * separate tab for accuracy checks with logging * fix test * advanced mod switch * refactor named vectors, improve logging, rename to precision * add files * fmt * fixes * fix table and progress bar * make advanced mode work * allow to set fixed heigh to editor * add SearchQualityPannel * format * rename files --------- Co-authored-by: generall <[email protected]>
- Loading branch information
Showing
7 changed files
with
511 additions
and
4 deletions.
There are no files selected for viewing
97 changes: 97 additions & 0 deletions
97
src/components/Collections/SearchQuality/SearchQuality.jsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import React, { useEffect } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { getSnackbarOptions } from '../../Common/utils/snackbarOptions'; | ||
import { useClient } from '../../../context/client-context'; | ||
import SearchQualityPannel from './SearchQualityPannel'; | ||
import { useSnackbar } from 'notistack'; | ||
import { Box, Card, CardHeader } from '@mui/material'; | ||
import { CopyButton } from '../../Common/CopyButton'; | ||
import { bigIntJSON } from '../../../common/bigIntJSON'; | ||
import EditorCommon from '../../EditorCommon'; | ||
import _ from 'lodash'; | ||
|
||
const SearchQuality = ({ collectionName }) => { | ||
const { enqueueSnackbar, closeSnackbar } = useSnackbar(); | ||
const { client } = useClient(); | ||
const [collection, setCollection] = React.useState(null); | ||
const [log, setLog] = React.useState(''); | ||
|
||
const handleLogUpdate = (newLog) => { | ||
const date = new Date().toLocaleString(); | ||
newLog = `[${date}] ${newLog}`; | ||
setLog((prevLog) => { | ||
return newLog + '\n' + prevLog; | ||
}); | ||
}; | ||
|
||
const clearLogs = () => { | ||
setLog(''); | ||
}; | ||
|
||
useEffect(() => { | ||
client | ||
.getCollection(collectionName) | ||
.then((res) => { | ||
setCollection(() => { | ||
return { ...res }; | ||
}); | ||
}) | ||
.catch((err) => { | ||
enqueueSnackbar(err.message, getSnackbarOptions('error', closeSnackbar)); | ||
}); | ||
}, []); | ||
|
||
// Check that collection.config.params.vectors?.size exists and integer | ||
const isNamedVectors = collection?.config?.params.vectors?.size && !_.isObject(collection?.config?.params?.vectors); | ||
let vectors = {}; | ||
if (collection) { | ||
vectors = isNamedVectors ? collection?.config?.params?.vectors : { '': collection?.config?.params?.vectors }; | ||
} | ||
|
||
return ( | ||
<> | ||
{collection?.config?.params?.vectors && ( | ||
<SearchQualityPannel | ||
collectionName={collectionName} | ||
vectors={vectors} | ||
loggingFoo={handleLogUpdate} | ||
clearLogsFoo={clearLogs} | ||
sx={{ mt: 5 }} | ||
/> | ||
)} | ||
|
||
<Card varian="dual" sx={{ mt: 5 }}> | ||
<CardHeader | ||
title={'Report'} | ||
variant="heading" | ||
sx={{ | ||
flexGrow: 1, | ||
}} | ||
action={<CopyButton text={bigIntJSON.stringify(log)} />} | ||
/> | ||
<Box sx={{ pt: 2, pb: 1, pr: 1 }}> | ||
<EditorCommon | ||
theme={'custom-language-theme'} | ||
value={log} | ||
options={{ | ||
scrollBeyondLastLine: false, | ||
fontSize: 12, | ||
wordWrap: 'on', | ||
minimap: { enabled: false }, | ||
automaticLayout: true, | ||
readOnly: true, | ||
mouseWheelZoom: true, | ||
lineNumbers: 'off', | ||
}} | ||
/> | ||
</Box> | ||
</Card> | ||
</> | ||
); | ||
}; | ||
|
||
SearchQuality.propTypes = { | ||
collectionName: PropTypes.string, | ||
}; | ||
|
||
export default SearchQuality; |
Oops, something went wrong.