From ab956664938dc7fb69a59d66d190ff4e69d05434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulius=20Preik=C5=A1a?= Date: Mon, 24 Jun 2024 15:08:35 +0300 Subject: [PATCH] feat: added workspace to main request --- GUI/back-end/main.py | 8 ++++++-- .../src/components/displays/chat/ChatDisplay.tsx | 9 ++++++++- GUI/front-end/src/services/request/requestService.ts | 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/GUI/back-end/main.py b/GUI/back-end/main.py index ee61a24..0260c0c 100644 --- a/GUI/back-end/main.py +++ b/GUI/back-end/main.py @@ -41,7 +41,10 @@ @app.route('/api/v1/request', methods=['POST']) def process(): - request_data = request.get_json() + request_data = request.json.get('content') + request_workspace = request.json.get('workspace') + print(request_data) + print(request_workspace) print("Got data") logging.info(request_data) if not request_data: @@ -75,4 +78,5 @@ def process(): # Run the app if __name__ == '__main__': - app.run(debug=True, host='0.0.0.0', port=8080) \ No newline at end of file + # app.run(debug=True, host='0.0.0.0', port=8080) + app.run(debug=True, port=8080) \ No newline at end of file diff --git a/GUI/front-end/src/components/displays/chat/ChatDisplay.tsx b/GUI/front-end/src/components/displays/chat/ChatDisplay.tsx index f284bc3..3428284 100644 --- a/GUI/front-end/src/components/displays/chat/ChatDisplay.tsx +++ b/GUI/front-end/src/components/displays/chat/ChatDisplay.tsx @@ -6,6 +6,7 @@ import { AccountCircle as AccountCircleIcon } from '@mui/icons-material'; import { useApplicationContext } from '../../../contexts'; import { KathLogo } from '../../svgs'; import { useSendRequest } from '../../../hooks'; +import { useWorkspaceContext } from '../../../contexts/tool/UseWorkspaceContext'; interface Props {} @@ -14,6 +15,7 @@ export const ChatDisplay: React.FC = () => { const [isInputDisabled, setIsInputDisabled] = React.useState(false); const applicationContext = useApplicationContext(); + const workspaceContext = useWorkspaceContext(); const sendRequest = useSendRequest(); const handleSubmit = async (content: string) => { @@ -23,7 +25,12 @@ export const ChatDisplay: React.FC = () => { } author='User' content={content} />, ]); - const responseResult = await sendRequest.mutateAsync(content); + const data = { + content: content, + workspace: workspaceContext.workspace, + } + + const responseResult = await sendRequest.mutateAsync(data); setIsInputDisabled(false); setChatInstances((prevInstances) => [ diff --git a/GUI/front-end/src/services/request/requestService.ts b/GUI/front-end/src/services/request/requestService.ts index 4a295b5..c21c537 100644 --- a/GUI/front-end/src/services/request/requestService.ts +++ b/GUI/front-end/src/services/request/requestService.ts @@ -2,9 +2,9 @@ import { ENDPOINTS } from "../../types/constants"; import httpClient from "../httpClient"; -export async function sendRequest(request: string) { +export async function sendRequest(data: { content: string, workspace: string | null}) { return await httpClient - .post(ENDPOINTS.REQUEST, request) + .post(ENDPOINTS.REQUEST, data) .then((res) => res.data) .catch((err) => { console.error(err);