Spaces:
Sleeping
Sleeping
Commit ·
67b5753
1
Parent(s): 051660a
added /session-summary endpoint
Browse filesCo-authored-by: Copilot <copilot@github.com>
main.py
CHANGED
|
@@ -233,6 +233,44 @@ def add_log(
|
|
| 233 |
|
| 234 |
return {"message": "Log stored"}
|
| 235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
@app.get("/restaurants")
|
| 237 |
def get_restaurants(db: Session = Depends(get_db)):
|
| 238 |
|
|
|
|
| 233 |
|
| 234 |
return {"message": "Log stored"}
|
| 235 |
|
| 236 |
+
|
| 237 |
+
@app.get("/session-summary")
|
| 238 |
+
def get_session_summary(
|
| 239 |
+
session_id: str,
|
| 240 |
+
db: Session = Depends(get_db)
|
| 241 |
+
):
|
| 242 |
+
|
| 243 |
+
logs = (
|
| 244 |
+
db.query(Log)
|
| 245 |
+
.filter(Log.session_id == session_id)
|
| 246 |
+
.order_by(Log.timestamp.asc())
|
| 247 |
+
.all()
|
| 248 |
+
)
|
| 249 |
+
|
| 250 |
+
report = (
|
| 251 |
+
db.query(CtrReport)
|
| 252 |
+
.filter(CtrReport.session_id == session_id)
|
| 253 |
+
.order_by(CtrReport.id.desc())
|
| 254 |
+
.first()
|
| 255 |
+
)
|
| 256 |
+
|
| 257 |
+
return {
|
| 258 |
+
"session_id": session_id,
|
| 259 |
+
"logs_count": len(logs),
|
| 260 |
+
"logs": [
|
| 261 |
+
{
|
| 262 |
+
"id": entry.id,
|
| 263 |
+
"log": entry.log,
|
| 264 |
+
"timestamp": entry.timestamp
|
| 265 |
+
}
|
| 266 |
+
for entry in logs
|
| 267 |
+
],
|
| 268 |
+
"report": report.report if report else "",
|
| 269 |
+
"insights": report.insights if report else "",
|
| 270 |
+
"suggestions": report.suggestions if report else "",
|
| 271 |
+
"state_flow": report.state_flow if report else ""
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
@app.get("/restaurants")
|
| 275 |
def get_restaurants(db: Session = Depends(get_db)):
|
| 276 |
|