Skip to content

Commit 4c30357

Browse files
committed
Enhance cross pollinate command by adding 'nologo' parameter to control logo removal in generated images. Update function signature and API request accordingly.
1 parent e2254fe commit 4c30357

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

cogs/cross_pollinate_cog.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ async def bookmark(
153153
return
154154

155155

156-
async def generate_cross_pollinate(prompt: str, image_url: str):
156+
async def generate_cross_pollinate(prompt: str, image_url: str, nologo: bool):
157157
"""Generate an edited image using the gptimage model"""
158158

159159
# Encode the image URL for the API
@@ -163,12 +163,14 @@ async def generate_cross_pollinate(prompt: str, image_url: str):
163163
url: str = f"{config.api.image_gen_endpoint}/{prompt}"
164164
url += f"?image={encoded_image}"
165165
url += "&model=gptimage"
166+
url += f"&nologo={nologo}" if nologo else ""
166167
url += f"&referer={config.image_generation.referer}"
167168

168169
dic = {
169170
"prompt": prompt,
170171
"image_url": image_url,
171172
"model": "gptimage",
173+
"nologo": nologo,
172174
"url": quote(url, safe=":/&=?"),
173175
}
174176

@@ -290,13 +292,15 @@ async def cog_load(self) -> None:
290292
@app_commands.describe(
291293
image="The image you want to cross-pollinate (upload an image file)",
292294
prompt="Describe how you want to modify the image",
295+
nologo="Remove the Logo",
293296
private="Only you can see the cross-pollinated image if set to True",
294297
)
295298
async def cross_pollinate_command(
296299
self,
297300
interaction: discord.Interaction,
298301
image: discord.Attachment,
299302
prompt: str,
303+
nologo: bool = config.image_generation.defaults.nologo,
300304
private: bool = config.image_generation.defaults.private,
301305
) -> None:
302306
# Validate the prompt
@@ -343,7 +347,7 @@ async def cross_pollinate_command(
343347
image_url = image.url
344348

345349
dic, edited_image = await generate_cross_pollinate(
346-
prompt=prompt, image_url=image_url
350+
prompt=prompt, image_url=image_url, nologo=nologo
347351
)
348352
time_taken = (datetime.datetime.now() - start).total_seconds()
349353

@@ -370,7 +374,9 @@ async def cross_pollinate_command(
370374

371375
if private:
372376
# For private responses, send embed with file attachment but no view
373-
await interaction.followup.send(embed=embed, file=image_file, ephemeral=True)
377+
await interaction.followup.send(
378+
embed=embed, file=image_file, ephemeral=True
379+
)
374380
else:
375381
# For public responses, send embed with view and file attachment
376382
view: discord.ui.View = CrossPollinateButtonView()

config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
load_dotenv(override=True)
1414

15+
1516
class BotConfig(BaseModel):
1617
command_prefix: str
1718
bot_id: str

0 commit comments

Comments
 (0)