Skip to content

Commit

Permalink
fix bugs in assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
genekogan committed Nov 22, 2023
1 parent f8ee783 commit 44dbce2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
8 changes: 6 additions & 2 deletions src/bots/eden/prompts/creator_prompt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ The full schema of a config is as follows. Not all fields are relevant to all ge
Config schema:
* "generator" is which generator to use.
* "text_input" is the text prompt which describes the desired image. It should start with a subject and details, followed by a list of modifier keywords which describe the desired style or aesthetic of the image. Make sure the prompt accurately conveys the user's intent, and is evocative and detailed enough to make a good image, but you may be creative to enhance the user's request into a good text_input. VERY IMPORTANT: if the user asks you to make an image including or of yourself, you should include YOUR NAME in the text_input. (create, controlnet)
* "init_image_data" is a path to an image file which is used as an input or control image for a generator that operates on input images (remix, controlnet, upscale)
* "seed" is a random seed to use for single image generation. Using the same seed for the same config reproduces the exact same generation. If you want to reproduce or slightly alter an earlier creation, copy the seed of the earlier creation. Otherwise leave this blank. (create, controlnet, remix, blend, upscale)
* "init_image" is a path to an image file which is used as an input or control image for a generator that operates on input images (remix, controlnet, upscale)
* "interpolation_init_images" is a *list* of image paths to generate a real2real interpolation video OR a blended image. Image paths must be provided. Copy them from the user. (real2real, blend)
* "interpolation_texts" is a list of text prompts to generate an interpolation video. You must interpret the user's description of the imagery into a *list* with at least two elements. Be creative. VERY IMPORTANT: if the user asks you to make a video including or of yourself, you should include YOUR NAME in all the interpolation_texts. (interpolate)
* "interpolation_seeds" is a list of random numbers, of the same length as "interpolation_texts". If you need to reproduce an earlier interpolation, copy its interpolation_seeds. Otherwise leave this blank. (interpolate, real2real)
* "n_frames" is the number of frames (at 12fps) in the output video. If the user doesn't mention a duration or explicit number of frames, default to 60 if a video (interpolate, real2real)
* "concept" is an optional reference to a specific finetuned concept. Only the following concepts are available: Banny, Kojii, LittleMartian. If the user specifically invokes one of these concepts, select it for the "concept" field and try to include it in the "text_input" field. Note the user might spell it differently, but you should use this spelling not theirs. If no concept is referenced, leave it blank. (create)

When prompted, please output the config and a helpful message explaining what you did to make it and alerting the user to wait for the creation to be made. If the config requires files (such as for the init_image_data or interpolation_init_images fields), make sure to use only the files that were provided by the user in the attachments field.
Note that sometimes the user will make reference to a prior creation, asking you to either modify it or include it in something new. By copying the seed of the prior creation (or in case of video, interpolation_seeds), you can reproduce it with the same config. If you want to make small changes to the prior creation, copy its seed and make changes to the prompt or other parameters.

When prompted, please output the config and a message, in character, explaining what you did to make it and alerting the user to wait for the creation to be made. If the config requires files (such as for the init_image or interpolation_init_images fields), make sure to use only the files that were provided by the user in the attachments field.
28 changes: 15 additions & 13 deletions src/cogs/AssistantCog.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,39 +75,41 @@ async def on_message(self, message: discord.Message) -> None:
}

response = self.assistant(
assistant_message, session_id=str(message.author.id)
assistant_message,
session_id=str(message.author.id)
)
print("rrrrr", response)

reply = response["message"][:2000]
reply = response.get("message")[:2000]
reply_message = await message.reply(reply)

# check if there is a config
config = response["config"]
config = response.get("config")

if not config:
return

mode = config.pop("generator")

if "text_input" in config:
if config.get("text_input"):
text_input = config["text_input"]
elif "interpolation_texts" in config:
elif config.get("interpolation_texts"):
text_input = " to ".join(config["interpolation_texts"])
else:
text_input = mode

if "init_image_data" in config:
config["init_image_data"] = attachment_lookup_url.get(
config["init_image_data"]
if config.get("init_image"):
config["init_image"] = attachment_lookup_url.get(
config["init_image"]
)
if "interpolation_init_images" in config:
if config.get("interpolation_init_images"):
config["interpolation_init_images"] = [
attachment_lookup_url.get(img)
for img in config["interpolation_init_images"]
]

if not config.get("seed"):
config["seed"] = random.randint(1, 1e8)

config = StableDiffusionConfig(
generator_name=mode, seed=random.randint(1, 1e8), **config
generator_name=mode, **config
)

source = get_source(ctx)
Expand Down
4 changes: 0 additions & 4 deletions src/common/eden.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ async def request_creation(
}

attributes = await build_eden_task_attributes(api_url, source.author_id)
print("attributes", attributes)

request = {
"generatorName": generator_name,
Expand All @@ -35,9 +34,6 @@ async def request_creation(
# response = requests.post(f"{api_url}/tasks/create", json=request, headers=header)
response = requests.post(f"{api_url}/admin/tasks/create", json=request, headers=header)

print("config")
print(config_dict)

check, error = await check_server_result_ok(response)

if not check:
Expand Down

0 comments on commit 44dbce2

Please sign in to comment.