From 8b11910f80bb7b0000ffe1035690a3b609ad3081 Mon Sep 17 00:00:00 2001 From: NishantBorthakur Date: Fri, 28 Jul 2023 15:07:49 +0530 Subject: [PATCH 1/4] index selection issue --- gui/pages/Content/Knowledge/KnowledgeForm.js | 7 ++++++- .../Content/Marketplace/KnowledgeTemplate.js | 18 +++++++++++------- superagi/tools/file/read_file.py | 1 - 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/gui/pages/Content/Knowledge/KnowledgeForm.js b/gui/pages/Content/Knowledge/KnowledgeForm.js index f6b0e2d7a..7b364d0c5 100644 --- a/gui/pages/Content/Knowledge/KnowledgeForm.js +++ b/gui/pages/Content/Knowledge/KnowledgeForm.js @@ -135,8 +135,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) => { diff --git a/gui/pages/Content/Marketplace/KnowledgeTemplate.js b/gui/pages/Content/Marketplace/KnowledgeTemplate.js index f7f6cf469..fc5f7a7dc 100644 --- a/gui/pages/Content/Marketplace/KnowledgeTemplate.js +++ b/gui/pages/Content/Marketplace/KnowledgeTemplate.js @@ -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,9 +112,7 @@ 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'); @@ -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', @@ -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', 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." - From 572db4670c15142a75f4fa814f66f2b4df831f2b Mon Sep 17 00:00:00 2001 From: NishantBorthakur Date: Fri, 28 Jul 2023 15:20:56 +0530 Subject: [PATCH 2/4] add vector db button --- gui/pages/Content/Knowledge/AddKnowledge.js | 3 ++- .../Content/Knowledge/KnowledgeDetails.js | 13 ++++++------ gui/pages/Content/Knowledge/KnowledgeForm.js | 21 ++++++++++++++++--- gui/pages/Dashboard/Content.js | 11 ++++++---- 4 files changed, 34 insertions(+), 14 deletions(-) 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 7b364d0c5..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); @@ -137,7 +138,7 @@ export default function KnowledgeForm({ const handleIndexSelect = (index) => { setIndexDropdown(false); - if(!checkIndexValidity(index.is_valid_state)[0]) { + if (!checkIndexValidity(index.is_valid_state)[0]) { return; } @@ -202,7 +203,7 @@ export default function KnowledgeForm({
{index.name}
{!checkIndexValidity(index.is_valid_state)[0] &&
@@ -219,7 +220,7 @@ export default function KnowledgeForm({
{index.name}
{!checkIndexValidity(index.is_valid_state)[0] &&
@@ -228,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/Dashboard/Content.js b/gui/pages/Dashboard/Content.js index 3783596ee..6e5321717 100644 --- a/gui/pages/Dashboard/Content.js +++ b/gui/pages/Dashboard/Content.js @@ -414,14 +414,16 @@ 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' && @@ -429,14 +431,15 @@ export default function Content({env, selectedView, selectedProjectId, organisat {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' && }
}
From 4350c444eb34bec6487fec78a33aa3764332c6ff Mon Sep 17 00:00:00 2001 From: NishantBorthakur Date: Fri, 28 Jul 2023 15:25:09 +0530 Subject: [PATCH 3/4] add vector db button 2 --- .../Content/Marketplace/KnowledgeTemplate.js | 30 ++++++++++++++----- gui/pages/Content/Marketplace/Market.js | 5 ++-- gui/pages/Dashboard/Content.js | 3 +- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/gui/pages/Content/Marketplace/KnowledgeTemplate.js b/gui/pages/Content/Marketplace/KnowledgeTemplate.js index fc5f7a7dc..f38d929d4 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([]); @@ -89,7 +89,7 @@ export default function KnowledgeTemplate({template, env}) { const handleInstallClick = (index) => { setIndexDropdown(false); - if(!checkIndexValidity(index.is_valid_state, index.is_valid_dimension)[0]) { + if (!checkIndexValidity(index.is_valid_state, index.is_valid_dimension)[0]) { return; } @@ -114,9 +114,9 @@ export default function KnowledgeTemplate({template, env}) { 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}); @@ -200,7 +200,7 @@ export default function KnowledgeTemplate({template, env}) {
{index.name}
{!checkIndexValidity(index.is_valid_state, index.is_valid_dimension)[0] &&
@@ -222,7 +222,7 @@ export default function KnowledgeTemplate({template, env}) {
{index.name}
{!checkIndexValidity(index.is_valid_state, index.is_valid_dimension)[0] &&
@@ -231,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 +
+
} } 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 6e5321717..340bb2289 100644 --- a/gui/pages/Dashboard/Content.js +++ b/gui/pages/Dashboard/Content.js @@ -428,7 +428,8 @@ export default function Content({env, selectedView, selectedProjectId, organisat } {tab.contentType === 'Settings' && } - {tab.contentType === 'Marketplace' && } + {tab.contentType === 'Marketplace' && + } {tab.contentType === 'Add_Toolkit' && } {tab.contentType === 'Add_Knowledge' && Date: Fri, 28 Jul 2023 15:26:59 +0530 Subject: [PATCH 4/4] overview button fix --- gui/pages/Content/Marketplace/KnowledgeTemplate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/pages/Content/Marketplace/KnowledgeTemplate.js b/gui/pages/Content/Marketplace/KnowledgeTemplate.js index f38d929d4..c5afa766b 100644 --- a/gui/pages/Content/Marketplace/KnowledgeTemplate.js +++ b/gui/pages/Content/Marketplace/KnowledgeTemplate.js @@ -324,7 +324,7 @@ export default function KnowledgeTemplate({template, env, sendDatabaseData}) {
- Overview
+ Overview
{/*{templateData?.overview.map((item, index) => (
*/} {/*
{index + 1}. {item || ''}
*/} {/* {index !== item.length - 1}*/}