Spaces:
Building
Building
Update prompt_builder.py
Browse files- prompt_builder.py +28 -5
prompt_builder.py
CHANGED
@@ -41,7 +41,8 @@ def _get_date_context() -> Dict[str, str]:
|
|
41 |
def build_intent_prompt(general_prompt: str,
|
42 |
conversation: List[Dict[str, str]],
|
43 |
user_input: str,
|
44 |
-
intents: List
|
|
|
45 |
|
46 |
# Get internal prompt from config
|
47 |
internal_prompt = cfg.global_config.internal_prompt or ""
|
@@ -50,12 +51,34 @@ def build_intent_prompt(general_prompt: str,
|
|
50 |
intent_names = [it.name for it in intents]
|
51 |
intent_captions = [it.caption or it.name for it in intents]
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
# Replace placeholders in internal prompt
|
54 |
if internal_prompt:
|
55 |
-
|
56 |
-
|
57 |
-
internal_prompt = internal_prompt.replace("<
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
# === INTENT INDEX ===
|
60 |
lines = ["### INTENT INDEX ###"]
|
61 |
for it in intents:
|
|
|
41 |
def build_intent_prompt(general_prompt: str,
|
42 |
conversation: List[Dict[str, str]],
|
43 |
user_input: str,
|
44 |
+
intents: List,
|
45 |
+
project_name: str = None) -> str: # project_name parametresi ekle
|
46 |
|
47 |
# Get internal prompt from config
|
48 |
internal_prompt = cfg.global_config.internal_prompt or ""
|
|
|
51 |
intent_names = [it.name for it in intents]
|
52 |
intent_captions = [it.caption or it.name for it in intents]
|
53 |
|
54 |
+
# Get project language
|
55 |
+
project_language = "Turkish" # Default
|
56 |
+
if project_name:
|
57 |
+
project = next((p for p in cfg.projects if p.name == project_name), None)
|
58 |
+
if project:
|
59 |
+
# Language code'u language name'e çevir
|
60 |
+
lang_map = {
|
61 |
+
"tr": "Turkish",
|
62 |
+
"en": "English",
|
63 |
+
"de": "German",
|
64 |
+
"fr": "French",
|
65 |
+
"es": "Spanish"
|
66 |
+
}
|
67 |
+
project_language = lang_map.get(project.default_language, "Turkish")
|
68 |
+
|
69 |
# Replace placeholders in internal prompt
|
70 |
if internal_prompt:
|
71 |
+
# Intent names - tırnak içinde ve virgülle ayrılmış
|
72 |
+
intent_names_str = ', '.join([f'"{name}"' for name in intent_names])
|
73 |
+
internal_prompt = internal_prompt.replace("<intent names>", intent_names_str)
|
74 |
+
|
75 |
+
# Intent captions - tırnak içinde ve virgülle ayrılmış
|
76 |
+
intent_captions_str = ', '.join([f'"{caption}"' for caption in intent_captions])
|
77 |
+
internal_prompt = internal_prompt.replace("<intent captions>", intent_captions_str)
|
78 |
+
|
79 |
+
# Project language
|
80 |
+
internal_prompt = internal_prompt.replace("<project language>", project_language)
|
81 |
+
|
82 |
# === INTENT INDEX ===
|
83 |
lines = ["### INTENT INDEX ###"]
|
84 |
for it in intents:
|