Spaces:
Running
Running
axeronis commited on
Commit ·
cf33fb8
1
Parent(s): ddfbf86
debug: add logging to track settings save and load
Browse files- backend/app/api/demo.py +10 -0
backend/app/api/demo.py
CHANGED
|
@@ -56,8 +56,14 @@ async def demo_chat(
|
|
| 56 |
if not tenant:
|
| 57 |
raise HTTPException(status_code=404, detail="Tenant not found")
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
# Build FULL context using memory manager (includes KB, products, settings)
|
| 60 |
tenant_context = await memory_manager.build_tenant_context(session, tenant)
|
|
|
|
| 61 |
|
| 62 |
# Add corrections to context if any
|
| 63 |
corrections_prompt = ""
|
|
@@ -320,9 +326,13 @@ async def confirm_smart_correction(
|
|
| 320 |
|
| 321 |
|
| 322 |
if applied_count > 0:
|
|
|
|
|
|
|
|
|
|
| 323 |
tenant.ai_settings = ai_settings
|
| 324 |
session.add(tenant)
|
| 325 |
await session.commit()
|
|
|
|
| 326 |
|
| 327 |
# Invalidate AI cache
|
| 328 |
await memory_manager.invalidate_memory(session, tenant)
|
|
|
|
| 56 |
if not tenant:
|
| 57 |
raise HTTPException(status_code=404, detail="Tenant not found")
|
| 58 |
|
| 59 |
+
# DEBUG: Log current settings
|
| 60 |
+
ai_settings = tenant.ai_settings or {}
|
| 61 |
+
ai_identity = ai_settings.get("ai_identity", {})
|
| 62 |
+
logger.info(f"🔍 Demo chat - bot_name from DB: {ai_identity.get('bot_name', 'NOT SET')}")
|
| 63 |
+
|
| 64 |
# Build FULL context using memory manager (includes KB, products, settings)
|
| 65 |
tenant_context = await memory_manager.build_tenant_context(session, tenant)
|
| 66 |
+
|
| 67 |
|
| 68 |
# Add corrections to context if any
|
| 69 |
corrections_prompt = ""
|
|
|
|
| 326 |
|
| 327 |
|
| 328 |
if applied_count > 0:
|
| 329 |
+
# DEBUG: Log what we're saving
|
| 330 |
+
logger.info(f"🔧 Saving ai_settings: {ai_settings.get('ai_identity', {})}")
|
| 331 |
+
|
| 332 |
tenant.ai_settings = ai_settings
|
| 333 |
session.add(tenant)
|
| 334 |
await session.commit()
|
| 335 |
+
|
| 336 |
|
| 337 |
# Invalidate AI cache
|
| 338 |
await memory_manager.invalidate_memory(session, tenant)
|