Update app.py
Browse files
app.py
CHANGED
|
@@ -159,11 +159,14 @@ async def load_chat(request: Request, id: str):
|
|
| 159 |
# Route to save chat history
|
| 160 |
@app.post("/hist/")
|
| 161 |
async def save_chat_history(history: dict):
|
| 162 |
-
#
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
|
|
|
|
|
|
|
|
|
| 167 |
@app.post("/webhook")
|
| 168 |
async def receive_form_data(request: Request):
|
| 169 |
form_data = await request.json()
|
|
|
|
| 159 |
# Route to save chat history
|
| 160 |
@app.post("/hist/")
|
| 161 |
async def save_chat_history(history: dict):
|
| 162 |
+
# Check if 'history' is a key in the incoming dictionary
|
| 163 |
+
if 'history' in history and isinstance(history['history'], list):
|
| 164 |
+
print("Received history:", history['history']) # Debugging line
|
| 165 |
+
cleaned_summary = summarize_conversation(llm_client, history['history'])
|
| 166 |
+
print("Cleaned summary:", cleaned_summary) # Debugging line
|
| 167 |
+
return {"summary": cleaned_summary, "message": "Chat history saved"}
|
| 168 |
+
else:
|
| 169 |
+
return JSONResponse(status_code=400, content={"message": "Invalid history format"})
|
| 170 |
@app.post("/webhook")
|
| 171 |
async def receive_form_data(request: Request):
|
| 172 |
form_data = await request.json()
|