srinuksv commited on
Commit
30adbdc
1 Parent(s): 0f1eb98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
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
- # Logic to save chat history, using the `id` from the frontend
163
- print(history) # You can replace this with actual save logic
164
- cleaned_summary = summarize_conversation(llm_client, history)
165
- print(cleaned_summary)
166
- return {"message": "Chat history saved"}
 
 
 
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()