LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
[FEAT] Add search functionality to LLMs, VectorDBs, Embeddings, and Connectors pages (#1694)
Chandrasekharan M0149d0481474
diff --git a/frontend/src/components/tool-settings/tool-settings/ToolSettings.jsx b/frontend/src/components/tool-settings/tool-settings/ToolSettings.jsxindex 8b078d282..d649e210b 100644--- a/frontend/src/components/tool-settings/tool-settings/ToolSettings.jsx+++ b/frontend/src/components/tool-settings/tool-settings/ToolSettings.jsx@@ -15,6 +15,7 @@ import { ToolNavBar } from "../../navigations/tool-nav-bar/ToolNavBar";import { ViewTools } from "../../custom-tools/view-tools/ViewTools";import { SharePermission } from "../../widgets/share-permission/SharePermission";import usePostHogEvents from "../../../hooks/usePostHogEvents";+import { useListSearch } from "../../../hooks/useListSearch";const titles = {llm: "LLMs",@@ -33,7 +34,6 @@ const btnText = {};function ToolSettings({ type }) {- const [tableRows, setTableRows] = useState([]);const [isLoading, setIsLoading] = useState(false);const [isShareLoading, setIsShareLoading] = useState(false);const [adapterDetails, setAdapterDetails] = useState(null);@@ -48,9 +48,16 @@ function ToolSettings({ type }) {const axiosPrivate = useAxiosPrivate();const handleException = useExceptionHandler();const { posthogEventText, setPostHogCustomEvent } = usePostHogEvents();+ const {+ displayList,+ setDisplayList,+ setMasterList,+ updateMasterList,+ onSearch,+ } = useListSearch("adapter_name");useEffect(() => {- setTableRows([]);+ setMasterList([]);if (!type) {return;}@@ -67,7 +74,7 @@ function ToolSettings({ type }) {setIsLoading(true);axiosPrivate(requestOptions).then((res) => {- setTableRows(res?.data);+ setMasterList(res?.data || []);}).catch((err) => {setAlertDetails(handleException(err));@@ -79,21 +86,29 @@ function ToolSettings({ type }) {const addNewItem = (row, isEdit) => {if (isEdit) {- const rowsModified = [...tableRows].map((tableRow) => {- if (tableRow?.id !== row?.id) {- return tableRow;- }- tableRow["adapter_name"] = row?.adapter_name;- return tableRow;- });- setTableRows(rowsModified);+ updateMasterList((currentList) =>+ currentList.map((tableRow) => {+ if (tableRow?.id !== row?.id) {+ return tableRow;+ }+ return { ...tableRow, adapter_name: row?.adapter_name };+ })+ );} else {- const rowsModified = [...tableRows];- rowsModified.push(row);- setTableRows(rowsModified);+ updateMasterList((currentList) => [...currentList, row]);}};+ const handleDeleteSuccess = (adapterId) => {+ updateMasterList((currentList) =>+ currentList.filter((row) => row?.id !== adapterId)+ );+ setAlertDetails({+ type: "success",+ content: "Successfully deleted",+ });+ };+const handleDelete = (_event, adapter) => {const requestOptions = {method: "DELETE",@@ -105,20 +120,9 @@ function ToolSettings({ type }) {setIsLoading(true);axiosPrivate(requestOptions)- .then((res) => {- const filteredList = tableRows.filter((row) => row?.id !== adapter?.id);- setTableRows(filteredList);- setAlertDetails({- type: "success",- content: "Successfully deleted",- });- })- .catch((err) => {- setAlertDetails(handleException(err));- })- .finally(() => {- setIsLoading(false);- });+ .then(() => handleDeleteSuccess(adapter?.id))+ .catch((err) => setAlertDetails(handleException(err)))+ .finally(() => setIsLoading(false));};const handleShare = (_event, adapter, isEdit) => {@@ -221,6 +225,9 @@ function ToolSettings({ type }) {<div className="plt-tool-settings-layout"><ToolNavBartitle={titles[type]}+ enableSearch+ setSearchList={setDisplayList}+ onSearch={onSearch}CustomButtons={() => {return (<CustomButton@@ -237,7 +244,7 @@ function ToolSettings({ type }) {<div className="plt-tool-settings-layout-2"><div className="plt-tool-settings-body"><ViewTools- listOfTools={tableRows}+ listOfTools={displayList}isLoading={isLoading}handleDelete={handleDelete}setOpenAddTool={setOpenAddSourcesModal}@@ -257,7 +264,7 @@ function ToolSettings({ type }) {titleProp="adapter_name"descriptionProp="description"iconProp="icon"- isEmpty={!tableRows?.length}+ isEmpty={!displayList?.length}centeredisClickable={false}handleShare={handleShare}diff --git a/frontend/src/hooks/useListSearch.js b/frontend/src/hooks/useListSearch.jsnew file mode 100644index 000000000..c8f9ad13a--- /dev/null+++ b/frontend/src/hooks/useListSearch.js@@ -0,0 +1,55 @@+import { useRef, useState, useCallback } from "react";++function useListSearch(searchField) {+ const listRef = useRef([]);+ const searchTextRef = useRef("");+ const [displayList, setDisplayList] = useState([]);++ const filterList = useCallback(+ (list, searchText) => {+ if (!searchText.trim()) {+ return list;+ }+ return list.filter((item) =>+ item[searchField]?.toLowerCase().includes(searchText.toLowerCase())+ );+ },+ [searchField]+ );++ const setMasterList = useCallback(+ (list) => {+ listRef.current = list;+ setDisplayList(filterList(list, searchTextRef.current));+ },+ [filterList]+ );++ const onSearch = useCallback(+ (searchText, setSearchList) => {+ searchTextRef.current = searchText;+ setSearchList(filterList(listRef.current, searchText));+ },+ [filterList]+ );++ const updateMasterList = useCallback(+ (updateFn) => {+ const updatedList = updateFn(listRef.current);+ listRef.current = updatedList;+ setDisplayList(filterList(updatedList, searchTextRef.current));+ },+ [filterList]+ );++ return {+ listRef,+ displayList,+ setDisplayList,+ setMasterList,+ updateMasterList,+ onSearch,+ };+}++export { useListSearch };diff --git a/frontend/src/pages/ConnectorsPage.jsx b/frontend/src/pages/ConnectorsPage.jsxindex 80ffaab86..cdc989c87 100644--- a/frontend/src/pages/ConnectorsPage.jsx+++ b/frontend/src/pages/ConnectorsPage.jsx@@ -7,6 +7,7 @@ import { useSessionStore } from "../store/session-store";import { useAlertStore } from "../store/alert-store";import { useExceptionHandler } from "../hooks/useExceptionHandler";import useRequestUrl from "../hooks/useRequestUrl";+import { useListSearch } from "../hooks/useListSearch";import "./ConnectorsPage.css";import { ToolNavBar } from "../components/navigations/tool-nav-bar/ToolNavBar";import { ViewTools } from "../components/custom-tools/view-tools/ViewTools";@@ -14,7 +15,6 @@ import { SharePermission } from "../components/widgets/share-permission/SharePerimport { AddSourceModal } from "../components/input-output/add-source-modal/AddSourceModal";function ConnectorsPage() {- const [connectors, setConnectors] = useState([]);const [loading, setLoading] = useState(false);const [modalVisible, setModalVisible] = useState(false);const [editingConnector, setEditingConnector] = useState(null);@@ -29,6 +29,8 @@ function ConnectorsPage() {const { setAlertDetails } = useAlertStore();const handleException = useExceptionHandler();const { getUrl } = useRequestUrl();+ const { displayList, setDisplayList, setMasterList, onSearch } =+ useListSearch("connector_name");useEffect(() => {fetchConnectors();@@ -39,7 +41,7 @@ function ConnectorsPage() {setLoading(true);try {const response = await axiosPrivate.get(getUrl("connector/"));- setConnectors(response.data || []);+ setMasterList(response.data || []);} catch (error) {setAlertDetails(handleException(error, "Failed to load connectors"));} finally {@@ -155,12 +157,15 @@ function ConnectorsPage() {<div className="connectors-layout"><ToolNavBartitle="Connectors"+ enableSearch+ setSearchList={setDisplayList}+ onSearch={onSearch}CustomButtons={renderCreateConnectorButtons}/><div className="connectors-pg-layout"><div className="connectors-pg-body"><ViewTools- listOfTools={connectors}+ listOfTools={displayList}isLoading={loading}handleDelete={handleDeleteConnector}handleEdit={handleEditConnector}@@ -172,7 +177,7 @@ function ConnectorsPage() {iconProp="icon"showOwner={true}type="Connector"- isEmpty={!connectors.length}+ isEmpty={!displayList.length}centeredisClickable={false}/>