style(chat_manager.py, chatMessage/index.tsx): fix indentation and formatting issues
This commit is contained in:
parent
0ef4572917
commit
0945dbe582
2 changed files with 70 additions and 70 deletions
|
|
@ -168,7 +168,7 @@ class ChatManager:
|
||||||
# Handle any exceptions that might occur
|
# Handle any exceptions that might occur
|
||||||
logger.exception(e)
|
logger.exception(e)
|
||||||
# send a message to the client
|
# send a message to the client
|
||||||
await self.send_message(client_id, f"Error: {e}")
|
await self.send_message(client_id, str(e))
|
||||||
raise e
|
raise e
|
||||||
finally:
|
finally:
|
||||||
await self.active_connections[client_id].close(
|
await self.active_connections[client_id].close(
|
||||||
|
|
|
||||||
|
|
@ -9,74 +9,74 @@ var Convert = require("ansi-to-html");
|
||||||
var convert = new Convert({ newline: true });
|
var convert = new Convert({ newline: true });
|
||||||
|
|
||||||
export default function ChatMessage({ chat }: { chat: ChatMessageType }) {
|
export default function ChatMessage({ chat }: { chat: ChatMessageType }) {
|
||||||
const [hidden, setHidden] = useState(true);
|
const [hidden, setHidden] = useState(true);
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
"w-full py-2 pl-2 flex",
|
"w-full py-2 pl-2 flex",
|
||||||
chat.isSend ? "bg-white" : "bg-gray-200"
|
chat.isSend ? "bg-white" : "bg-gray-200"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
"rounded-full w-8 h-8 flex items-center my-3 justify-center",
|
"rounded-full w-8 h-8 flex items-center my-3 justify-center",
|
||||||
chat.isSend ? "bg-gray-900" : "bg-gray-200"
|
chat.isSend ? "bg-gray-900" : "bg-gray-200"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{!chat.isSend && <img className="scale-150" src={AiIcon} />}
|
{!chat.isSend && <img className="scale-150" src={AiIcon} />}
|
||||||
{chat.isSend && <UserIcon className="w-6 h-6 -mb-1 text-gray-200" />}
|
{chat.isSend && <UserIcon className="w-6 h-6 -mb-1 text-gray-200" />}
|
||||||
</div>
|
</div>
|
||||||
{!chat.isSend ? (
|
{!chat.isSend ? (
|
||||||
<div className="w-full text-start flex items-center">
|
<div className="w-full text-start flex items-center">
|
||||||
<div className=" relative text-start inline-block text-gray-600 text-sm font-normal">
|
<div className="w-full relative text-start inline-block text-gray-600 text-sm font-normal">
|
||||||
{hidden && chat.thought && chat.thought !== "" && (
|
{hidden && chat.thought && chat.thought !== "" && (
|
||||||
<div
|
<div
|
||||||
onClick={() => setHidden((prev) => !prev)}
|
onClick={() => setHidden((prev) => !prev)}
|
||||||
className="absolute -top-1 -left-2 cursor-pointer"
|
className="absolute -top-1 -left-2 cursor-pointer"
|
||||||
>
|
>
|
||||||
<ChatBubbleOvalLeftEllipsisIcon className="w-5 h-5 animate-bounce" />
|
<ChatBubbleOvalLeftEllipsisIcon className="w-5 h-5 animate-bounce" />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{chat.thought && chat.thought !== "" && !hidden && (
|
{chat.thought && chat.thought !== "" && !hidden && (
|
||||||
<div
|
<div
|
||||||
onClick={() => setHidden((prev) => !prev)}
|
onClick={() => setHidden((prev) => !prev)}
|
||||||
className=" text-start inline-block rounded-md h-full border border-gray-300
|
className=" text-start inline-block rounded-md h-full border border-gray-300
|
||||||
bg-gray-100 w-[95%] pb-3 pt-3 px-2 ml-3 cursor-pointer scrollbar-hide overflow-scroll"
|
bg-gray-100 w-[95%] pb-3 pt-3 px-2 ml-3 cursor-pointer scrollbar-hide overflow-scroll"
|
||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
__html: convert.toHtml(chat.thought),
|
__html: convert.toHtml(chat.thought),
|
||||||
}}
|
}}
|
||||||
></div>
|
></div>
|
||||||
)}
|
)}
|
||||||
{chat.thought && chat.thought !== "" && !hidden && <br></br>}
|
{chat.thought && chat.thought !== "" && !hidden && <br></br>}
|
||||||
<div className="w-full px-4 pb-3 pt-3 pr-8">
|
<div className="w-full px-4 pb-3 pt-3 pr-8">
|
||||||
<span>
|
<span>
|
||||||
{chat.message}
|
{chat.message}
|
||||||
{chat.files && (
|
{chat.files && (
|
||||||
<div className="my-2 w-full">
|
<div className="my-2 w-full">
|
||||||
{chat.files.map((file,index) => {
|
{chat.files.map((file, index) => {
|
||||||
return (
|
return (
|
||||||
<div key={index} className="my-2 w-full">
|
<div key={index} className="my-2 w-full">
|
||||||
<FileCard
|
<FileCard
|
||||||
fileName={"Generated File"}
|
fileName={"Generated File"}
|
||||||
fileType={file.type}
|
fileType={file.type}
|
||||||
content={file.data}
|
content={file.data}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="w-full flex items-center">
|
<div className="w-full flex items-center">
|
||||||
<div className="text-start inline-block px-3 text-sm text-gray-600 dark:text-white dark:bg-gray-700">
|
<div className="text-start inline-block px-3 text-sm text-gray-600 dark:text-white dark:bg-gray-700">
|
||||||
{chat.message}
|
{chat.message}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue