diff --git a/src/components/BitteAiChat.tsx b/src/components/BitteAiChat.tsx
index d767a3d..ee886b6 100644
--- a/src/components/BitteAiChat.tsx
+++ b/src/components/BitteAiChat.tsx
@@ -13,6 +13,7 @@ export const BitteAiChat = ({
historyApiUrl,
agentId,
options,
+ messageComponents
}: BitteAiChatProps) => {
const [loadedData, setLoadedData] = useState({
agentIdLoaded: "",
@@ -61,6 +62,7 @@ export const BitteAiChat = ({
agentId={agentId ?? agentIdLoaded}
messages={uiMessages}
options={optionsProps}
+ messageComponents={messageComponents}
/>
);
diff --git a/src/components/chat/ChatContent.tsx b/src/components/chat/ChatContent.tsx
index 55bb307..0bc195d 100644
--- a/src/components/chat/ChatContent.tsx
+++ b/src/components/chat/ChatContent.tsx
@@ -32,6 +32,7 @@ export const ChatContent = ({
apiKey,
options,
messages: initialMessages,
+ messageComponents
}: BitteAiChatProps) => {
const chatId = useRef(options?.chatId || generateId()).current;
const [isAtBottom, setIsAtBottom] = useState(true);
@@ -243,6 +244,7 @@ export const ChatContent = ({
textColor={textColor!}
agentImage={options?.agentImage}
addToolResult={addToolResult}
+ components={messageComponents}
/>
);
})}
diff --git a/src/components/chat/MessageGroup.tsx b/src/components/chat/MessageGroup.tsx
index dcb02d0..dbe31e4 100644
--- a/src/components/chat/MessageGroup.tsx
+++ b/src/components/chat/MessageGroup.tsx
@@ -1,18 +1,15 @@
-import { useEffect, useState } from "react";
-
import { MessageSquare } from "lucide-react";
-
-import { NearSafe } from "near-safe";
-
-import { Wallet } from "@near-wallet-selector/core";
-import { Account } from "near-api-js";
-import { cn, safeStringify } from "../../lib/utils";
-
import { formatAgentId, getAgentIdFromMessage } from "../../lib/chat";
import { BittePrimitiveName, DEFAULT_AGENT_ID } from "../../lib/constants";
import { BITTE_BLACK_IMG } from "../../lib/images";
import { isDataString } from "../../lib/regex";
-import { BitteToolResult, SmartActionAiMessage } from "../../types/types";
+import {
+ BitteToolResult,
+ ChatCustomComponents,
+ MessageGroupComponentProps,
+ SmartActionAiMessage,
+ ToolResultComponentProps,
+} from "../../types/types";
import {
Accordion,
AccordionContent,
@@ -29,9 +26,11 @@ import { SAMessage } from "./Message";
import { EvmTxCard } from "./transactions/EvmTxCard";
import { ReviewSignMessage } from "./transactions/ReviewSignMessage";
import { ReviewTransaction } from "./transactions/ReviewTransaction";
+import { cn } from "../../lib/utils";
+import { useEffect, useState } from "react";
interface MessageGroupProps {
- chatId: string | undefined;
+ chatId?: string;
groupKey: string;
messages: SmartActionAiMessage[];
accountId: string;
@@ -39,9 +38,6 @@ interface MessageGroupProps {
isLoading?: boolean;
agentImage?: string;
agentName?: string;
- evmAdapter?: NearSafe;
- account?: Account;
- wallet?: Wallet;
messageBackgroundColor: string;
borderColor: string;
textColor: string;
@@ -49,22 +45,103 @@ interface MessageGroupProps {
toolCallId: string;
result: BitteToolResult;
}) => void;
+ components?: ChatCustomComponents;
}
+// Default components
+const DefaultMessageContainer = ({
+ message,
+ isUser,
+ userName,
+ children,
+ style,
+}: MessageGroupComponentProps) => (
+ {userName}
+ {formatAgentId(message.agentId ?? "Bitte Assistant")}
+
{toolName}
+ - {creator || accountId} -
- > - ) : ( - <> -- {formatAgentId(message?.agentId ?? "Bitte Assistant")} -
- > - )} -{toolName}
-