From 2cce59fb5806633db002d4145070035414e9c42d Mon Sep 17 00:00:00 2001 From: huker667 Date: Tue, 14 Jul 2026 08:23:17 +0300 Subject: add new markdown --- supergenerator.py | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'supergenerator.py') diff --git a/supergenerator.py b/supergenerator.py index 17c4c03..b64994f 100644 --- a/supergenerator.py +++ b/supergenerator.py @@ -146,6 +146,7 @@ def set_user_config( call_mode=DEFAULT_CALL, prompt_name=DEFAULT_PROMPT, notify_mode=DEFAULT_NOTIFY, + markdown="", ): with shelve.open("users") as db: db[str(user_id)] = { @@ -154,6 +155,7 @@ def set_user_config( "call": call_mode, "prompt": prompt_name, "notify": notify_mode, + "markdown": markdown, } @@ -163,7 +165,8 @@ def ensure_user( stream_mode=DEFAULT_STREAM, call_mode=DEFAULT_CALL, prompt_name=DEFAULT_PROMPT, - notify_mode=DEFAULT_NOTIFY + notify_mode=DEFAULT_NOTIFY, + markdown="" ): with shelve.open("users") as db: key = str(user_id) @@ -175,14 +178,30 @@ def ensure_user( "call": call_mode, "prompt": prompt_name, "notify": notify_mode, + "markdown": markdown, } + def get_user_config(user_id): with shelve.open("users") as db: - return db.get( - str(user_id), - {"model": DEFAULT_MODEL, "stream": DEFAULT_STREAM, "call": DEFAULT_CALL, "prompt": DEFAULT_PROMPT, "notify": DEFAULT_NOTIFY}, - ) + config = db.get(str(user_id), {}) + defaults = { + "model": DEFAULT_MODEL, + "stream": DEFAULT_STREAM, + "call": DEFAULT_CALL, + "prompt": DEFAULT_PROMPT, + "notify": DEFAULT_NOTIFY, + "markdown": "", + } + updated = False + for key, value in defaults.items(): + if key not in config: + config[key] = value + updated = True + if updated: + db[str(user_id)] = config + return config + async def generate( @@ -205,6 +224,10 @@ async def generate( system_prompt_name = config["prompt"] if system_prompt_name in SYSTEM_PROMPTS: system_prompt = SYSTEM_PROMPTS[system_prompt_name] + ADD_TO_PROMPT + if config["markdown"] == "new": + system_prompt += NEW_MD + else: + system_prompt += OLD_MD else: text = "❌произошла ошибка, возможные проблемы:\n" \ f"1. у вас выбран удалённый сист промпт (`{system_prompt_name}`)\n" \ @@ -259,7 +282,7 @@ async def generate( print(f"{RED} -- err photo - {e} : {model}{RESET}") content += [{"type": "text", "text": prompt}] - messages = [{"role": "system", "content": SYSTEM_PROMPTS[DEFAULT_PROMPT]+ADD_TO_PROMPT}] + [ + messages = [{"role": "system", "content": SYSTEM_PROMPTS[DEFAULT_PROMPT]+ADD_TO_PROMPT+OLD_MD}] + [ {"role": "user", "content": content} ] @@ -337,7 +360,7 @@ async def openai_generate_text( stream=stream, max_tokens=MAX_TOKENS, extra_body={ - "think": False + "think": "false" } ) if stream: -- cgit v1.3.1