Skip to content

Commit

Permalink
chore: improve tool messsage in remix
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-bo-davis committed Mar 12, 2024
1 parent 66ea47a commit 454c3da
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions remix/app/components/chat/ChatMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import type { AgentHistoryItem } from '@codellm/core';

const chatBubbleCommonClassNames = 'whitespace-pre-wrap p-6 chat-bubble';
const chatBubbleCommonClassNames = 'whitespace-pre-wrap p-6';

const chatBubbleClassNames = {
assistant: `${chatBubbleCommonClassNames} chat-bubble-primary`,
error: `${chatBubbleCommonClassNames} chat-bubble-error`,
tool: `${chatBubbleCommonClassNames} chat-bubble-accent`,
user: `${chatBubbleCommonClassNames}`,
assistant: `${chatBubbleCommonClassNames} chat-bubble chat-bubble-primary`,
error: `${chatBubbleCommonClassNames} chat-bubble chat-bubble-error`,
tool: `${chatBubbleCommonClassNames} card-body rounded-md chat-bubble-accent`,
user: `${chatBubbleCommonClassNames} chat-bubble`,
};

export const ChatMessage = ({ message }: { message: AgentHistoryItem }) => {
const role = message.role;

const wrapperClassNames =
role === 'user' ? 'chat chat-start' : 'chat chat-end';
const getWrapperClasses = () => {
if (role === 'user') return 'chat chat-start';
if (role === 'tool') return 'card items-center m-1';
return 'chat chat-end';
};

const Content = () => {
if (role === 'error') {
Expand All @@ -37,7 +40,7 @@ export const ChatMessage = ({ message }: { message: AgentHistoryItem }) => {
};

return (
<div className={wrapperClassNames}>
<div className={getWrapperClasses()}>
<div className={chatBubbleClassNames[role]}>
<Content />
</div>
Expand Down

0 comments on commit 454c3da

Please # to comment.