Skip to content

Commit

Permalink
[extension] - refactor: streamline icon imports in AgentMessage compo…
Browse files Browse the repository at this point in the history
…nent

 - Removed individual icon imports for various services and replaced with a generic document icon
 - Implemented a citation icon map to dynamically resolve icons based on document provider
 - Simplified makeDocumentCitation and makeWebsearchResultsCitation by integrating icon components directly
  • Loading branch information
JulesBelveze committed Dec 18, 2024
1 parent 4a7c459 commit 870a2fc
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions extension/app/src/components/conversation/AgentMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,12 @@ import {
removeNulls,
} from "@dust-tt/client";
import type { ConversationMessageSizeType } from "@dust-tt/sparkle";
import {
ConfluenceLogo,
DocumentTextIcon,
DriveLogo,
GithubLogo,
ImageIcon,
IntercomLogo,
MicrosoftLogo,
NotionLogo,
SlackLogo,
SnowflakeLogo,
ZendeskLogo,
} from "@dust-tt/sparkle";
import { DocumentTextStrokeIcon } from "@dust-tt/sparkle";
import {
Citation,
CitationIcons,
CitationIndex,
CitationTitle,
Icon,
} from "@dust-tt/sparkle";
import {
ArrowPathIcon,
Expand All @@ -59,12 +46,13 @@ import {
} from "@dust-tt/sparkle";
import { AgentMessageActions } from "@extension/components/conversation/AgentMessageActions";
import { GenerationContext } from "@extension/components/conversation/GenerationContextProvider";
import type { MarkdownCitation } from "@extension/components/conversation/MarkdownCitation";
import {
CitationsContext,
CiteBlock,
getCiteDirective,
} from "@extension/components/markdown/CiteBlock";
import type { MarkdownCitation } from "@extension/components/markdown/MarkdownCitation";
import { citationIconMap } from "@extension/components/markdown/MarkdownCitation";
import {
MentionBlock,
mentionDirective,
Expand Down Expand Up @@ -103,10 +91,12 @@ export function visualizationDirective() {
export function makeDocumentCitation(
document: RetrievalDocumentPublicType
): MarkdownCitation {
const IconComponent =
citationIconMap[getProviderFromRetrievedDocument(document)];
return {
href: document.sourceUrl ?? undefined,
title: getTitleFromRetrievedDocument(document),
type: getProviderFromRetrievedDocument(document),
icon: <IconComponent />,
};
}

Expand All @@ -117,7 +107,7 @@ export function makeWebsearchResultsCitation(
description: result.snippet,
href: result.link,
title: result.title,
type: "document" as const,
icon: <DocumentTextStrokeIcon />,
};
}

Expand Down

0 comments on commit 870a2fc

Please sign in to comment.