diff options
| author | huker667 <huker@tuta.io> | 2026-07-14 08:23:17 +0300 |
|---|---|---|
| committer | huker667 <huker@tuta.io> | 2026-07-14 08:23:17 +0300 |
| commit | 2cce59fb5806633db002d4145070035414e9c42d (patch) | |
| tree | 569b1c2e0e58384cb5a10903ffc94592e0c4a3cd /supergenerator.py | |
| parent | b3f345838899498eee98e16e86e7c3dcba092864 (diff) | |
| download | uzbekgpt-2cce59fb5806633db002d4145070035414e9c42d.tar.gz uzbekgpt-2cce59fb5806633db002d4145070035414e9c42d.tar.bz2 uzbekgpt-2cce59fb5806633db002d4145070035414e9c42d.zip | |
add new markdown
Diffstat (limited to 'supergenerator.py')
| -rw-r--r-- | supergenerator.py | 37 |
1 files changed, 30 insertions, 7 deletions
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: |