rairo commited on
Commit
0eadc66
·
verified ·
1 Parent(s): 6d2dafd

Update utility.py

Browse files
Files changed (1) hide show
  1. utility.py +4 -4
utility.py CHANGED
@@ -543,6 +543,7 @@ def generateResponse(prompt: str, currency: str = "R") -> str:
543
  return '{"error": "Model not available"}'
544
 
545
  # --- FIX BUG 4: Inject User Currency into System Prompt ---
 
546
  system_prompt = f"""
547
  Analyze the user's request for business transaction management. Your goal is to extract structured information about one or more transactions and output it as a valid JSON list.
548
 
@@ -550,7 +551,7 @@ def generateResponse(prompt: str, currency: str = "R") -> str:
550
  - **Default Currency:** {currency} (Use this currency code if no symbol is provided in the input).
551
 
552
  **1. Output Format:**
553
- You MUST output your response as a valid JSON list `[]` containing one or more transaction objects `{}`.
554
 
555
  **2. Transaction Object Structure:**
556
  Each transaction object MUST have the following keys:
@@ -577,9 +578,8 @@ Each transaction object MUST have the following keys:
577
 
578
  **Example 2: Creating a Normalized Expense**
579
  - **Input:** "I paid 250 for fuel for work" (Assuming {currency} default)
580
- - **Output:** [ {{"intent": "create", "transaction_type": "expense", "details": {{"description": "fuel", "amount": 250, "currency": "{currency}"}} }} ]"""
581
-
582
-
583
  try:
584
  full_prompt = [system_prompt, prompt]
585
  response = model.generate_content(full_prompt)
 
543
  return '{"error": "Model not available"}'
544
 
545
  # --- FIX BUG 4: Inject User Currency into System Prompt ---
546
+ # NOTE: {currency} uses single braces for variable. {{}} uses double braces for literal JSON.
547
  system_prompt = f"""
548
  Analyze the user's request for business transaction management. Your goal is to extract structured information about one or more transactions and output it as a valid JSON list.
549
 
 
551
  - **Default Currency:** {currency} (Use this currency code if no symbol is provided in the input).
552
 
553
  **1. Output Format:**
554
+ You MUST output your response as a valid JSON list `[]` containing one or more transaction objects `{{}}`.
555
 
556
  **2. Transaction Object Structure:**
557
  Each transaction object MUST have the following keys:
 
578
 
579
  **Example 2: Creating a Normalized Expense**
580
  - **Input:** "I paid 250 for fuel for work" (Assuming {currency} default)
581
+ - **Output:** [ {{"intent": "create", "transaction_type": "expense", "details": {{"description": "fuel", "amount": 250, "currency": "{currency}"}} }} ]
582
+ """
 
583
  try:
584
  full_prompt = [system_prompt, prompt]
585
  response = model.generate_content(full_prompt)