Spaces:
Building
Building
Update prompt_builder.py
Browse files- prompt_builder.py +19 -3
prompt_builder.py
CHANGED
@@ -42,6 +42,20 @@ def build_intent_prompt(general_prompt: str,
|
|
42 |
conversation: List[Dict[str, str]],
|
43 |
user_input: str,
|
44 |
intents: List) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
# === INTENT INDEX ===
|
46 |
lines = ["### INTENT INDEX ###"]
|
47 |
for it in intents:
|
@@ -61,16 +75,18 @@ def build_intent_prompt(general_prompt: str,
|
|
61 |
f"{m['role'].upper()}: {m['content']}" for m in conversation[-10:]
|
62 |
)
|
63 |
|
|
|
|
|
|
|
64 |
prompt = (
|
65 |
-
f"{
|
66 |
f"{intent_index}\n\n"
|
67 |
f"Conversation so far:\n{history_block}\n\n"
|
68 |
f"USER: {user_input.strip()}"
|
69 |
)
|
70 |
-
log("β
Intent prompt built (
|
71 |
return prompt
|
72 |
|
73 |
-
|
74 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
75 |
# PARAMETER PROMPT - Improved version
|
76 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
42 |
conversation: List[Dict[str, str]],
|
43 |
user_input: str,
|
44 |
intents: List) -> str:
|
45 |
+
|
46 |
+
# Get internal prompt from config
|
47 |
+
internal_prompt = cfg.global_config.internal_prompt or ""
|
48 |
+
|
49 |
+
# Extract intent names and captions
|
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 |
+
internal_prompt = internal_prompt.replace("<intent names>", ", ".join(intent_names))
|
56 |
+
internal_prompt = internal_prompt.replace("<intent captions>", ", ".join(intent_captions))
|
57 |
+
internal_prompt = internal_prompt.replace("<project language>", "Turkish") # TODO: Make this configurable
|
58 |
+
|
59 |
# === INTENT INDEX ===
|
60 |
lines = ["### INTENT INDEX ###"]
|
61 |
for it in intents:
|
|
|
75 |
f"{m['role'].upper()}: {m['content']}" for m in conversation[-10:]
|
76 |
)
|
77 |
|
78 |
+
# Combine prompts
|
79 |
+
combined_prompt = internal_prompt + "\n\n" + general_prompt if internal_prompt else general_prompt
|
80 |
+
|
81 |
prompt = (
|
82 |
+
f"{combined_prompt}\n\n"
|
83 |
f"{intent_index}\n\n"
|
84 |
f"Conversation so far:\n{history_block}\n\n"
|
85 |
f"USER: {user_input.strip()}"
|
86 |
)
|
87 |
+
log("β
Intent prompt built (with internal prompt)")
|
88 |
return prompt
|
89 |
|
|
|
90 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
91 |
# PARAMETER PROMPT - Improved version
|
92 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|