Yaswanth-Bolla commited on
Commit
4ff1ff7
·
1 Parent(s): 50bce45

Added some better logic

Browse files
Files changed (1) hide show
  1. business_continuity.py +5 -1
business_continuity.py CHANGED
@@ -114,6 +114,8 @@ Your output MUST be in this EXACT format with NO DEVIATIONS:
114
  "third_party_vendors_unavailability_strategy": "Strategy for supplier disruptions (2-3 sentences).",
115
  "vendor_reasoning": "Why this vendor strategy works (1 sentence)."
116
  }
 
 
117
  GIVE ONLY this JSON output. DO NOT include any other text, explanations, or formatting.
118
  THE ENTIRE CODE DEPENDS ON THIS JSON STRUCTURE BEING CORRECT. PLEASE ensure the JSON is valid and parsable.
119
  DO NOT add markdown code blocks, explanations, or any text before or after the JSON. ONLY output the raw JSON object."""
@@ -131,7 +133,9 @@ Description: {request.business_process.process_description}"""
131
  # Parse JSON response directly
132
  try:
133
  # Simple direct parsing - trust the LLM to format correctly
134
- strategies_data = json.loads(api_response+'}')
 
 
135
  logger.info(f"Request {request_id}: Successfully parsed JSON")
136
  except json.JSONDecodeError as e:
137
  # If parsing fails, just return the error
 
114
  "third_party_vendors_unavailability_strategy": "Strategy for supplier disruptions (2-3 sentences).",
115
  "vendor_reasoning": "Why this vendor strategy works (1 sentence)."
116
  }
117
+
118
+ CRITICAL: Your output MUST be a valid JSON object with the above structure. If you cannot generate this, return an error message in the same JSON format with a "message" field indicating the error.
119
  GIVE ONLY this JSON output. DO NOT include any other text, explanations, or formatting.
120
  THE ENTIRE CODE DEPENDS ON THIS JSON STRUCTURE BEING CORRECT. PLEASE ensure the JSON is valid and parsable.
121
  DO NOT add markdown code blocks, explanations, or any text before or after the JSON. ONLY output the raw JSON object."""
 
133
  # Parse JSON response directly
134
  try:
135
  # Simple direct parsing - trust the LLM to format correctly
136
+ if not api_response.strip().endswith('}'):
137
+ api_response += '}'
138
+ strategies_data = json.loads(api_response)
139
  logger.info(f"Request {request_id}: Successfully parsed JSON")
140
  except json.JSONDecodeError as e:
141
  # If parsing fails, just return the error