update no output message

This commit is contained in:
anovazzi1 2024-06-18 19:12:07 -03:00
commit ab71831ca9
2 changed files with 37 additions and 40 deletions

View file

@ -188,7 +188,7 @@ export default function ChatMessage({
<Markdown <Markdown
remarkPlugins={[remarkGfm, remarkMath]} remarkPlugins={[remarkGfm, remarkMath]}
rehypePlugins={[rehypeMathjax]} rehypePlugins={[rehypeMathjax]}
className="markdown prose flex flex-col text-primary word-break-break-word dark:prose-invert" className={cn("markdown prose flex flex-col word-break-break-word dark:prose-invert",chatMessage === "" ? "text-chat-trigger-disabled" : "text-primary")}
components={{ components={{
pre({ node, ...props }) { pre({ node, ...props }) {
return <>{props.children}</>; return <>{props.children}</>;
@ -235,7 +235,7 @@ export default function ChatMessage({
}, },
]} ]}
activeTab={"0"} activeTab={"0"}
setActiveTab={() => {}} setActiveTab={() => { }}
/> />
) : ( ) : (
<code className={className} {...props}> <code className={className} {...props}>
@ -245,7 +245,7 @@ export default function ChatMessage({
}, },
}} }}
> >
{chatMessage} {chatMessage===""?EMPTY_INPUT_SEND_MESSAGE:chatMessage}
</Markdown> </Markdown>
), ),
[chat.message, chatMessage], [chat.message, chatMessage],
@ -274,52 +274,52 @@ export default function ChatMessage({
} }
/> />
</button> </button>
<span className="prose text-primary word-break-break-word dark:prose-invert"> <span className={cn("prose word-break-break-word dark:prose-invert",(chatMessage!==""?EMPTY_INPUT_SEND_MESSAGE:chatMessage?"text-primary":"text-chat-trigger-disabled"))}>
{promptOpen {promptOpen
? template?.split("\n")?.map((line, index) => { ? template?.split("\n")?.map((line, index) => {
const regex = /{([^}]+)}/g; const regex = /{([^}]+)}/g;
let match; let match;
let parts: Array<JSX.Element | string> = []; let parts: Array<JSX.Element | string> = [];
let lastIndex = 0; let lastIndex = 0;
while ((match = regex.exec(line)) !== null) { while ((match = regex.exec(line)) !== null) {
// Push text up to the match // Push text up to the match
if (match.index !== lastIndex) { if (match.index !== lastIndex) {
parts.push(line.substring(lastIndex, match.index)); parts.push(line.substring(lastIndex, match.index));
} }
// Push div with matched text // Push div with matched text
if (chat.message[match[1]]) { if (chat.message[match[1]]) {
parts.push( parts.push(
<span className="chat-message-highlight"> <span className="chat-message-highlight">
{chat.message[match[1]]} {chat.message[match[1]]}
</span>, </span>,
); );
} }
// Update last index // Update last index
lastIndex = regex.lastIndex; lastIndex = regex.lastIndex;
} }
// Push text after the last match // Push text after the last match
if (lastIndex !== line.length) { if (lastIndex !== line.length) {
parts.push(line.substring(lastIndex)); parts.push(line.substring(lastIndex));
} }
return <p>{parts}</p>; return <p>{parts}</p>;
}) })
: chatMessage} : (chatMessage === "" ? EMPTY_INPUT_SEND_MESSAGE : chatMessage)
}
</span> </span>
</> </>
) : ( ) : (
<div className="flex flex-col"> <div className="flex flex-col">
<span <span
className={`prose word-break-break-word dark:prose-invert ${ className={`prose word-break-break-word dark:prose-invert ${chatMessage === ""
chatMessage === EMPTY_INPUT_SEND_MESSAGE ? "text-chat-trigger-disabled"
? "text-gray-400"
: "text-primary" : "text-primary"
}`} }`}
data-testid={ data-testid={
"chat-message-" + chat.sender_name + "-" + chatMessage "chat-message-" + chat.sender_name + "-" + chatMessage
} }
> >
{chatMessage} {(chatMessage === "" ? EMPTY_INPUT_SEND_MESSAGE : chatMessage)}
</span> </span>
{chat.files && ( {chat.files && (
<div className="my-2 flex flex-col gap-5"> <div className="my-2 flex flex-col gap-5">

View file

@ -80,10 +80,7 @@ export default function ChatView({
return { return {
isSend: !is_ai, isSend: !is_ai,
message: message,
(message === "" || !message) && !stream_url && files?.length === 0
? EMPTY_INPUT_SEND_MESSAGE
: message,
sender_name, sender_name,
componentId: output.id, componentId: output.id,
stream_url: stream_url, stream_url: stream_url,