allow multi-track drifting (multiple images to retcon)
This commit is contained in:
@@ -5,8 +5,6 @@
|
|||||||
import openai
|
import openai
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
from openai.types.chat import ChatCompletionMessageParam
|
from openai.types.chat import ChatCompletionMessageParam
|
||||||
from openai._types import FileTypes, SequenceNotStr
|
|
||||||
from typing import Union
|
|
||||||
from io import BufferedReader, BytesIO
|
from io import BufferedReader, BytesIO
|
||||||
|
|
||||||
|
|
||||||
@@ -138,7 +136,7 @@ def image_generation(prompt: str, openai_url: str, openai_api_key: str, n=1) ->
|
|||||||
|
|
||||||
|
|
||||||
def image_edit(
|
def image_edit(
|
||||||
image: BufferedReader | BytesIO,
|
image: BufferedReader | BytesIO | list[BufferedReader] | list[BytesIO],
|
||||||
prompt: str,
|
prompt: str,
|
||||||
openai_url: str,
|
openai_url: str,
|
||||||
openai_api_key: str,
|
openai_api_key: str,
|
||||||
|
|||||||
@@ -278,14 +278,17 @@ async def doodlebob(ctx, *, message: str):
|
|||||||
|
|
||||||
@bot.command(name="retcon")
|
@bot.command(name="retcon")
|
||||||
async def retcon(ctx, *, message: str):
|
async def retcon(ctx, *, message: str):
|
||||||
image_url = ctx.message.attachments[0].url
|
image_data_list = []
|
||||||
image_data = requests.get(image_url).content
|
for discord_image in ctx.message.attachments:
|
||||||
image_bytestream = BytesIO(image_data)
|
image_url = discord_image.url
|
||||||
|
image_data = requests.get(image_url).content
|
||||||
|
image_bytestream = BytesIO(image_data)
|
||||||
|
image_data_list.append(image_bytestream)
|
||||||
|
|
||||||
await ctx.send(f"**Rewriting history to match {message[:100]}...**")
|
await ctx.send(f"**Rewriting history to match {message[:100]}...**")
|
||||||
|
|
||||||
image_b64 = llama_wrapper.image_edit(
|
image_b64 = llama_wrapper.image_edit(
|
||||||
image=image_bytestream,
|
image=image_data_list,
|
||||||
prompt=message,
|
prompt=message,
|
||||||
openai_url=IMAGE_EDIT_ENDPOINT,
|
openai_url=IMAGE_EDIT_ENDPOINT,
|
||||||
openai_api_key=IMAGE_EDIT_ENDPOINT_KEY,
|
openai_api_key=IMAGE_EDIT_ENDPOINT_KEY,
|
||||||
|
|||||||
Reference in New Issue
Block a user