clean function implemented on front

This commit is contained in:
anovazzi1 2023-04-25 22:02:25 -03:00
commit 101044946d
4 changed files with 16 additions and 11 deletions

View file

@ -61,5 +61,5 @@
"last 1 safari version" "last 1 safari version"
] ]
}, },
"proxy": "http://backend:7860" "proxy": "http://127.0.0.1:5003"
} }

View file

@ -19,12 +19,12 @@ export default function ChatMessage({ chat }: { chat: ChatMessageType }) {
> >
<div <div
className={classNames( className={classNames(
"rounded-full w-9 h-9 flex items-center my-3 justify-center", "rounded-full w-8 h-8 flex items-center my-3 justify-center",
chat.isSend ? "bg-gray-200" : "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 />} {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">
@ -49,7 +49,7 @@ export default function ChatMessage({ chat }: { chat: ChatMessageType }) {
)} )}
{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">
{chat.file ? ( {chat.files ? (
<div></div> <div></div>
) : ( ) : (
<span> <span>

View file

@ -52,7 +52,7 @@ export default function ChatModal({
}; };
useEffect(() => { useEffect(() => {
const newWs = new WebSocket(`ws://localhost:7860/chat/${flow.id}`); const newWs = new WebSocket(`ws://127.0.0.1:5003/chat/${flow.id}`);
newWs.onopen = () => { newWs.onopen = () => {
console.log("WebSocket connection established!"); console.log("WebSocket connection established!");
}; };
@ -78,7 +78,6 @@ export default function ChatModal({
isSend: !chatItem.is_bot, isSend: !chatItem.is_bot,
message: chatItem.message, message: chatItem.message,
thought: chatItem.intermediate_steps, thought: chatItem.intermediate_steps,
file:chatItem.data
}); });
} }
newChatHistory.push({ newChatHistory.push({
@ -217,7 +216,8 @@ export default function ChatModal({
} }
function clearChat() { function clearChat() {
setChatHistory([]); setChatHistory([]);
updateFlow({ ..._.cloneDeep(flow), chat: [] }); ws.send(JSON.stringify({clear_history:true}))
} }
const { closePopUp } = useContext(PopUpContext); const { closePopUp } = useContext(PopUpContext);

View file

@ -1,5 +1,10 @@
import { ReactFlowInstance } from 'reactflow'; import { ReactFlowInstance } from "reactflow";
import { FlowType } from "../flow"; import { FlowType } from "../flow";
export type ChatType = {flow:FlowType,reactFlowInstance:ReactFlowInstance} export type ChatType = { flow: FlowType; reactFlowInstance: ReactFlowInstance };
export type ChatMessageType = { message: string; isSend: boolean, thought?:string,file?:string } export type ChatMessageType = {
message: string;
isSend: boolean;
thought?: string;
files?: Array<{content:string,type:string}>;
};