Spaces:
Paused
Paused
Update main.py
#4
by
Ufoptg
- opened
main.py
CHANGED
|
@@ -31,6 +31,10 @@ from typing import *
|
|
| 31 |
from typing import Union
|
| 32 |
|
| 33 |
import g4f
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
import requests
|
| 35 |
from bardapi import Bard
|
| 36 |
from bs4 import BeautifulSoup
|
|
@@ -102,6 +106,7 @@ app = FastAPI(
|
|
| 102 |
)
|
| 103 |
|
| 104 |
trans = SyncTranslator()
|
|
|
|
| 105 |
|
| 106 |
timeout = 100
|
| 107 |
contact_support = """
|
|
@@ -464,6 +469,29 @@ def gemini_pro(item: GeminiPro):
|
|
| 464 |
)
|
| 465 |
|
| 466 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 467 |
@app.post("/UFoP/dalle3xl")
|
| 468 |
def dalle_3xl(item: Dalle3XL, api_key: None = Depends(validate_api_key)):
|
| 469 |
API_URL = SOURCE_DALLE3XL_URL
|
|
|
|
| 31 |
from typing import Union
|
| 32 |
|
| 33 |
import g4f
|
| 34 |
+
from g4f.client import Client as BingClient
|
| 35 |
+
from g4f.cookies import set_cookies
|
| 36 |
+
from g4f.Provider import BingCreateImages, OpenaiChat, Gemini
|
| 37 |
+
|
| 38 |
import requests
|
| 39 |
from bardapi import Bard
|
| 40 |
from bs4 import BeautifulSoup
|
|
|
|
| 106 |
)
|
| 107 |
|
| 108 |
trans = SyncTranslator()
|
| 109 |
+
BingImages = BingClient()
|
| 110 |
|
| 111 |
timeout = 100
|
| 112 |
contact_support = """
|
|
|
|
| 469 |
)
|
| 470 |
|
| 471 |
|
| 472 |
+
@app.get("/Bing/Dall-E-3")
|
| 473 |
+
async def bing_dalle(item: BingDalle):
|
| 474 |
+
try:
|
| 475 |
+
set_cookies(
|
| 476 |
+
".bing.com",
|
| 477 |
+
{
|
| 478 |
+
"_U": item.cookie
|
| 479 |
+
},
|
| 480 |
+
)
|
| 481 |
+
except requests.exceptions.RequestException:
|
| 482 |
+
raise HTTPException(status_code=500, detail="Invalid cookie string, check your cookie string and try again")
|
| 483 |
+
|
| 484 |
+
try:
|
| 485 |
+
response = BingImages.images.generate(
|
| 486 |
+
prompt=item.prompt,
|
| 487 |
+
model=item.model,
|
| 488 |
+
)
|
| 489 |
+
return {"status": "true", "sukuna": {"message": response.data[0].url}}
|
| 490 |
+
|
| 491 |
+
except BaseException e:
|
| 492 |
+
return {"status": "false", "message": f"Something went wrong: {e}"}
|
| 493 |
+
|
| 494 |
+
|
| 495 |
@app.post("/UFoP/dalle3xl")
|
| 496 |
def dalle_3xl(item: Dalle3XL, api_key: None = Depends(validate_api_key)):
|
| 497 |
API_URL = SOURCE_DALLE3XL_URL
|