Skip to content

Commit

Permalink
fix: Fixed get feedback, feat: Added the routes to be forwarded
Browse files Browse the repository at this point in the history
  • Loading branch information
emrekuruu committed Dec 1, 2023
1 parent a3eff50 commit 156a3d5
Showing 1 changed file with 172 additions and 1 deletion.
173 changes: 172 additions & 1 deletion Expectation/UI_message_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -104,4 +106,173 @@ async def get_feedback(user_id: str):
detail="Feedback request timed out")











# 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()

0 comments on commit 156a3d5

Please sign in to comment.