merasabkuch commited on
Commit
be57c73
·
verified ·
1 Parent(s): 26ec01f

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +8 -1
main.py CHANGED
@@ -177,9 +177,16 @@ async def analyze_image(file: UploadFile = File(...)):
177
 
178
  # Generate content using the AI model
179
  response = model.generate_content([prompt, blob])
 
 
 
180
 
 
 
 
 
181
  # Return the AI-generated response
182
- return JSONResponse(content=response.text, media_type="application/json")
183
 
184
 
185
 
 
177
 
178
  # Generate content using the AI model
179
  response = model.generate_content([prompt, blob])
180
+
181
+ # Remove extra characters and escape sequences
182
+ cleaned_response = re.sub(r'\\n|json', '', response.text).strip()
183
 
184
+ # Parse the cleaned string as JSON
185
+ data = json.loads(cleaned_response)
186
+ fd = json.dumps(data, indent=4)
187
+
188
  # Return the AI-generated response
189
+ return JSONResponse(content=fd ,media_type="application/json")
190
 
191
 
192