Skip to content

Commit

Permalink
Fix: bypass not found error (#322)
Browse files Browse the repository at this point in the history
Signed-off-by: Daishan Peng <[email protected]>
  • Loading branch information
StrongMonkey authored Oct 25, 2024
1 parent 3508c55 commit 98cbf98
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 78 deletions.
6 changes: 3 additions & 3 deletions pkg/controller/handlers/uploads/remoteknowledgesource.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ func (u *UploadHandler) HandleUploadRun(req router.Request, resp router.Response

file, err := u.gptscript.ReadFileInWorkspace(req.Ctx, ".metadata.json", gptscript.ReadFileInWorkspaceOptions{WorkspaceID: thread.Spec.WorkspaceID})
if err != nil {
// Purposely ignore not found errors.
if !strings.HasPrefix(err.Error(), "not found") {
return err
if strings.HasPrefix(err.Error(), "not found") {
return nil
}
return err
} else {
if err = json.Unmarshal(file, &metadata); err != nil {
return err
Expand Down
17 changes: 0 additions & 17 deletions ui/admin/app/components/knowledge/AgentKnowledgePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,6 @@ export function AgentKnowledgePanel({ agentId }: { agentId: string }) {
let notionSource = remoteKnowledgeSources.find(
(source) => source.sourceType === "notion"
);
const onedriveSource = remoteKnowledgeSources.find(
(source) => source.sourceType === "onedrive"
);
const websiteSource = remoteKnowledgeSources.find(
(source) => source.sourceType === "website"
);

const onClickNotion = async () => {
if (!notionSource) {
Expand All @@ -178,21 +172,10 @@ export function AgentKnowledgePanel({ agentId }: { agentId: string }) {
};

const onClickOnedrive = async () => {
if (!onedriveSource) {
await KnowledgeService.createRemoteKnowledgeSource(agentId, {
sourceType: "onedrive",
});
}
setIsOnedriveModalOpen(true);
};

const onClickWebsite = async () => {
if (!websiteSource) {
await KnowledgeService.createRemoteKnowledgeSource(agentId, {
sourceType: "website",
});
getRemoteKnowledgeSources.mutate();
}
setIsWebsiteModalOpen(true);
};

Expand Down
35 changes: 22 additions & 13 deletions ui/admin/app/components/knowledge/onedrive/AddLinkModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,30 @@ const AddLinkModal: FC<AddLinkModalProps> = ({
const [newLink, setNewLink] = useState("");

const handleSave = async () => {
if (!onedriveSource) return;

await KnowledgeService.updateRemoteKnowledgeSource(
agentId,
onedriveSource!.id,
{
...onedriveSource,
if (!onedriveSource) {
await KnowledgeService.createRemoteKnowledgeSource(agentId, {
sourceType: "onedrive",
onedriveConfig: {
sharedLinks: [
...(onedriveSource.onedriveConfig?.sharedLinks || []),
newLink,
],
sharedLinks: [newLink],
},
}
);
});
} else {
await KnowledgeService.updateRemoteKnowledgeSource(
agentId,
onedriveSource!.id,
{
...onedriveSource,
onedriveConfig: {
sharedLinks: [
...(onedriveSource.onedriveConfig?.sharedLinks ||
[]),
newLink,
],
},
}
);
}

setNewLink("");
startPolling();
onOpenChange(false);
Expand Down
30 changes: 13 additions & 17 deletions ui/admin/app/components/knowledge/onedrive/OneDriveModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -390,23 +390,19 @@ export const OnedriveModal: FC<OnedriveModalProps> = ({
Close
</Button>
</div>
{onedriveSource && (
<>
<RemoteSourceSettingModal
agentId={agentId}
isOpen={isSettingModalOpen}
onOpenChange={setIsSettingModalOpen}
remoteKnowledgeSource={onedriveSource}
/>
<AddLinkModal
agentId={agentId}
onedriveSource={onedriveSource}
startPolling={startPolling}
isOpen={isAddLinkModalOpen}
onOpenChange={setIsAddLinkModalOpen}
/>
</>
)}
<RemoteSourceSettingModal
agentId={agentId}
isOpen={isSettingModalOpen}
onOpenChange={setIsSettingModalOpen}
remoteKnowledgeSource={onedriveSource!}
/>
<AddLinkModal
agentId={agentId}
onedriveSource={onedriveSource!}
startPolling={startPolling}
isOpen={isAddLinkModalOpen}
onOpenChange={setIsAddLinkModalOpen}
/>
</DialogContent>
</Dialog>
);
Expand Down
32 changes: 21 additions & 11 deletions ui/admin/app/components/knowledge/website/AddWebsiteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,30 @@ const AddWebsiteModal: FC<AddWebsiteModalProps> = ({
newWebsite.startsWith("https://")
? newWebsite
: `https://${newWebsite}`;
await KnowledgeService.updateRemoteKnowledgeSource(
agentId,
websiteSource.id!,
{

if (!websiteSource) {
await KnowledgeService.createRemoteKnowledgeSource(agentId, {
sourceType: "website",
websiteCrawlingConfig: {
urls: [
...(websiteSource.websiteCrawlingConfig?.urls ||
[]),
formattedWebsite,
],
urls: [formattedWebsite],
},
}
);
});
} else {
await KnowledgeService.updateRemoteKnowledgeSource(
agentId,
websiteSource.id!,
{
sourceType: "website",
websiteCrawlingConfig: {
urls: [
...(websiteSource.websiteCrawlingConfig?.urls ||
[]),
formattedWebsite,
],
},
}
);
}
const intervalId = setInterval(() => {
startPolling();
if (websiteSource?.runID) {
Expand Down
30 changes: 13 additions & 17 deletions ui/admin/app/components/knowledge/website/WebsiteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,23 +301,19 @@ export const WebsiteModal: FC<WebsiteModalProps> = ({
Close
</Button>
</div>
{websiteSource && (
<>
<RemoteSourceSettingModal
agentId={agentId}
isOpen={isSettingModalOpen}
onOpenChange={setIsSettingModalOpen}
remoteKnowledgeSource={websiteSource}
/>
<AddWebsiteModal
agentId={agentId}
websiteSource={websiteSource}
startPolling={startPolling}
isOpen={isAddWebsiteModalOpen}
onOpenChange={setIsAddWebsiteModalOpen}
/>
</>
)}
<RemoteSourceSettingModal
agentId={agentId}
isOpen={isSettingModalOpen}
onOpenChange={setIsSettingModalOpen}
remoteKnowledgeSource={websiteSource!}
/>
<AddWebsiteModal
agentId={agentId}
websiteSource={websiteSource!}
startPolling={startPolling}
isOpen={isAddWebsiteModalOpen}
onOpenChange={setIsAddWebsiteModalOpen}
/>
</DialogContent>
</Dialog>
);
Expand Down

0 comments on commit 98cbf98

Please sign in to comment.