From 156a3d5882e7cd24bf6ec9fae7ff0a4e99e2303c Mon Sep 17 00:00:00 2001 From: Emre Kuru Date: Fri, 1 Dec 2023 15:46:28 +0300 Subject: [PATCH] fix: Fixed get feedback, feat: Added the routes to be forwarded --- Expectation/UI_message_handler.py | 173 +++++++++++++++++++++++++++++- 1 file changed, 172 insertions(+), 1 deletion(-) diff --git a/Expectation/UI_message_handler.py b/Expectation/UI_message_handler.py index 821a6d5..d4f67f5 100644 --- a/Expectation/UI_message_handler.py +++ b/Expectation/UI_message_handler.py @@ -95,7 +95,9 @@ async def get_feedback(user_id: str): elif interaction.at[user_id, 'Feedback'] != "": result = interaction.at[user_id, 'Feedback'] + interaction.at[user_id,"Feedback"] = "" print(interaction.loc[user_id]) + save(interaction) return {"accepted": False, "feedback": result} await asyncio.sleep(2) # Sleep for 2 seconds before checking again @@ -104,4 +106,173 @@ async def get_feedback(user_id: str): detail="Feedback request timed out") - \ No newline at end of file + + + + + + + + +# Rest of this is just being forwarded + +# Home Route Forwards +@app.post("/register") +async def register(request: Request): + + url = "http://127.0.0.1:8000/register" + + try: + request_data = await request.json() + internal_response = requests.post(url, json=request_data) + internal_response.raise_for_status() + except requests.exceptions.RequestException as e: + raise HTTPException(status_code=500, detail=f"Internal Server Error: {e}") + + return internal_response.json() + +@app.post("/get-user-categories") +async def register(request: Request): + + url = "http://127.0.0.1:8000/get-user-categories" + + try: + request_data = await request.json() + internal_response = requests.post(url, json=request_data) + internal_response.raise_for_status() + except requests.exceptions.RequestException as e: + raise HTTPException(status_code=500, detail=f"Internal Server Error: {e}") + + return internal_response.json() + +@app.post("/save-user-profile") +async def register(request: Request): + + url = "http://127.0.0.1:8000/save-user-profile" + + try: + request_data = await request.json() + internal_response = requests.post(url, json=request_data) + internal_response.raise_for_status() + except requests.exceptions.RequestException as e: + raise HTTPException(status_code=500, detail=f"Internal Server Error: {e}") + + return internal_response.json() + + +@app.post("/save-preferences") +async def register(request: Request): + + url = "http://127.0.0.1:8000/save-preferences" + + try: + request_data = await request.json() + internal_response = requests.post(url, json=request_data) + internal_response.raise_for_status() + except requests.exceptions.RequestException as e: + raise HTTPException(status_code=500, detail=f"Internal Server Error: {e}") + + return internal_response.json() + +@app.post("/get-recipe-ingredients") +async def register(request: Request): + + url = "http://127.0.0.1:8000/get-recipe-ingredients" + + try: + request_data = await request.json() + internal_response = requests.post(url, json=request_data) + internal_response.raise_for_status() + except requests.exceptions.RequestException as e: + raise HTTPException(status_code=500, detail=f"Internal Server Error: {e}") + + return internal_response.json() + +@app.post("/save-constraints") +async def register(request: Request): + + url = "http://127.0.0.1:8000/save-constraints" + + try: + request_data = await request.json() + internal_response = requests.post(url, json=request_data) + internal_response.raise_for_status() + except requests.exceptions.RequestException as e: + raise HTTPException(status_code=500, detail=f"Internal Server Error: {e}") + + return internal_response.json() + + +#Active Learning Forwards + +@app.post("/active-learning/get-init-sample") +async def register(request: Request): + + url = "http://127.0.0.1:8000/active-learning/get-init-sample" + + try: + request_data = await request.json() + internal_response = requests.post(url, json=request_data) + internal_response.raise_for_status() + except requests.exceptions.RequestException as e: + raise HTTPException(status_code=500, detail=f"Internal Server Error: {e}") + + return internal_response.json() + +@app.post("/active-learning/save-user-response") +async def register(request: Request): + + url = "http://127.0.0.1:8000/active-learning/save-user-response" + + try: + request_data = await request.json() + internal_response = requests.post(url, json=request_data) + internal_response.raise_for_status() + except requests.exceptions.RequestException as e: + raise HTTPException(status_code=500, detail=f"Internal Server Error: {e}") + + return internal_response.json() + +@app.post("/active-learning/submit-feedback-data") +async def register(request: Request): + + url = "http://127.0.0.1:8000/active-learning/submit-feedback-data" + + try: + request_data = await request.json() + internal_response = requests.post(url, json=request_data) + internal_response.raise_for_status() + except requests.exceptions.RequestException as e: + raise HTTPException(status_code=500, detail=f"Internal Server Error: {e}") + + return internal_response.json() + +@app.post("/active-learning/active_learning_feedback_and_update_step") +async def register(request: Request): + + url = "http://127.0.0.1:8000/active-learning/active_learning_feedback_and_update_step" + + try: + request_data = await request.json() + internal_response = requests.post(url, json=request_data) + internal_response.raise_for_status() + except requests.exceptions.RequestException as e: + raise HTTPException(status_code=500, detail=f"Internal Server Error: {e}") + + return internal_response.json() + + +# Recommendation Forwards +@app.post("/recommendation/generate-user-recommendations") +async def register(request: Request): + + url = "http://127.0.0.1:8000/recommendation/generate-user-recommendations" + + try: + request_data = await request.json() + internal_response = requests.post(url, json=request_data) + internal_response.raise_for_status() + except requests.exceptions.RequestException as e: + raise HTTPException(status_code=500, detail=f"Internal Server Error: {e}") + + return internal_response.json() \ No newline at end of file