Skip to content

Commit

Permalink
[front/components/actions/websearch] - refactor: update citation icon…
Browse files Browse the repository at this point in the history
… to use component in utils

 - Change the static document type to a DocumentTextStrokeIcon component in makeWebsearchResultsCitation

[front/components/assistant/conversation] - refactor: simplify AgentMessage component by omitting typeIcons

 - Remove the typeIcons mapping and utilize the document's icon directly in AgentMessage rendering
 - Delete unused icon imports after refactor
  • Loading branch information
JulesBelveze committed Dec 15, 2024
1 parent e02dab4 commit bea23fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DocumentTextStrokeIcon } from "@dust-tt/sparkle";
import type { WebsearchActionType, WebsearchResultType } from "@dust-tt/types";

import type { MarkdownCitation } from "@app/components/markdown/MarkdownCitation";
Expand All @@ -9,7 +10,7 @@ export function makeWebsearchResultsCitation(
description: result.snippet,
href: result.link,
title: result.title,
type: "document" as const,
icon: <DocumentTextStrokeIcon />,
};
}

Expand Down
34 changes: 2 additions & 32 deletions front/components/assistant/conversation/AgentMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,7 @@ import type {
FeedbackSelectorProps,
} from "@dust-tt/sparkle";
import { CitationIndex } from "@dust-tt/sparkle";
import {
Citation,
CitationIcons,
CitationTitle,
ConfluenceLogo,
DocumentTextIcon,
DriveLogo,
GithubLogo,
Icon,
ImageIcon,
IntercomLogo,
MicrosoftLogo,
NotionLogo,
SlackLogo,
SnowflakeLogo,
ZendeskLogo,
} from "@dust-tt/sparkle";
import { Citation, CitationIcons, CitationTitle } from "@dust-tt/sparkle";
import {
ArrowPathIcon,
Button,
Expand Down Expand Up @@ -93,20 +77,6 @@ import { useEventSource } from "@app/hooks/useEventSource";
import { useSubmitFunction } from "@app/lib/client/utils";
import { useAgentConfigurationLastAuthor } from "@app/lib/swr/assistants";

const typeIcons = {
confluence: ConfluenceLogo,
document: DocumentTextIcon,
github: GithubLogo,
google_drive: DriveLogo,
intercom: IntercomLogo,
microsoft: MicrosoftLogo,
zendesk: ZendeskLogo,
notion: NotionLogo,
slack: SlackLogo,
image: ImageIcon,
snowflake: SnowflakeLogo,
};

function cleanUpCitations(message: string): string {
const regex = / ?:cite\[[a-zA-Z0-9, ]+\]/g;
return message.replace(regex, "");
Expand Down Expand Up @@ -728,7 +698,7 @@ function getCitations({
<Citation key={index} href={document.href}>
<CitationIcons>
<CitationIndex>{index}</CitationIndex>
<Icon visual={typeIcons[document.type]} />
{document.icon}
</CitationIcons>
<CitationTitle>{document.title}</CitationTitle>
</Citation>
Expand Down

0 comments on commit bea23fc

Please sign in to comment.