diff --git a/gui/pages/Content/Knowledge/AddKnowledge.js b/gui/pages/Content/Knowledge/AddKnowledge.js index 98a6abd90..bf788f801 100644 --- a/gui/pages/Content/Knowledge/AddKnowledge.js +++ b/gui/pages/Content/Knowledge/AddKnowledge.js @@ -1,7 +1,7 @@ import React, {useState, useEffect} from 'react'; import KnowledgeForm from "@/pages/Content/Knowledge/KnowledgeForm"; -export default function AddKnowledge({internalId, sendKnowledgeData}) { +export default function AddKnowledge({internalId, sendKnowledgeData, sendDatabaseData}) { const [knowledgeName, setKnowledgeName] = useState(''); const [knowledgeDescription, setKnowledgeDescription] = useState(''); const [selectedIndex, setSelectedIndex] = useState(null); @@ -38,6 +38,7 @@ export default function AddKnowledge({internalId, sendKnowledgeData}) { isEditing={false} setIsEditing={null} sendKnowledgeData={sendKnowledgeData} + sendDatabaseData={sendDatabaseData} />
diff --git a/gui/pages/Content/Knowledge/KnowledgeDetails.js b/gui/pages/Content/Knowledge/KnowledgeDetails.js index 51f237d81..018b853cd 100644 --- a/gui/pages/Content/Knowledge/KnowledgeDetails.js +++ b/gui/pages/Content/Knowledge/KnowledgeDetails.js @@ -8,7 +8,7 @@ import {deleteCustomKnowledge, deleteMarketplaceKnowledge, getKnowledgeDetails} import {removeTab} from "@/utils/utils"; import {EventBus} from "@/utils/eventBus"; -export default function KnowledgeDetails({internalId, knowledgeId}) { +export default function KnowledgeDetails({internalId, knowledgeId, sendDatabaseData}) { const [showDescription, setShowDescription] = useState(false); const [dropdown, setDropdown] = useState(false); const [isEditing, setIsEditing] = useState(false); @@ -33,8 +33,8 @@ export default function KnowledgeDetails({internalId, knowledgeId}) { .then((response) => { console.log(response) toast.success("Knowledge uninstalled successfully", {autoClose: 1800}); - removeTab(knowledgeId, knowledgeName, "Knowledge", internalId); - EventBus.emit('reFetchKnowledge', {}); + removeTab(knowledgeId, knowledgeName, "Knowledge", internalId); + EventBus.emit('reFetchKnowledge', {}); }) .catch((error) => { toast.error("Unable to uninstall knowledge", {autoClose: 1800}); @@ -43,9 +43,9 @@ export default function KnowledgeDetails({internalId, knowledgeId}) { } else { deleteCustomKnowledge(knowledgeId) .then((response) => { - toast.success("Knowledge uninstalled successfully", {autoClose: 1800}); - removeTab(knowledgeId, knowledgeName, "Knowledge", internalId); - EventBus.emit('reFetchKnowledge', {}); + toast.success("Knowledge uninstalled successfully", {autoClose: 1800}); + removeTab(knowledgeId, knowledgeName, "Knowledge", internalId); + EventBus.emit('reFetchKnowledge', {}); }) .catch((error) => { toast.error("Unable to uninstall knowledge", {autoClose: 1800}); @@ -103,6 +103,7 @@ export default function KnowledgeDetails({internalId, knowledgeId}) { isEditing={true} setIsEditing={setIsEditing} sendKnowledgeData={null} + sendDatabaseData={sendDatabaseData} /> :
diff --git a/gui/pages/Content/Knowledge/KnowledgeForm.js b/gui/pages/Content/Knowledge/KnowledgeForm.js index f6b0e2d7a..1dc260f89 100644 --- a/gui/pages/Content/Knowledge/KnowledgeForm.js +++ b/gui/pages/Content/Knowledge/KnowledgeForm.js @@ -18,6 +18,7 @@ export default function KnowledgeForm({ setSelectedIndex, isEditing, setIsEditing, + sendDatabaseData, sendKnowledgeData }) { const [addClickable, setAddClickable] = useState(true); @@ -135,8 +136,13 @@ export default function KnowledgeForm({ } const handleIndexSelect = (index) => { - setLocalStorageArray("knowledge_index_" + String(internalId), index, setSelectedIndex); setIndexDropdown(false); + + if (!checkIndexValidity(index.is_valid_state)[0]) { + return; + } + + setLocalStorageArray("knowledge_index_" + String(internalId), index, setSelectedIndex); } const checkIndexValidity = (validState) => { @@ -197,7 +203,7 @@ export default function KnowledgeForm({
{index.name}
{!checkIndexValidity(index.is_valid_state)[0] &&
@@ -214,7 +220,7 @@ export default function KnowledgeForm({
{index.name}
{!checkIndexValidity(index.is_valid_state)[0] &&
@@ -223,6 +229,20 @@ export default function KnowledgeForm({
}
))}
} +
+
sendDatabaseData({ + id: -7, + name: "new database", + contentType: "Add_Database", + internalId: createInternalId() + })}> + add-icon  Add + vector database +
+
} diff --git a/gui/pages/Content/Marketplace/KnowledgeTemplate.js b/gui/pages/Content/Marketplace/KnowledgeTemplate.js index f7f6cf469..c5afa766b 100644 --- a/gui/pages/Content/Marketplace/KnowledgeTemplate.js +++ b/gui/pages/Content/Marketplace/KnowledgeTemplate.js @@ -14,9 +14,9 @@ import { getValidMarketplaceIndices, installKnowledgeTemplate } from "@/pages/api/DashboardService"; -import {loadingTextEffect} from "@/utils/utils"; +import {createInternalId} from "@/utils/utils"; -export default function KnowledgeTemplate({template, env}) { +export default function KnowledgeTemplate({template, env, sendDatabaseData}) { const [installed, setInstalled] = useState(''); const [dropdown, setDropdown] = useState(false); const [templateData, setTemplateData] = useState([]); @@ -86,12 +86,18 @@ export default function KnowledgeTemplate({template, env}) { } }, []); - const handleInstallClick = (indexId) => { + const handleInstallClick = (index) => { + setIndexDropdown(false); + + if (!checkIndexValidity(index.is_valid_state, index.is_valid_dimension)[0]) { + return; + } + setInstalled("Installing"); if (window.location.href.toLowerCase().includes('marketplace')) { localStorage.setItem('knowledge_to_install', template.name); - localStorage.setItem('knowledge_index_to_install', indexId); + localStorage.setItem('knowledge_index_to_install', index.id); if (env === 'PROD') { window.open(`https://app.superagi.com/`, '_self'); @@ -106,13 +112,11 @@ export default function KnowledgeTemplate({template, env}) { return; } - setIndexDropdown(false); - - installKnowledgeTemplate(template.name, indexId) + installKnowledgeTemplate(template.name, index.id) .then((response) => { - toast.success("Knowledge installed", {autoClose: 1800}); - setInstalled('Installed'); - EventBus.emit('reFetchKnowledge', {}); + toast.success("Knowledge installed", {autoClose: 1800}); + setInstalled('Installed'); + EventBus.emit('reFetchKnowledge', {}); }) .catch((error) => { toast.error("Error installing Knowledge: ", {autoClose: 1800}); @@ -187,7 +191,7 @@ export default function KnowledgeTemplate({template, env}) {
Pinecone
{pinconeIndices.map((index) => (
handleInstallClick(index.id)} style={{ + onClick={() => handleInstallClick(index)} style={{ padding: '12px 14px', maxWidth: '100%', display: 'flex', @@ -196,7 +200,7 @@ export default function KnowledgeTemplate({template, env}) {
{index.name}
{!checkIndexValidity(index.is_valid_state, index.is_valid_dimension)[0] &&
@@ -209,7 +213,7 @@ export default function KnowledgeTemplate({template, env}) {
Qdrant
{qdrantIndices.map((index) => (
handleInstallClick(index.id)} style={{ + onClick={() => handleInstallClick(index)} style={{ padding: '12px 14px', maxWidth: '100%', display: 'flex', @@ -218,7 +222,7 @@ export default function KnowledgeTemplate({template, env}) {
{index.name}
{!checkIndexValidity(index.is_valid_state, index.is_valid_dimension)[0] &&
@@ -227,6 +231,20 @@ export default function KnowledgeTemplate({template, env}) {
}
))}
} +
+
sendDatabaseData({ + id: -7, + name: "new database", + contentType: "Add_Database", + internalId: createInternalId() + })}> + add-icon  Add + vector database +
+
}
} @@ -306,7 +324,7 @@ export default function KnowledgeTemplate({template, env}) {
- Overview
+ Overview
{/*{templateData?.overview.map((item, index) => (
*/} {/*
{index + 1}. {item || ''}
*/} {/* {index !== item.length - 1}*/} diff --git a/gui/pages/Content/Marketplace/Market.js b/gui/pages/Content/Marketplace/Market.js index 55d89fe90..79c635755 100644 --- a/gui/pages/Content/Marketplace/Market.js +++ b/gui/pages/Content/Marketplace/Market.js @@ -10,7 +10,7 @@ import AgentTemplate from "./AgentTemplate"; import KnowledgeTemplate from "./KnowledgeTemplate"; import {setLocalStorageValue, setLocalStorageArray} from "@/utils/utils"; -export default function Market({env}) { +export default function Market({env, sendDatabaseData}) { const [activeTab, setActiveTab] = useState('market_tools'); const [itemClicked, setItemClicked] = useState(false); const [templateData, setTemplateData] = useState([]); @@ -104,7 +104,8 @@ export default function Market({env}) {
:
{detailType === 'agent_template' && } - {detailType === 'knowledge_template' && } + {detailType === 'knowledge_template' && + } {detailType === 'tool_template' && }
}
diff --git a/gui/pages/Dashboard/Content.js b/gui/pages/Dashboard/Content.js index 3783596ee..340bb2289 100644 --- a/gui/pages/Dashboard/Content.js +++ b/gui/pages/Dashboard/Content.js @@ -414,29 +414,33 @@ export default function Content({env, selectedView, selectedProjectId, organisat
{selectedTab === index &&
{tab.contentType === 'Agents' && - } {tab.contentType === 'Toolkits' && } {tab.contentType === 'Knowledge' && - } + } {tab.contentType === 'Database' && } {tab.contentType === 'Settings' && } - {tab.contentType === 'Marketplace' && } + {tab.contentType === 'Marketplace' && + } {tab.contentType === 'Add_Toolkit' && } {tab.contentType === 'Add_Knowledge' && - } + } {tab.contentType === 'Add_Database' && } {tab.contentType === 'Create_Agent' && } + fetchAgents={getAgentList} toolkits={toolkits} env={env}/>} {isApmOpened && tab.contentType === 'APM' && }
}
diff --git a/superagi/tools/file/read_file.py b/superagi/tools/file/read_file.py index 0f9d6c730..4288685ea 100644 --- a/superagi/tools/file/read_file.py +++ b/superagi/tools/file/read_file.py @@ -63,4 +63,3 @@ def _execute(self, file_name: str): max_length = len(' '.join(file_content.split(" ")[:1000])) return file_content[:max_length] + "\n File " + file_name + " read successfully." -