Refactor WebSocket connection to new port number 7860 in Makefile and add file upload support to ChatModal component.

This commit is contained in:
Gabriel Almeida 2023-04-27 09:53:31 -03:00
commit cdc6d2994a
2 changed files with 295 additions and 293 deletions

View file

@ -27,7 +27,7 @@ run_frontend:
cd src/frontend && npm start cd src/frontend && npm start
run_backend: run_backend:
poetry run uvicorn langflow.main:app --port 5003 --reload --log-level debug poetry run uvicorn langflow.main:app --port 7860 --reload --log-level debug
build_frontend: build_frontend:
cd src/frontend && CI='' npm run build cd src/frontend && CI='' npm run build

View file

@ -44,7 +44,7 @@ export default function ChatModal({
setChatHistory((old) => { setChatHistory((old) => {
let newChat = _.cloneDeep(old); let newChat = _.cloneDeep(old);
if (files) { if (files) {
newChat.push({ message, isSend, files,thought }); newChat.push({ message, isSend, files, thought });
} else if (thought) { } else if (thought) {
newChat.push({ message, isSend, thought }); newChat.push({ message, isSend, thought });
} else { } else {
@ -55,7 +55,7 @@ export default function ChatModal({
}; };
function connectWS() { function connectWS() {
const newWs = new WebSocket(`ws://127.0.0.1:5003/chat/${flow.id}`); const newWs = new WebSocket(`ws://127.0.0.1:7860/chat/${flow.id}`);
newWs.onopen = () => { newWs.onopen = () => {
console.log("WebSocket connection established!"); console.log("WebSocket connection established!");
}; };
@ -115,9 +115,8 @@ export default function ChatModal({
console.log(data); console.log(data);
} }
} catch (error) { } catch (error) {
if(event.data!=="Error: 1005"){ if (event.data !== "Error: 1005") {
setErrorData({ title: event.data }); setErrorData({ title: event.data });
} }
} }
}; };
@ -294,7 +293,10 @@ export default function ChatModal({
) : ( ) : (
<div className="flex flex-col h-full text-center justify-center w-full items-center align-middle "> <div className="flex flex-col h-full text-center justify-center w-full items-center align-middle ">
<span> <span>
👋 <span className="text-gray-600 text-lg">LangFlow Chat</span> 👋{" "}
<span className="text-gray-600 text-lg">
LangFlow Chat
</span>
</span> </span>
<br /> <br />
<div className="bg-gray-100 rounded-md w-2/4 px-6 py-8 border border-gray-200"> <div className="bg-gray-100 rounded-md w-2/4 px-6 py-8 border border-gray-200">