Fixed sme things and added dalle option

This commit is contained in:
Paillat
2023-01-20 13:30:45 +01:00
parent f4d47b1ce5
commit a33f95f024
3 changed files with 57 additions and 44 deletions

View File

@@ -1,7 +1,16 @@
import requests
import os
async def generate(prompt,path):
r = requests.get(f"http://localhost:8000/generate_image?prompt={prompt}&path={path}")
return r.json()
#print the current working directory
print(os.getcwd())
import openai
async def generate(prompt, path, mode, openai_key):
#r = requests.get(f"http://localhost:8000/generate_image?prompt={prompt}&path={path}")
if mode == "sd":
r = requests.get(f"https://localhost:8000/generate_image?prompt={prompt}&path={path}")
return "image generated"
if mode == "dalle":
openai.api_key = openai_key
img = await openai.Image.acreate(
prompt=prompt,
n=1,
size="1024x1024",
)
return img