Skip to content

Instantly share code, notes, and snippets.

@shibanovp
Last active April 21, 2023 11:20
Show Gist options
  • Save shibanovp/6f3e62bc3e4941135a1d4f3c48bcc8af to your computer and use it in GitHub Desktop.
Save shibanovp/6f3e62bc3e4941135a1d4f3c48bcc8af to your computer and use it in GitHub Desktop.
"use client";
import { FC } from "react";
import type { MessageType } from "langchain/schema";
interface ChatMessageProps {
text: string;
type: MessageType;
}
const ChatMessage: FC<ChatMessageProps> = ({ text, type }) => {
const isHuman = type === "human";
return (
<div className={`flex my-2 ${isHuman ? "justify-end" : "justify-start"}`}>
<div>
<p
className={`font-semibold text-gray-500 ${
isHuman ? "text-right" : "text-left"
}`}
>
{type}
</p>
<div
className={`w-auto max-w-3/4 rounded-tl-lg rounded-tr-lg px-4 py-2 ${
isHuman
? "bg-blue-400 text-white rounded-bl-lg"
: "bg-gray-300 text-gray-700 rounded-br-lg"
}`}
>
<p className="whitespace-pre-wrap">{text}</p>
</div>
</div>
</div>
);
};
export default ChatMessage;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment