Spaces:
Running

axeronis commited on
Commit
597f927
·
1 Parent(s): 25a2e3d

fix: smart-correct reads ai_identity from correct tenant field

Browse files
Files changed (1) hide show
  1. backend/app/api/demo.py +7 -7
backend/app/api/demo.py CHANGED
@@ -510,9 +510,9 @@ async def smart_correct(
510
  if not tenant:
511
  raise HTTPException(status_code=404, detail="Tenant not found")
512
 
513
- # Get FULL settings context
514
  ai_settings = tenant.ai_settings or {}
515
- ai_identity = ai_settings.get("ai_identity", {})
516
  playbook = ai_settings.get("playbook", {})
517
 
518
  # Fetch Products (catalog)
@@ -544,7 +544,7 @@ async def smart_correct(
544
  if not services_text:
545
  services_text = " (нет услуг)"
546
 
547
- # Build comprehensive context
548
  current_config = f"""
549
  === ТЕКУЩИЕ НАСТРОЙКИ AI (tenant: {tenant.id}) ===
550
 
@@ -554,8 +554,8 @@ async def smart_correct(
554
  - Пол: {ai_identity.get('bot_gender', 'female')}
555
 
556
  [ТОН И СТИЛЬ]
557
- - Тон общения: {ai_settings.get('tone_of_voice', 'Professional')}
558
- - Методология продаж: {ai_settings.get('sales_methodology', 'Consultative')}
559
 
560
  [КАТАЛОГ ТОВАРОВ]
561
  {products_text}
@@ -564,10 +564,10 @@ async def smart_correct(
564
  {services_text}
565
 
566
  [ЗАПРЕТЫ]
567
- - Запрещённые слова: {ai_settings.get('banned_words', [])}
568
 
569
  [ИНСТРУКЦИИ]
570
- {ai_settings.get('custom_instructions', '(пусто)')[:500]}
571
 
572
  [PLAYBOOK - ЭТАПЫ ВОРОНКИ]
573
  {json.dumps(playbook.get('stages', []), ensure_ascii=False, indent=2)[:500] if playbook.get('stages') else '(нет этапов)'}
 
510
  if not tenant:
511
  raise HTTPException(status_code=404, detail="Tenant not found")
512
 
513
+ # Get FULL settings context - READ FROM CORRECT FIELDS
514
  ai_settings = tenant.ai_settings or {}
515
+ ai_identity = tenant.ai_identity or {} # This is the correct field!
516
  playbook = ai_settings.get("playbook", {})
517
 
518
  # Fetch Products (catalog)
 
544
  if not services_text:
545
  services_text = " (нет услуг)"
546
 
547
+ # Build comprehensive context - USE CORRECT TENANT FIELDS
548
  current_config = f"""
549
  === ТЕКУЩИЕ НАСТРОЙКИ AI (tenant: {tenant.id}) ===
550
 
 
554
  - Пол: {ai_identity.get('bot_gender', 'female')}
555
 
556
  [ТОН И СТИЛЬ]
557
+ - Тон общения: {tenant.tone_of_voice or 'Professional'}
558
+ - Методология продаж: {tenant.sales_methodology or 'Consultative'}
559
 
560
  [КАТАЛОГ ТОВАРОВ]
561
  {products_text}
 
564
  {services_text}
565
 
566
  [ЗАПРЕТЫ]
567
+ - Запрещённые слова: {tenant.banned_words or []}
568
 
569
  [ИНСТРУКЦИИ]
570
+ {(tenant.custom_instructions or '(пусто)')[:500]}
571
 
572
  [PLAYBOOK - ЭТАПЫ ВОРОНКИ]
573
  {json.dumps(playbook.get('stages', []), ensure_ascii=False, indent=2)[:500] if playbook.get('stages') else '(нет этапов)'}