Spaces:
Building
Building
""" | |
Flare – Prompt Builder | |
~~~~~~~~~~~~~~~~~~~~~~ | |
Merkezi noktadan, şablon + placeholder birleştirir. | |
""" | |
from typing import List, Dict | |
from config_provider import IntentConfig, ParameterConfig | |
# ========= Helper =========================================================== | |
def _join(*parts: List[str]) -> str: | |
"""Boş stringleri atarak satır satır birleştir.""" | |
return "\n\n".join(p for p in parts if p) | |
# ========= Public Builders ================================================== | |
def build_intent_prompt(general_prompt: str, | |
intent: IntentConfig) -> str: | |
return _join(general_prompt, intent.detection_prompt) | |
def build_param_prompt(intent_prompt_base: str, | |
missing_params: List[ParameterConfig]) -> str: | |
pieces = [intent_prompt_base] | |
pieces += [p.extraction_prompt for p in missing_params] | |
return _join(*pieces) | |
def build_api_humanize_prompt(intent_prompt_base: str, | |
api_response_prompt: str, | |
api_json: str) -> str: | |
return _join(intent_prompt_base, | |
api_response_prompt.replace("{{api_response}}", api_json)) | |