Spaces:
Running
Running
Update prompt_builder.py
Browse files- prompt_builder.py +17 -26
prompt_builder.py
CHANGED
@@ -1,34 +1,25 @@
|
|
1 |
"""
|
2 |
-
Flare – Prompt Builder
|
3 |
-
|
4 |
-
|
|
|
5 |
"""
|
6 |
|
7 |
-
from
|
8 |
-
|
9 |
from config_provider import IntentConfig, ParameterConfig
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
"
|
14 |
-
return "\n\n".join(p for p in parts if p)
|
15 |
-
|
16 |
-
|
17 |
-
# ========= Public Builders ==================================================
|
18 |
-
def build_intent_prompt(general_prompt: str,
|
19 |
-
intent: IntentConfig) -> str:
|
20 |
-
return _join(general_prompt, intent.detection_prompt)
|
21 |
-
|
22 |
|
23 |
-
def
|
24 |
-
|
25 |
-
|
26 |
-
pieces += [p.extraction_prompt for p in missing_params]
|
27 |
-
return _join(*pieces)
|
28 |
|
|
|
|
|
|
|
29 |
|
30 |
-
def build_api_humanize_prompt(
|
31 |
-
|
32 |
-
api_json: str) -> str:
|
33 |
-
return _join(intent_prompt_base,
|
34 |
-
api_response_prompt.replace("{{api_response}}", api_json))
|
|
|
1 |
"""
|
2 |
+
Flare – Prompt Builder helpers
|
3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
4 |
+
Karmaşık şablonlar Spark tarafında derinleştirilecek ama
|
5 |
+
ilk versiyon için basit string concat yeterli.
|
6 |
"""
|
7 |
|
8 |
+
from __future__ import annotations
|
9 |
+
from typing import List
|
10 |
from config_provider import IntentConfig, ParameterConfig
|
11 |
|
12 |
+
def build_detection_prompt(general: str, intent: IntentConfig) -> str:
|
13 |
+
examples = "\n".join(f"- {e}" for e in intent.examples)
|
14 |
+
return f"{general}\nÖrnekler:\n{examples}\nBu mesaj yukarıdaki niyetlerden hangisine ait?"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
def build_param_extract_prompt(general: str, intent: IntentConfig, missing: List[ParameterConfig]) -> str:
|
17 |
+
names = ", ".join(p.name for p in missing)
|
18 |
+
return f"{general}\nIntent: {intent.name}\nEksik parametreleri çıkar: {names}"
|
|
|
|
|
19 |
|
20 |
+
def build_missing_param_prompt(missing: List[str]) -> str:
|
21 |
+
list_ = ", ".join(missing)
|
22 |
+
return f"{list_} değer(ler)ine ihtiyacım var, paylaşır mısın?"
|
23 |
|
24 |
+
def build_api_humanize_prompt(general: str, response_prompt: str, api_json: str) -> str:
|
25 |
+
return f"{general}\n{response_prompt}\nJSON:\n{api_json}"
|
|
|
|
|
|