mirror of
https://github.com/karl0ss/ai_image_frame_server.git
synced 2025-06-29 11:19:13 +01:00
try cleanup generated prompt if any other text
This commit is contained in:
parent
4ea81daa47
commit
bfbf8d82e0
@ -3,6 +3,7 @@ import logging
|
||||
import litellm
|
||||
import nest_asyncio
|
||||
from libs.generic import load_recent_prompts, load_config
|
||||
import re
|
||||
nest_asyncio.apply()
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
@ -74,5 +75,10 @@ def create_prompt_on_openwebui(prompt: str, topic: str = "random") -> str:
|
||||
# api_key=user_config["openwebui"]["api_key"],
|
||||
# )
|
||||
# prompt = response["choices"][0]["message"]["content"].strip('"')
|
||||
match = re.search(r'"([^"]+)"', prompt)
|
||||
if not match:
|
||||
match = re.search(r":\s*\n*\s*(.+)", prompt)
|
||||
if match:
|
||||
prompt = match.group(1)
|
||||
logging.debug(prompt)
|
||||
return prompt.split(": ")[-1]
|
||||
return prompt
|
Loading…
x
Reference in New Issue
Block a user