Spaces:
Paused
Paused
Update prompt_builder.py
Browse files- prompt_builder.py +31 -20
prompt_builder.py
CHANGED
|
@@ -260,32 +260,32 @@ def _build_locale_aware_date_prompt(param, date_ctx: Dict, locale_data: Dict, lo
|
|
| 260 |
" IMPORTANT DATE RULES:"
|
| 261 |
]
|
| 262 |
|
| 263 |
-
# Common date expressions
|
| 264 |
if locale_code.startswith("tr"):
|
| 265 |
# Turkish specific
|
| 266 |
prompt_parts.extend([
|
| 267 |
-
f" - 'bugΓΌn' = {date_ctx['today']}",
|
| 268 |
-
f" - 'yarΔ±n' = {date_ctx['tomorrow']}",
|
| 269 |
-
f" - '
|
| 270 |
-
f" - 'bu hafta sonu' = {date_ctx['this_weekend_saturday']} or {date_ctx['this_weekend_sunday']}",
|
| 271 |
-
f" - 'bu cumartesi' = {date_ctx['this_weekend_saturday']}",
|
| 272 |
-
f" - 'bu pazar' = {date_ctx['this_weekend_sunday']}",
|
| 273 |
-
f" - '
|
| 274 |
-
f" - '
|
| 275 |
-
f" - '
|
| 276 |
-
f" - 'X gΓΌn sonra' = add X days to today"
|
| 277 |
])
|
| 278 |
elif locale_code.startswith("en"):
|
| 279 |
# English specific
|
| 280 |
prompt_parts.extend([
|
| 281 |
-
f" - 'today' = {date_ctx['today']}",
|
| 282 |
-
f" - 'tomorrow' = {date_ctx['tomorrow']}",
|
| 283 |
-
f" - 'day after tomorrow' = {date_ctx['day_after_tomorrow']}",
|
| 284 |
-
f" - 'this weekend' = {date_ctx['this_weekend_saturday']} or {date_ctx['this_weekend_sunday']}",
|
| 285 |
-
f" - 'this Saturday' = {date_ctx['this_weekend_saturday']}",
|
| 286 |
-
f" - 'this Sunday' = {date_ctx['this_weekend_sunday']}",
|
| 287 |
-
f" - 'next week' = add 7 days to current date",
|
| 288 |
-
f" - 'in X days' = add X days to today"
|
|
|
|
| 289 |
])
|
| 290 |
# DiΔer diller iΓ§in de eklenebilir
|
| 291 |
|
|
@@ -299,6 +299,12 @@ def _build_locale_aware_date_prompt(param, date_ctx: Dict, locale_data: Dict, lo
|
|
| 299 |
# Date format hint
|
| 300 |
date_format = locale_data.get("date_format", "YYYY-MM-DD")
|
| 301 |
prompt_parts.append(f" - Expected date format: YYYY-MM-DD (convert from {date_format})")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
|
| 303 |
return "\n".join(prompt_parts)
|
| 304 |
|
|
@@ -308,9 +314,14 @@ def build_smart_parameter_question_prompt(
|
|
| 308 |
missing_params: List[str],
|
| 309 |
session, # Session object
|
| 310 |
project_language: str = "Turkish"
|
|
|
|
| 311 |
) -> str:
|
| 312 |
"""AkΔ±llΔ± parametre sorusu ΓΌretmek iΓ§in prompt oluΕtur"""
|
| 313 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
# Config'den template'i al
|
| 315 |
template = collection_config.collection_prompt
|
| 316 |
|
|
@@ -346,7 +357,7 @@ def build_smart_parameter_question_prompt(
|
|
| 346 |
prompt = prompt.replace("{{max_params}}", str(params_to_ask_count))
|
| 347 |
prompt = prompt.replace("{{project_language}}", project_language)
|
| 348 |
|
| 349 |
-
log(f"π Smart parameter question prompt built for {params_to_ask_count} params")
|
| 350 |
return prompt
|
| 351 |
|
| 352 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 260 |
" IMPORTANT DATE RULES:"
|
| 261 |
]
|
| 262 |
|
| 263 |
+
# Common date expressions based on locale
|
| 264 |
if locale_code.startswith("tr"):
|
| 265 |
# Turkish specific
|
| 266 |
prompt_parts.extend([
|
| 267 |
+
f" - '{date_expressions.get('today', 'bugΓΌn')}' = {date_ctx['today']}",
|
| 268 |
+
f" - '{date_expressions.get('tomorrow', 'yarΔ±n')}' = {date_ctx['tomorrow']}",
|
| 269 |
+
f" - '{' or '.join(date_expressions.get('day_after_tomorrow', ['ΓΆbΓΌr gΓΌn']))}' = {date_ctx['day_after_tomorrow']}",
|
| 270 |
+
f" - '{date_expressions.get('this_weekend', 'bu hafta sonu')}' = {date_ctx['this_weekend_saturday']} or {date_ctx['this_weekend_sunday']}",
|
| 271 |
+
f" - '{date_expressions.get('this_saturday', 'bu cumartesi')}' = {date_ctx['this_weekend_saturday']}",
|
| 272 |
+
f" - '{date_expressions.get('this_sunday', 'bu pazar')}' = {date_ctx['this_weekend_sunday']}",
|
| 273 |
+
f" - '{' or '.join(date_expressions.get('next_week', ['gelecek hafta', 'haftaya']))}' = add 7 days to current date",
|
| 274 |
+
f" - 'X gΓΌn sonra' = add X days to today",
|
| 275 |
+
f" - 'X gΓΌn ΓΆnce' = subtract X days from today"
|
|
|
|
| 276 |
])
|
| 277 |
elif locale_code.startswith("en"):
|
| 278 |
# English specific
|
| 279 |
prompt_parts.extend([
|
| 280 |
+
f" - '{date_expressions.get('today', 'today')}' = {date_ctx['today']}",
|
| 281 |
+
f" - '{date_expressions.get('tomorrow', 'tomorrow')}' = {date_ctx['tomorrow']}",
|
| 282 |
+
f" - '{' or '.join(date_expressions.get('day_after_tomorrow', ['day after tomorrow']))}' = {date_ctx['day_after_tomorrow']}",
|
| 283 |
+
f" - '{date_expressions.get('this_weekend', 'this weekend')}' = {date_ctx['this_weekend_saturday']} or {date_ctx['this_weekend_sunday']}",
|
| 284 |
+
f" - '{date_expressions.get('this_saturday', 'this Saturday')}' = {date_ctx['this_weekend_saturday']}",
|
| 285 |
+
f" - '{date_expressions.get('this_sunday', 'this Sunday')}' = {date_ctx['this_weekend_sunday']}",
|
| 286 |
+
f" - '{date_expressions.get('next_week', 'next week')}' = add 7 days to current date",
|
| 287 |
+
f" - 'in X days' = add X days to today",
|
| 288 |
+
f" - 'X days ago' = subtract X days from today"
|
| 289 |
])
|
| 290 |
# DiΔer diller iΓ§in de eklenebilir
|
| 291 |
|
|
|
|
| 299 |
# Date format hint
|
| 300 |
date_format = locale_data.get("date_format", "YYYY-MM-DD")
|
| 301 |
prompt_parts.append(f" - Expected date format: YYYY-MM-DD (convert from {date_format})")
|
| 302 |
+
|
| 303 |
+
# Example based on locale
|
| 304 |
+
if locale_code.startswith("tr"):
|
| 305 |
+
prompt_parts.append(f" - Example: '10 Temmuz' = {date_ctx['today_year']}-07-10")
|
| 306 |
+
elif locale_code.startswith("en"):
|
| 307 |
+
prompt_parts.append(f" - Example: 'July 10' = {date_ctx['today_year']}-07-10")
|
| 308 |
|
| 309 |
return "\n".join(prompt_parts)
|
| 310 |
|
|
|
|
| 314 |
missing_params: List[str],
|
| 315 |
session, # Session object
|
| 316 |
project_language: str = "Turkish"
|
| 317 |
+
locale_code: str = None
|
| 318 |
) -> str:
|
| 319 |
"""AkΔ±llΔ± parametre sorusu ΓΌretmek iΓ§in prompt oluΕtur"""
|
| 320 |
|
| 321 |
+
# Use intent's locale if not specified
|
| 322 |
+
if not locale_code:
|
| 323 |
+
locale_code = getattr(intent_config, 'locale', 'tr-TR')
|
| 324 |
+
|
| 325 |
# Config'den template'i al
|
| 326 |
template = collection_config.collection_prompt
|
| 327 |
|
|
|
|
| 357 |
prompt = prompt.replace("{{max_params}}", str(params_to_ask_count))
|
| 358 |
prompt = prompt.replace("{{project_language}}", project_language)
|
| 359 |
|
| 360 |
+
log(f"π Smart parameter question prompt built for {params_to_ask_count} params in {locale_code}")
|
| 361 |
return prompt
|
| 362 |
|
| 363 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|