added dalle3hd
This commit is contained in:
parent
c65cf891ff
commit
0ccd421f8b
1 changed files with 25 additions and 4 deletions
|
|
@ -103,7 +103,7 @@ class ChatGPT(commands.Cog):
|
|||
self.bot.logger.exception("Error occurred in answer_question")
|
||||
return "Error occurred in answer_question"
|
||||
|
||||
async def get_dalle(self, prompt, model="dall-e-2"):
|
||||
async def get_dalle(self, prompt, model="dall-e-2", quality="standard", size="1024x1024"):
|
||||
headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': f'Bearer {os.getenv("openai.api_key")}',
|
||||
|
|
@ -111,8 +111,8 @@ class ChatGPT(commands.Cog):
|
|||
data = {
|
||||
"model": model,
|
||||
"prompt": prompt,
|
||||
"size": "1024x1024",
|
||||
"quality": "standard",
|
||||
"size": size,
|
||||
"quality": quality,
|
||||
"n":1,
|
||||
}
|
||||
url = "https://api.openai.com/v1/images/generations"
|
||||
|
|
@ -241,7 +241,28 @@ class ChatGPT(commands.Cog):
|
|||
async def dalle3(self, ctx):
|
||||
if ctx.author.get_role(self.premium_role):
|
||||
prompt = ctx.message.content.split(" ", maxsplit=1)[1]
|
||||
img_url = await self.get_dalle(prompt, "dall-e-3")
|
||||
img_url = await self.get_dalle(prompt, model="dall-e-3")
|
||||
my_filename = str(time.time_ns()) + ".png"
|
||||
filepath = f"{self.data_dir}dalle/{my_filename}"
|
||||
await self.download_image(img_url, filepath)
|
||||
with open(filepath, "rb") as fh:
|
||||
f = discord.File(fh, filename=filepath)
|
||||
log_data = f'Author: {ctx.author.name}, Prompt: {prompt}, Filename: {my_filename}\n'
|
||||
with open(f"{self.data_dir}logs/dalle3.log", 'a') as log_file:
|
||||
log_file.writelines(log_data)
|
||||
await ctx.send(f'Generated by: {ctx.author.name}\nPrompt: {prompt}', file=f)
|
||||
else:
|
||||
await ctx.send("Sorry you must be a premium member to use this command. (!donate)")
|
||||
|
||||
@commands.command(
|
||||
description="Dalle 3 HD",
|
||||
help="Generate an HD image with Dalle 3 Usage: !dalle3 (prompt)",
|
||||
brief="Generate HD Image",
|
||||
)
|
||||
async def dalle3hd(self, ctx):
|
||||
if ctx.author.get_role(self.premium_role):
|
||||
prompt = ctx.message.content.split(" ", maxsplit=1)[1]
|
||||
img_url = await self.get_dalle(prompt, model="dall-e-3", quality="hd", size="1792x1024")
|
||||
my_filename = str(time.time_ns()) + ".png"
|
||||
filepath = f"{self.data_dir}dalle/{my_filename}"
|
||||
await self.download_image(img_url, filepath)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue