From 1bf96b1fc8c5de457a16df6fbd2ebd64e1000dc9 Mon Sep 17 00:00:00 2001 From: Daishan Peng Date: Fri, 1 Nov 2024 15:56:18 -0700 Subject: [PATCH] Chore: Add knowledge description, enforce unique urls (#416) Signed-off-by: Daishan Peng --- ui/admin/app/components/agent/Agent.tsx | 6 +++- .../knowledge/AgentKnowledgePanel.tsx | 35 ++++++++++++++++++- .../knowledge/onedrive/AddLinkModal.tsx | 10 +++--- .../knowledge/website/AddWebsiteModal.tsx | 10 +++--- .../knowledge/website/WebsiteModal.tsx | 2 +- ui/admin/app/lib/model/agents.ts | 2 +- 6 files changed, 53 insertions(+), 12 deletions(-) diff --git a/ui/admin/app/components/agent/Agent.tsx b/ui/admin/app/components/agent/Agent.tsx index 6d700a0e3..4c093e846 100644 --- a/ui/admin/app/components/agent/Agent.tsx +++ b/ui/admin/app/components/agent/Agent.tsx @@ -89,7 +89,11 @@ function AgentContent({ className, onRefresh }: AgentProps) { website, or external links in order to give it context about various topics. - + diff --git a/ui/admin/app/components/knowledge/AgentKnowledgePanel.tsx b/ui/admin/app/components/knowledge/AgentKnowledgePanel.tsx index 29ea36bd5..4e8d65277 100644 --- a/ui/admin/app/components/knowledge/AgentKnowledgePanel.tsx +++ b/ui/admin/app/components/knowledge/AgentKnowledgePanel.tsx @@ -2,6 +2,7 @@ import { Globe, SettingsIcon, UploadIcon } from "lucide-react"; import { useEffect, useMemo, useState } from "react"; import useSWR, { SWRResponse } from "swr"; +import { Agent } from "~/lib/model/agents"; import { KnowledgeFile, KnowledgeFileState, @@ -13,12 +14,24 @@ import { assetUrl } from "~/lib/utils"; import { Button } from "~/components/ui/button"; import { Avatar } from "../ui/avatar"; +import { Label } from "../ui/label"; +import { Textarea } from "../ui/textarea"; import FileModal from "./file/FileModal"; import { NotionModal } from "./notion/NotionModal"; import { OnedriveModal } from "./onedrive/OneDriveModal"; import { WebsiteModal } from "./website/WebsiteModal"; -export default function AgentKnowledgePanel({ agentId }: { agentId: string }) { +type AgentKnowledgePanelProps = { + agentId: string; + agent: Agent; + updateAgent: (updatedAgent: Agent) => void; +}; + +export default function AgentKnowledgePanel({ + agentId, + agent, + updateAgent, +}: AgentKnowledgePanelProps) { const [blockPollingLocalFiles, setBlockPollingLocalFiles] = useState(false); const [blockPollingOneDrive, setBlockPollingOneDrive] = useState(false); const [blockPollingNotion, setBlockPollingNotion] = useState(false); @@ -34,6 +47,10 @@ export default function AgentKnowledgePanel({ agentId }: { agentId: string }) { const [isNotionModalOpen, setIsNotionModalOpen] = useState(false); const [isWebsiteModalOpen, setIsWebsiteModalOpen] = useState(false); + const [knowledgeDescription, setKnowledgeDescription] = useState( + agent.knowledgeDescription + ); + const getLocalFiles: SWRResponse = useSWR( KnowledgeService.getLocalKnowledgeFilesForAgent.key(agentId), ({ agentId }) => @@ -347,6 +364,22 @@ export default function AgentKnowledgePanel({ agentId }: { agentId: string }) { return (
+
+ +