Ufoptg commited on
Commit
3c2992b
·
verified ·
1 Parent(s): 9b505d1

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -4
main.py CHANGED
@@ -107,6 +107,7 @@ app = FastAPI(
107
  )
108
 
109
  trans = SyncTranslator()
 
110
 
111
  timeout = 100
112
  contact_support = """
@@ -471,7 +472,6 @@ def gemini_pro(item: GeminiPro):
471
 
472
  @app.post("/Bing/Dall-E-3")
473
  async def bing_dalle(item: BingDalle):
474
- BingImages = BingClient()
475
  try:
476
  set_cookies(
477
  ".bing.com",
@@ -482,11 +482,11 @@ async def bing_dalle(item: BingDalle):
482
  except requests.exceptions.RequestException:
483
  raise HTTPException(status_code=500, detail="Invalid cookie string, check your cookie string and try again")
484
 
485
- async def generate_image(prompt, model):
486
  try:
487
  response = await BingCreateImages.create_async(
488
- prompt=prompt,
489
  model=model,
 
490
  )
491
 
492
  image_url = response.get('data', [])[0].get('url')
@@ -497,7 +497,7 @@ async def bing_dalle(item: BingDalle):
497
  return {"status": "false", "message": f"Internal Error: {e}"}
498
 
499
  try:
500
- response = await generate_image(item.prompt, item.model)
501
  return response
502
  except BaseException as e:
503
  return {"status": "false", "message": f"Something went wrong: {e}"}
 
107
  )
108
 
109
  trans = SyncTranslator()
110
+ BingImages = BingClient()
111
 
112
  timeout = 100
113
  contact_support = """
 
472
 
473
  @app.post("/Bing/Dall-E-3")
474
  async def bing_dalle(item: BingDalle):
 
475
  try:
476
  set_cookies(
477
  ".bing.com",
 
482
  except requests.exceptions.RequestException:
483
  raise HTTPException(status_code=500, detail="Invalid cookie string, check your cookie string and try again")
484
 
485
+ async def generate_image(model, prompt):
486
  try:
487
  response = await BingCreateImages.create_async(
 
488
  model=model,
489
+ prompt=prompt,
490
  )
491
 
492
  image_url = response.get('data', [])[0].get('url')
 
497
  return {"status": "false", "message": f"Internal Error: {e}"}
498
 
499
  try:
500
+ response = await generate_image(item.model, item.prompt)
501
  return response
502
  except BaseException as e:
503
  return {"status": "false", "message": f"Something went wrong: {e}"}