merasabkuch commited on
Commit
8759844
·
verified ·
1 Parent(s): 00658f1

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -0
main.py CHANGED
@@ -180,6 +180,9 @@ async def analyze_image(file: UploadFile = File(...)):
180
  # Generate content using the AI model
181
  response = model.generate_content([prompt, blob])
182
 
 
 
 
183
  # Extract JSON string from Markdown-formatted JSON string
184
  json_string = re.search(r'```json(.*?)```', response.text, re.DOTALL).group(1)
185
 
 
180
  # Generate content using the AI model
181
  response = model.generate_content([prompt, blob])
182
 
183
+ if '```json' not in response.text:
184
+ return JSONResponse(content=response.text ,media_type="application/json")
185
+
186
  # Extract JSON string from Markdown-formatted JSON string
187
  json_string = re.search(r'```json(.*?)```', response.text, re.DOTALL).group(1)
188