()
| 54 | })) |
| 55 | |
| 56 | const VectorStoreQuery = () => { |
| 57 | const customization = useSelector((state) => state.customization) |
| 58 | const navigate = useNavigate() |
| 59 | const theme = useTheme() |
| 60 | const dispatch = useDispatch() |
| 61 | const inputRef = useRef(null) |
| 62 | const { hasAssignedWorkspace } = useAuth() |
| 63 | |
| 64 | useNotifier() |
| 65 | |
| 66 | const enqueueSnackbar = (...args) => dispatch(enqueueSnackbarAction(...args)) |
| 67 | const closeSnackbar = (...args) => dispatch(closeSnackbarAction(...args)) |
| 68 | |
| 69 | const { storeId } = useParams() |
| 70 | |
| 71 | const [documentChunks, setDocumentChunks] = useState([]) |
| 72 | const [loading, setLoading] = useState(false) |
| 73 | const [showExpandedChunkDialog, setShowExpandedChunkDialog] = useState(false) |
| 74 | const [expandedChunkDialogProps, setExpandedChunkDialogProps] = useState({}) |
| 75 | const [documentStore, setDocumentStore] = useState({}) |
| 76 | const [query, setQuery] = useState('') |
| 77 | |
| 78 | const [timeTaken, setTimeTaken] = useState(-1) |
| 79 | const [retrievalError, setRetrievalError] = useState(undefined) |
| 80 | |
| 81 | const getSpecificDocumentStoreApi = useApi(documentsApi.getSpecificDocumentStore) |
| 82 | const queryVectorStoreApi = useApi(documentsApi.queryVectorStore) |
| 83 | |
| 84 | const getVectorStoreNodeDetailsApi = useApi(nodesApi.getSpecificNode) |
| 85 | const [selectedVectorStoreProvider, setSelectedVectorStoreProvider] = useState({}) |
| 86 | |
| 87 | const handleVectorStoreProviderDataChange = ({ inputParam, newValue }) => { |
| 88 | setSelectedVectorStoreProvider((prevData) => { |
| 89 | const updatedData = { ...prevData } |
| 90 | updatedData.inputs[inputParam.name] = newValue |
| 91 | updatedData.inputParams = showHideInputParams(updatedData) |
| 92 | return updatedData |
| 93 | }) |
| 94 | } |
| 95 | |
| 96 | const chunkSelected = (chunkId, selectedChunkNumber) => { |
| 97 | const selectedChunk = documentChunks.find((chunk) => chunk.id === chunkId) |
| 98 | const dialogProps = { |
| 99 | data: { |
| 100 | selectedChunk, |
| 101 | selectedChunkNumber |
| 102 | } |
| 103 | } |
| 104 | setExpandedChunkDialogProps(dialogProps) |
| 105 | setShowExpandedChunkDialog(true) |
| 106 | } |
| 107 | |
| 108 | const handleEnter = (e) => { |
| 109 | // Check if IME composition is in progress |
| 110 | const isIMEComposition = e.isComposing || e.keyCode === 229 |
| 111 | if (e.key === 'Enter' && query && !isIMEComposition) { |
| 112 | if (!e.shiftKey && query) { |
| 113 | if (inputRef.current) { |
nothing calls this directly
no test coverage detected