Spaces:
Running
Running
Bing Dall-E-3 (#11)
Browse files- Update main.py (5f87b05bcce586ddc8cf21c35d9cdbf5367a761e)
Co-authored-by: True Saiyan <[email protected]>
main.py
CHANGED
@@ -58,6 +58,11 @@ from fastapi import Body, Query
|
|
58 |
from fastapi.staticfiles import StaticFiles
|
59 |
from fastapi.templating import Jinja2Templates
|
60 |
|
|
|
|
|
|
|
|
|
|
|
61 |
from pymongo import MongoClient
|
62 |
|
63 |
from RyuzakiLib.hackertools.chatgpt import RendyDevChat
|
@@ -537,6 +542,31 @@ def ryuzaki_ai(
|
|
537 |
except Exception:
|
538 |
return SuccessResponse(status="False", randydev={"message": contact_support})
|
539 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
540 |
@app.post("/ryuzaki/dalle3xl")
|
541 |
def dalle_3xl(
|
542 |
item: Dalle3XL,
|
|
|
58 |
from fastapi.staticfiles import StaticFiles
|
59 |
from fastapi.templating import Jinja2Templates
|
60 |
|
61 |
+
import g4f
|
62 |
+
from g4f.client import Client as BingClient
|
63 |
+
from g4f.cookies import set_cookies
|
64 |
+
from g4f.Provider import BingCreateImages, OpenaiChat, Gemini
|
65 |
+
|
66 |
from pymongo import MongoClient
|
67 |
|
68 |
from RyuzakiLib.hackertools.chatgpt import RendyDevChat
|
|
|
542 |
except Exception:
|
543 |
return SuccessResponse(status="False", randydev={"message": contact_support})
|
544 |
|
545 |
+
|
546 |
+
BingImages = BingClient()
|
547 |
+
|
548 |
+
@app.post("/ryuzaki/dall-e-3")
|
549 |
+
def bing_dalle(item: BingDalle, api_key: None = Depends(validate_api_key)):
|
550 |
+
try:
|
551 |
+
set_cookies(
|
552 |
+
".bing.com",
|
553 |
+
{
|
554 |
+
"_U": item.cookie
|
555 |
+
},
|
556 |
+
)
|
557 |
+
except requests.exceptions.RequestException:
|
558 |
+
raise HTTPException(status_code=500, detail="Invalid cookie string, check your cookie string and try again")
|
559 |
+
|
560 |
+
try:
|
561 |
+
response = BingImages.images.generate(
|
562 |
+
prompt=item.prompt,
|
563 |
+
model=item.model,
|
564 |
+
)
|
565 |
+
return SuccessResponse(status="True", randydev={"data": response.data[0].url})
|
566 |
+
|
567 |
+
except BaseException as e:
|
568 |
+
return SuccessResponse(status="False", randydev={"data": f"Error: {e}"})
|
569 |
+
|
570 |
@app.post("/ryuzaki/dalle3xl")
|
571 |
def dalle_3xl(
|
572 |
item: Dalle3XL,
|