ciyidogan commited on
Commit
6506311
Β·
verified Β·
1 Parent(s): a7f165e

Update prompt_builder.py

Browse files
Files changed (1) hide show
  1. prompt_builder.py +13 -11
prompt_builder.py CHANGED
@@ -47,9 +47,8 @@ def build_intent_prompt(general_prompt: str,
47
  # PARAMETER PROMPT (değişmedi)
48
  # ─────────────────────────────────────────────────────────────────────────────
49
  _FMT = (
50
- "Return exactly ONE line in the format:\n"
51
- "#PARAMETERS:{"
52
- "\"extracted\":[{\"name\":\"<param>\",\"value\":\"<val>\"},...],"
53
  "\"missing\":[\"<param>\",...]}"
54
  )
55
 
@@ -57,24 +56,27 @@ def build_parameter_prompt(intent_cfg,
57
  missing_params: List[str],
58
  user_input: str,
59
  conversation: List[Dict[str, str]]) -> str:
 
60
  parts: List[str] = [
61
- "You will extract ONLY the parameters listed below.",
62
- "If a parameter cannot be found OR fails validation, keep it in the "
63
- "\"missing\" list. Never guess values."
64
  ]
 
65
  for p in intent_cfg.parameters:
66
  if p.name in missing_params:
67
- parts.append(f"* {p.name}: {p.extraction_prompt}")
 
68
  parts.append(_FMT)
69
-
70
  history_block = "\n".join(
71
  f"{m['role'].upper()}: {m['content']}" for m in conversation[-10:]
72
  )
73
-
74
  prompt = (
75
- "\n".join(parts) +
76
  "\n\nConversation so far:\n" + history_block +
77
  "\n\nUSER: " + user_input.strip()
78
  )
79
- log("βœ… Parameter prompt built")
80
  return prompt
 
47
  # PARAMETER PROMPT (değişmedi)
48
  # ─────────────────────────────────────────────────────────────────────────────
49
  _FMT = (
50
+ "Return ONLY the JSON object in the EXACT format below with no extra text:\n"
51
+ "{\"extracted\":[{\"name\":\"<param>\",\"value\":\"<val>\"},...],"
 
52
  "\"missing\":[\"<param>\",...]}"
53
  )
54
 
 
56
  missing_params: List[str],
57
  user_input: str,
58
  conversation: List[Dict[str, str]]) -> str:
59
+
60
  parts: List[str] = [
61
+ "Extract ONLY the parameters listed below from the user's message.",
62
+ "If a parameter cannot be found, is invalid, or wasn't provided, keep it in the \"missing\" list.",
63
+ "Never guess or make up values. Only extract values explicitly given by the user."
64
  ]
65
+
66
  for p in intent_cfg.parameters:
67
  if p.name in missing_params:
68
+ parts.append(f"β€’ {p.name}: {p.extraction_prompt}")
69
+
70
  parts.append(_FMT)
71
+
72
  history_block = "\n".join(
73
  f"{m['role'].upper()}: {m['content']}" for m in conversation[-10:]
74
  )
75
+
76
  prompt = (
77
+ "\n".join(parts) +
78
  "\n\nConversation so far:\n" + history_block +
79
  "\n\nUSER: " + user_input.strip()
80
  )
81
+
82
  return prompt