Skip to content

Commit

Permalink
build org
Browse files Browse the repository at this point in the history
  • Loading branch information
pablonyx committed Dec 2, 2024
1 parent 911fbfa commit d97e96b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
5 changes: 3 additions & 2 deletions web/src/app/chat/message/MemoizedTextComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ValidSources } from "@/lib/types";
import React, { memo } from "react";
import isEqual from "lodash/isEqual";

export const MemoizedA = memo(({ docs, children }: any) => {
export const MemoizedAnchor = memo(({ docs, children }: any) => {
console.log(children);
const value = children?.toString();
if (value?.startsWith("[") && value?.endsWith("]")) {
Expand All @@ -24,7 +24,7 @@ export const MemoizedA = memo(({ docs, children }: any) => {
};

const icon =
associatedDoc?.source_type == "web" ? (
associatedDoc?.source_type === "web" ? (
<WebResultIcon url={associatedDoc.link} />
) : (
getIcon(
Expand Down Expand Up @@ -86,5 +86,6 @@ export const MemoizedParagraph = memo(
}
);

MemoizedAnchor.displayName = "MemoizedAnchor";
MemoizedLink.displayName = "MemoizedLink";
MemoizedParagraph.displayName = "MemoizedParagraph";
23 changes: 10 additions & 13 deletions web/src/app/chat/message/Messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,13 @@ import GeneratingImageDisplay from "../tools/GeneratingImageDisplay";
import RegenerateOption from "../RegenerateOption";
import { LlmOverride } from "@/lib/hooks";
import { ContinueGenerating } from "./ContinueMessage";
import {
MemoizedA,
MemoizedLink,
MemoizedParagraph,
} from "./MemoizedTextComponents";
import { MemoizedAnchor, MemoizedParagraph } from "./MemoizedTextComponents";
import { extractCodeText } from "./codeUtils";
import ToolResult from "../../../components/tools/ToolResult";
import CsvContent from "../../../components/tools/CSVContent";
import SourceCard, {
SeeMoreBlock,
} from "@/components/chat_search/sources/SourceCard";
import { getSourceMetadata } from "@/lib/sources";
import { WebResultIcon } from "@/components/WebResultIcon";

const TOOLS_WITH_CUSTOM_HANDLING = [
SEARCH_TOOL_NAME,
Expand Down Expand Up @@ -308,11 +302,14 @@ export const AIMessage = ({
}

const paragraphCallback = useCallback(
(props: any) => <MemoizedParagraph children={props.children} />,
(props: any) => <MemoizedParagraph>{props.children}</MemoizedParagraph>,
[]
);
const aCallback = useCallback(
(props: any) => <MemoizedA docs={docs} children={props.children} />,

const anchorCallback = useCallback(
(props: any) => (
<MemoizedAnchor docs={docs}>{props.children}</MemoizedAnchor>
),
[docs]
);

Expand All @@ -326,9 +323,9 @@ export const AIMessage = ({

const markdownComponents = useMemo(
() => ({
a: aCallback,
a: anchorCallback,
p: paragraphCallback,
code: ({ node, className, children, ...props }: any) => {
code: ({ node, className, children }: any) => {
const codeText = extractCodeText(
node,
finalContent as string,
Expand All @@ -342,7 +339,7 @@ export const AIMessage = ({
);
},
}),
[aCallback, paragraphCallback, finalContent]
[anchorCallback, paragraphCallback, finalContent]
);

const renderedMarkdown = useMemo(() => {
Expand Down

0 comments on commit d97e96b

Please sign in to comment.