ciyidogan commited on
Commit
38465a9
·
verified ·
1 Parent(s): ac5df61

Update chat_handler.py

Browse files
Files changed (1) hide show
  1. chat_handler.py +33 -11
chat_handler.py CHANGED
@@ -459,13 +459,18 @@ async def _generate_smart_parameter_question(
459
  log(f"📋 Params to ask in this round: {params_to_ask}")
460
 
461
  # Proje dilini belirle
462
- project_language = "Turkish" # Default
463
- if hasattr(version, 'project') and hasattr(version.project, 'default_language'):
464
- lang_map = {
465
- "tr": "Turkish", "en": "English", "de": "German",
466
- "fr": "French", "es": "Spanish"
467
- }
468
- project_language = lang_map.get(version.project.default_language, "Turkish")
 
 
 
 
 
469
 
470
  # Prompt oluştur
471
  prompt = build_smart_parameter_question_prompt(
@@ -473,7 +478,8 @@ async def _generate_smart_parameter_question(
473
  intent_config,
474
  params_to_ask, # Sadece bu turda sorulacak parametreler
475
  session,
476
- project_language
 
477
  )
478
 
479
  # LLM'den soru üret
@@ -486,14 +492,30 @@ async def _generate_smart_parameter_question(
486
  param = params_to_ask[0]
487
  param_config = next(p for p in intent_config.parameters if p.name == param)
488
 
 
 
 
 
489
  # Parametrenin kaç kez sorulduğuna göre farklı fallback
490
  ask_count = session.get_parameter_ask_count(param)
 
 
 
 
 
 
 
 
 
491
  if ask_count == 0:
492
- return f"{param_config.caption} bilgisini alabilir miyim?"
 
493
  elif ask_count == 1:
494
- return f"Lütfen {param_config.caption.lower()} bilgisini paylaşır mısınız?"
 
495
  else:
496
- return f"Devam edebilmem için {param_config.caption.lower()} bilgisine ihtiyacım var."
 
497
 
498
  # Response'u temizle
499
  clean_response = response.strip()
 
459
  log(f"📋 Params to ask in this round: {params_to_ask}")
460
 
461
  # Proje dilini belirle
462
+ project = next((p for p in cfg.projects if p.name == session.project_name), None)
463
+ if project and hasattr(project, 'default_language'):
464
+ # default_language locale code'dur (tr-TR, en-US vb.)
465
+ project_locale_code = project.default_language
466
+ # Locale'den dil adını al
467
+ locale_data = LocaleManager.get_locale(project_locale_code)
468
+ project_language = locale_data.get('name', 'Turkish')
469
+ else:
470
+ project_locale_code = 'tr-TR'
471
+ project_language = 'Turkish'
472
+
473
+ log(f"📋 Project locale: {project_locale_code}, language: {project_language}")
474
 
475
  # Prompt oluştur
476
  prompt = build_smart_parameter_question_prompt(
 
478
  intent_config,
479
  params_to_ask, # Sadece bu turda sorulacak parametreler
480
  session,
481
+ project_language,
482
+ intent_config.locale # Locale code'u da gönder
483
  )
484
 
485
  # LLM'den soru üret
 
492
  param = params_to_ask[0]
493
  param_config = next(p for p in intent_config.parameters if p.name == param)
494
 
495
+ # Intent'in locale'ini kullan
496
+ intent_locale_code = getattr(intent_config, 'locale', project_locale_code)
497
+ locale_data = LocaleManager.get_locale(intent_locale_code)
498
+
499
  # Parametrenin kaç kez sorulduğuna göre farklı fallback
500
  ask_count = session.get_parameter_ask_count(param)
501
+ fallback_questions = locale_data.get('parameter_collection', {}).get('fallback_questions', {})
502
+
503
+ # Caption'ı küçük harfe çevir (Türkçe için özel)
504
+ caption = param_config.caption
505
+ if intent_locale_code.startswith('tr'):
506
+ caption_lower = caption.lower()
507
+ else:
508
+ caption_lower = caption
509
+
510
  if ask_count == 0:
511
+ template = fallback_questions.get('first_ask', '{caption} bilgisini alabilir miyim?')
512
+ return template.replace('{caption}', caption)
513
  elif ask_count == 1:
514
+ template = fallback_questions.get('second_ask', 'Lütfen {caption} bilgisini paylaşır mısınız?')
515
+ return template.replace('{caption}', caption_lower)
516
  else:
517
+ template = fallback_questions.get('third_ask', 'Devam edebilmem için {caption} bilgisine ihtiyacım var.')
518
+ return template.replace('{caption}', caption_lower)
519
 
520
  # Response'u temizle
521
  clean_response = response.strip()