From dcc6f94b24839d489491a1afa3b562a768501b35 Mon Sep 17 00:00:00 2001 From: Karl Hudgell Date: Wed, 23 Apr 2025 13:29:43 +0100 Subject: [PATCH] re-add topic logic --- lib.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib.py b/lib.py index e660750..76279d5 100644 --- a/lib.py +++ b/lib.py @@ -104,11 +104,21 @@ def rename_image() -> str | None: def create_prompt_on_openwebui(prompt: str) -> str: """Sends prompt to OpenWebui and returns the generated response.""" - recent_prompts = load_recent_prompts() + # Unique list of recent prompts + recent_prompts = list(set(load_recent_prompts())) + # Decide on whether to include a topic (e.g., 30% chance to include) + topics = [t.strip() for t in user_config["comfyui"]["topics"].split(",") if t.strip()] + topic_instruction = "" + if random.random() < 0.3 and topics: + selected_topic = random.choice(topics) + topic_instruction = f" Incorporate the theme of '{selected_topic}' into the new prompt." + user_content = ( "Here are the prompts from the last 7 days:\n\n" + "\n".join(f"{i+1}. {p}" for i, p in enumerate(recent_prompts)) - + "\n\nDo not repeat ideas, themes, or settings from the above. Now generate a new, completely original Stable Diffusion prompt that hasn't been done yet." + + "\n\nDo not repeat ideas, themes, or settings from the above. " + "Now generate a new, completely original Stable Diffusion prompt that hasn't been done yet." + + topic_instruction ) model = random.choice(user_config["openwebui"]["models"].split(","))