Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -260,15 +260,11 @@ def dalle_3xl(
|
|
260 |
):
|
261 |
API_URL = SOURCE_DALLE3XL_URL
|
262 |
try:
|
263 |
-
payload = {
|
264 |
-
|
265 |
-
"
|
266 |
-
"
|
267 |
-
|
268 |
-
"seed": item.seed if item.seed != -1 else random.randint(1, 1000000000),
|
269 |
-
"strength": item.strength
|
270 |
-
}
|
271 |
-
headers = {"Authorization": f"Bearer {HUGGING_TOKEN}"}
|
272 |
response = requests.post(API_URL, headers=headers, json=payload, timeout=timeout)
|
273 |
response.raise_for_status()
|
274 |
except requests.exceptions.RequestException:
|
@@ -276,6 +272,7 @@ def dalle_3xl(
|
|
276 |
status_code=500,
|
277 |
detail=CustomErrorResponseModel(detail=[{}])
|
278 |
)
|
|
|
279 |
try:
|
280 |
encoded_string = base64.b64encode(response.content).decode("utf-8")
|
281 |
except Exception:
|
@@ -283,11 +280,13 @@ def dalle_3xl(
|
|
283 |
status_code=500,
|
284 |
detail=CustomErrorResponseModel(detail=[{}])
|
285 |
)
|
|
|
286 |
if encoded_string:
|
287 |
return SuccessResponse(status="True", sukuna={"data": encoded_string})
|
288 |
else:
|
289 |
return SuccessResponse(status="False", sukuna={"data": contact_support})
|
290 |
|
|
|
291 |
@app.get("/ryuzaki/unsplash")
|
292 |
async def get_image_unsplash(query: str, size: str="500x500"):
|
293 |
url = SOURCE_UNSPLASH_URL
|
|
|
260 |
):
|
261 |
API_URL = SOURCE_DALLE3XL_URL
|
262 |
try:
|
263 |
+
payload = {"inputs": item.query}
|
264 |
+
headers = {
|
265 |
+
"Authorization": f"Bearer {HUGGING_TOKEN}",
|
266 |
+
"Content-Type": "application/json",
|
267 |
+
}
|
|
|
|
|
|
|
|
|
268 |
response = requests.post(API_URL, headers=headers, json=payload, timeout=timeout)
|
269 |
response.raise_for_status()
|
270 |
except requests.exceptions.RequestException:
|
|
|
272 |
status_code=500,
|
273 |
detail=CustomErrorResponseModel(detail=[{}])
|
274 |
)
|
275 |
+
|
276 |
try:
|
277 |
encoded_string = base64.b64encode(response.content).decode("utf-8")
|
278 |
except Exception:
|
|
|
280 |
status_code=500,
|
281 |
detail=CustomErrorResponseModel(detail=[{}])
|
282 |
)
|
283 |
+
|
284 |
if encoded_string:
|
285 |
return SuccessResponse(status="True", sukuna={"data": encoded_string})
|
286 |
else:
|
287 |
return SuccessResponse(status="False", sukuna={"data": contact_support})
|
288 |
|
289 |
+
|
290 |
@app.get("/ryuzaki/unsplash")
|
291 |
async def get_image_unsplash(query: str, size: str="500x500"):
|
292 |
url = SOURCE_UNSPLASH_URL
|