Spaces:
Running
Running
Update main.py
Browse files
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 |
|