From 29e1443aa8976cebc3b22d40cc65e33159c38c99 Mon Sep 17 00:00:00 2001 From: ch-liuzhide Date: Mon, 23 Dec 2024 15:08:01 +0800 Subject: [PATCH] Load the avatar by using a background image. --- assistant/src/Chat/index.tsx | 30 ++++++++++++++++++++++-------- client/package.json | 2 +- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/assistant/src/Chat/index.tsx b/assistant/src/Chat/index.tsx index 08e85f17..b5a402b8 100644 --- a/assistant/src/Chat/index.tsx +++ b/assistant/src/Chat/index.tsx @@ -68,6 +68,21 @@ export interface ChatProps extends BotInfo { getToolsResult?: (response: any) => void; } +const Avatar = (props: { backgroundColor?: string; avatar: string }) => { + const { backgroundColor, avatar } = props; + return ( +
+ ); +}; + const Chat: FC = memo( ({ helloMessage = '让我们开始对话吧~', @@ -276,8 +291,11 @@ const Chat: FC = memo( // ============================ Roles ============================= const roles: GetProp = React.useMemo(() => { - const { title, avatar = BOT_INFO.avatar } = - currentBotInfo?.assistantMeta ?? {}; + const { + title, + avatar = BOT_INFO.avatar, + backgroundColor, + } = currentBotInfo?.assistantMeta ?? {}; return { [Role.init]: { classNames: { @@ -286,9 +304,7 @@ const Chat: FC = memo( content: 'petercat-content-start', }, placement: 'start', - avatar: { - src: avatar, - }, + avatar: , header: <>{title}, messageRender: (message) => { try { @@ -335,9 +351,7 @@ const Chat: FC = memo( header: 'petercat-header', }, placement: 'start', - avatar: { - src: avatar, - }, + avatar: , variant: 'borderless', header: <>{title}, messageRender: (message: any) => { diff --git a/client/package.json b/client/package.json index 6b54fa7b..d766c8f6 100644 --- a/client/package.json +++ b/client/package.json @@ -22,7 +22,7 @@ "@fullpage/react-fullpage": "^0.1.42", "@next/bundle-analyzer": "^13.4.19", "@nextui-org/react": "^2.2.9", - "@petercatai/assistant": "1.0.22", + "@petercatai/assistant": "^2.0.4", "@sentry/nextjs": "^8.28.0", "@supabase/supabase-js": "^2.32.0", "@tanstack/react-query": "^5.17.19",