Spaces:
Running
Running
axeronis commited on
Commit ·
ddfbf86
1
Parent(s): af3e859
fix: add full_value to smart-correct pending_changes for correct DB save
Browse files- backend/app/api/demo.py +9 -0
backend/app/api/demo.py
CHANGED
|
@@ -313,6 +313,11 @@ async def confirm_smart_correction(
|
|
| 313 |
else:
|
| 314 |
ai_settings["custom_instructions"] = full_value
|
| 315 |
applied_count += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 316 |
|
| 317 |
if applied_count > 0:
|
| 318 |
tenant.ai_settings = ai_settings
|
|
@@ -556,8 +561,10 @@ async def smart_correct(
|
|
| 556 |
"section": "AI Мозг → Глобальный промпт",
|
| 557 |
"old": "(добавлено новое)",
|
| 558 |
"new": value[:100] + ("..." if len(value) > 100 else ""),
|
|
|
|
| 559 |
"reason": reason
|
| 560 |
})
|
|
|
|
| 561 |
|
| 562 |
elif action == "set_tone" and value:
|
| 563 |
valid_tones = ["Professional", "Friendly", "Empathetic", "Bold"]
|
|
@@ -587,8 +594,10 @@ async def smart_correct(
|
|
| 587 |
"section": "AI Мозг → Таргетинг",
|
| 588 |
"old": old_value[:50] + "..." if old_value else "(пусто)",
|
| 589 |
"new": value[:50] + "...",
|
|
|
|
| 590 |
"reason": reason
|
| 591 |
})
|
|
|
|
| 592 |
|
| 593 |
if applied_changes:
|
| 594 |
# DON'T save to database - return as pending for confirmation
|
|
|
|
| 313 |
else:
|
| 314 |
ai_settings["custom_instructions"] = full_value
|
| 315 |
applied_count += 1
|
| 316 |
+
elif "Идеальный клиент" in field or "клиент" in field.lower():
|
| 317 |
+
full_value = change.get("full_value", new_value.replace("...", ""))
|
| 318 |
+
ai_settings["ideal_customer_profile"] = full_value
|
| 319 |
+
applied_count += 1
|
| 320 |
+
|
| 321 |
|
| 322 |
if applied_count > 0:
|
| 323 |
tenant.ai_settings = ai_settings
|
|
|
|
| 561 |
"section": "AI Мозг → Глобальный промпт",
|
| 562 |
"old": "(добавлено новое)",
|
| 563 |
"new": value[:100] + ("..." if len(value) > 100 else ""),
|
| 564 |
+
"full_value": value, # Full value for confirm endpoint
|
| 565 |
"reason": reason
|
| 566 |
})
|
| 567 |
+
|
| 568 |
|
| 569 |
elif action == "set_tone" and value:
|
| 570 |
valid_tones = ["Professional", "Friendly", "Empathetic", "Bold"]
|
|
|
|
| 594 |
"section": "AI Мозг → Таргетинг",
|
| 595 |
"old": old_value[:50] + "..." if old_value else "(пусто)",
|
| 596 |
"new": value[:50] + "...",
|
| 597 |
+
"full_value": value, # Full value for confirm endpoint
|
| 598 |
"reason": reason
|
| 599 |
})
|
| 600 |
+
|
| 601 |
|
| 602 |
if applied_changes:
|
| 603 |
# DON'T save to database - return as pending for confirmation
|