Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -256,10 +256,12 @@ async def gemini(q: str, model: str = "flash"):
|
|
256 |
response = requests.get(url)
|
257 |
response.raise_for_status() # Raise an error for bad status codes
|
258 |
data = response.json()
|
259 |
-
return data['content']
|
260 |
except requests.exceptions.RequestException as e:
|
261 |
raise HTTPException(status_code=500, detail=f"Gemini API request failed: {e}")
|
262 |
|
|
|
|
|
263 |
@app.get("/api/web_gemini")
|
264 |
async def web_gemini(q: str, model: str = "flash"):
|
265 |
"""Search the web and get answers from Gemini models."""
|
|
|
256 |
response = requests.get(url)
|
257 |
response.raise_for_status() # Raise an error for bad status codes
|
258 |
data = response.json()
|
259 |
+
return JSONResponse(content=jsonable_encoder({data['content']})) # Use JSONResponse to return a JSON
|
260 |
except requests.exceptions.RequestException as e:
|
261 |
raise HTTPException(status_code=500, detail=f"Gemini API request failed: {e}")
|
262 |
|
263 |
+
|
264 |
+
|
265 |
@app.get("/api/web_gemini")
|
266 |
async def web_gemini(q: str, model: str = "flash"):
|
267 |
"""Search the web and get answers from Gemini models."""
|