Spaces:
Running
Running
Update chat_handler.py
Browse files- chat_handler.py +15 -2
chat_handler.py
CHANGED
@@ -295,6 +295,13 @@ async def _handle_parameter_followup(session: Session, user_input: str, version)
|
|
295 |
log("⚠️ No last intent in session")
|
296 |
session.reset_flow()
|
297 |
return "Üzgünüm, hangi işlem için bilgi istediğimi unuttum. Baştan başlayalım."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
|
299 |
# Get intent config
|
300 |
intent_config = next((i for i in version.intents if i.name == session.last_intent), None)
|
@@ -307,7 +314,7 @@ async def _handle_parameter_followup(session: Session, user_input: str, version)
|
|
307 |
missing = session.awaiting_parameters
|
308 |
log(f"🔍 Trying to extract missing params: {missing}")
|
309 |
|
310 |
-
prompt = build_parameter_prompt(intent_config, missing, user_input, session.chat_history)
|
311 |
raw = await spark_generate(session, prompt, user_input)
|
312 |
|
313 |
# Try parsing with or without #PARAMETERS: prefix
|
@@ -362,6 +369,12 @@ async def _handle_parameter_followup(session: Session, user_input: str, version)
|
|
362 |
# ───────────────────────── PARAMETER HANDLING ───────────────────────── #
|
363 |
async def _extract_parameters(session: Session, intent_config, user_input: str) -> str:
|
364 |
"""Extract parameters from user input with smart question generation"""
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
|
366 |
# Yeni intent için parametre takibini sıfırla
|
367 |
if session.parameter_ask_rounds == 0:
|
@@ -376,7 +389,7 @@ async def _extract_parameters(session: Session, intent_config, user_input: str)
|
|
376 |
return await _execute_api_call(session, intent_config)
|
377 |
|
378 |
# Build parameter extraction prompt
|
379 |
-
prompt = build_parameter_prompt(intent_config, missing, user_input, session.chat_history)
|
380 |
raw = await spark_generate(session, prompt, user_input)
|
381 |
|
382 |
# Try processing with flexible parsing
|
|
|
295 |
log("⚠️ No last intent in session")
|
296 |
session.reset_flow()
|
297 |
return "Üzgünüm, hangi işlem için bilgi istediğimi unuttum. Baştan başlayalım."
|
298 |
+
|
299 |
+
# Get version config from session
|
300 |
+
version = session.get_version_config()
|
301 |
+
if not version:
|
302 |
+
log("❌ Version config not found")
|
303 |
+
session.reset_flow()
|
304 |
+
return "Bir hata oluştu. Lütfen tekrar deneyin."
|
305 |
|
306 |
# Get intent config
|
307 |
intent_config = next((i for i in version.intents if i.name == session.last_intent), None)
|
|
|
314 |
missing = session.awaiting_parameters
|
315 |
log(f"🔍 Trying to extract missing params: {missing}")
|
316 |
|
317 |
+
prompt = build_parameter_prompt(intent_config, missing, user_input, session.chat_history, intent_config.locale)
|
318 |
raw = await spark_generate(session, prompt, user_input)
|
319 |
|
320 |
# Try parsing with or without #PARAMETERS: prefix
|
|
|
369 |
# ───────────────────────── PARAMETER HANDLING ───────────────────────── #
|
370 |
async def _extract_parameters(session: Session, intent_config, user_input: str) -> str:
|
371 |
"""Extract parameters from user input with smart question generation"""
|
372 |
+
|
373 |
+
# Version config'i al
|
374 |
+
version = session.get_version_config()
|
375 |
+
if not version:
|
376 |
+
log("❌ Version config not found")
|
377 |
+
return "Bir hata oluştu. Lütfen tekrar deneyin."
|
378 |
|
379 |
# Yeni intent için parametre takibini sıfırla
|
380 |
if session.parameter_ask_rounds == 0:
|
|
|
389 |
return await _execute_api_call(session, intent_config)
|
390 |
|
391 |
# Build parameter extraction prompt
|
392 |
+
prompt = build_parameter_prompt(intent_config, missing, user_input, session.chat_history, intent_config.locale)
|
393 |
raw = await spark_generate(session, prompt, user_input)
|
394 |
|
395 |
# Try processing with flexible parsing
|