Nelly-43 commited on
Commit
05035b2
·
verified ·
1 Parent(s): 60f096b

Update src/prompts.py

Browse files
Files changed (1) hide show
  1. src/prompts.py +20 -1
src/prompts.py CHANGED
@@ -266,6 +266,9 @@ INIT_PROMPT_TEMPLATE = """\
266
  You are a query-routing classifier for a {domain} research chatbot.
267
  Your task is to read the user's query and extract the country, value chain, and investment area in which the PERI analysis is to be run. Return ONLY valid JSON.
268
  Place all output values in a list and if not specified in the user query return None
 
 
 
269
  Output:
270
  {{
271
  "country": ["Malawi"] or None,
@@ -275,6 +278,21 @@ Output:
275
  USER'S QUESTION: {query}
276
  Return only the JSON object. Do not provide explanations, markdown, or additional text.
277
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
  def build_stata_prompt(query:str,
279
  subcmd:str,
280
  dofx:str,
@@ -292,7 +310,8 @@ def build_categorizer_prompt(query:str,
292
  ):
293
  return CATEGORIZER_PROMPT_TEMPLATE.format(
294
  domain=domain,
295
- query=query
 
296
  )
297
 
298
  def build_init_prompt(query:str,
 
266
  You are a query-routing classifier for a {domain} research chatbot.
267
  Your task is to read the user's query and extract the country, value chain, and investment area in which the PERI analysis is to be run. Return ONLY valid JSON.
268
  Place all output values in a list and if not specified in the user query return None
269
+
270
+ Match labels included in the user queries with options included in this items list:
271
+ {approved_options}
272
  Output:
273
  {{
274
  "country": ["Malawi"] or None,
 
278
  USER'S QUESTION: {query}
279
  Return only the JSON object. Do not provide explanations, markdown, or additional text.
280
  """
281
+ def dict_to_string(d, indent=0):
282
+ result = ""
283
+ for key, value in d.items():
284
+ # Add indentation based on nesting depth
285
+ spacing = " " * indent
286
+
287
+ if isinstance(value, dict):
288
+ result += f"{spacing}{key}:\n"
289
+ # Recursively call the function for nested dictionaries
290
+ result += dict_to_string(value, indent + 1)
291
+ else:
292
+ result += f"{spacing}{key}: {value}\n"
293
+
294
+ return result
295
+
296
  def build_stata_prompt(query:str,
297
  subcmd:str,
298
  dofx:str,
 
310
  ):
311
  return CATEGORIZER_PROMPT_TEMPLATE.format(
312
  domain=domain,
313
+ query=query,
314
+ approved_options=dict_to_string(APPROVED_OPTIONS, indent=4)
315
  )
316
 
317
  def build_init_prompt(query:str,