ciyidogan commited on
Commit
b232328
·
verified ·
1 Parent(s): d8516ac

Update prompt_builder.py

Browse files
Files changed (1) hide show
  1. prompt_builder.py +17 -26
prompt_builder.py CHANGED
@@ -1,34 +1,25 @@
1
  """
2
- Flare – Prompt Builder
3
- ~~~~~~~~~~~~~~~~~~~~~~
4
- Merkezi noktadan, şablon + placeholder birleştirir.
 
5
  """
6
 
7
- from typing import List, Dict
8
-
9
  from config_provider import IntentConfig, ParameterConfig
10
 
11
- # ========= Helper ===========================================================
12
- def _join(*parts: List[str]) -> str:
13
- """Boş stringleri atarak satır satır birleştir."""
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 build_param_prompt(intent_prompt_base: str,
24
- missing_params: List[ParameterConfig]) -> str:
25
- pieces = [intent_prompt_base]
26
- pieces += [p.extraction_prompt for p in missing_params]
27
- return _join(*pieces)
28
 
 
 
 
29
 
30
- def build_api_humanize_prompt(intent_prompt_base: str,
31
- api_response_prompt: str,
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}"