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 1ec2f3d..7d4478c 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);
@@ -239,6 +240,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 0bae7f9..020e39b 100644
--- a/src/components/chat/MessageGroup.tsx
+++ b/src/components/chat/MessageGroup.tsx
@@ -1,73 +1,124 @@
-import { useState, useEffect } from "react";
+import { MessageSquare } from 'lucide-react'
+import { useEffect, useState } from "react"
+import { getAgentIdFromMessage } from '../../lib/chat'
+import { DEFAULT_AGENT_ID } from '../../lib/constants'
+import { BITTE_BLACK_IMG } from "../../lib/images"
+import { cn } from "../../lib/utils"
+import type { BitteToolResult, ChatCustomComponents, MessageGroupComponentProps, SmartActionAiMessage, ToolResultComponentProps } from "../../types/types"
+import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "../ui/accordion"
+import { Card } from "../ui/card"
+import { ImageWithFallback } from "../ui/ImageWithFallback"
+import { SAMessage } from "./Message"
-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";
+ // Function to remove ".vercel.app" from agentId
+ export const formatAgentId = (agentId: string) => {
+ return agentId.replace(".vercel.app", "");
+ };
-import { 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 { SmartActionAiMessage, BitteToolResult } from "../../types/types";
-import {
- Accordion,
- AccordionContent,
- AccordionItem,
- AccordionTrigger,
-} from "../ui/accordion";
-import { Button } from "../ui/button";
-import { Card } from "../ui/card";
-import { ChartWrapper } from "../ui/charts/ChartWrapper";
-import { ImageWithFallback } from "../ui/ImageWithFallback";
-import { CodeBlock } from "./CodeBlock";
-import { ErrorBoundary } from "./ErrorBoundary";
-import { SAMessage } from "./Message";
-import { EvmTxCard } from "./transactions/EvmTxCard";
-import { ReviewTransaction } from "./transactions/ReviewTransaction";
-import { ReviewSignMessage } from "./transactions/ReviewSignMessage";
interface MessageGroupProps {
- chatId: string | undefined;
- groupKey: string;
- messages: SmartActionAiMessage[];
- accountId: string;
- creator?: string;
- isLoading?: boolean;
- agentImage?: string;
- agentName?: string;
- evmAdapter?: NearSafe;
- account?: Account;
- wallet?: Wallet;
- messageBackgroundColor: string;
- borderColor: string;
- textColor: string;
- addToolResult: (params: {
- toolCallId: string;
- result: BitteToolResult;
- }) => void;
+ chatId?: string
+ groupKey: string
+ messages: SmartActionAiMessage[]
+ accountId: string
+ creator?: string
+ isLoading?: boolean
+ agentImage?: string
+ agentName?: string
+ messageBackgroundColor: string
+ borderColor: string
+ textColor: string
+ addToolResult: (params: { 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}
-