mirror of
https://github.com/Physton/sd-webui-prompt-all-in-one.git
synced 2026-05-01 11:41:46 +00:00
New Feature: Keyword Grouping / One-Click Keyword Addition
新功能:关键词分组 / 一键添加关键词
This commit is contained in:
@@ -20,6 +20,7 @@ from scripts.physton_prompt.gen_openai import gen_openai
|
||||
from scripts.physton_prompt.get_lang import get_lang
|
||||
from scripts.physton_prompt.get_version import get_git_commit_version, get_git_remote_versions, get_latest_version
|
||||
from scripts.physton_prompt.mbart50 import initialize as mbart50_initialize, translate as mbart50_translate
|
||||
from scripts.physton_prompt.get_group_tags import get_group_tags
|
||||
|
||||
try:
|
||||
from modules.shared import cmd_opts
|
||||
@@ -368,6 +369,10 @@ def on_app_started(_: gr.Blocks, app: FastAPI):
|
||||
except Exception as e:
|
||||
return {"success": False, 'message': str(e)}
|
||||
|
||||
@app.get("/physton_prompt/get_group_tags")
|
||||
async def _get_group_tags(lang: str):
|
||||
return {"tags": get_group_tags(lang)}
|
||||
|
||||
try:
|
||||
translate_api = st.get('translateApi')
|
||||
if translate_api == 'mbart50':
|
||||
|
||||
21
scripts/physton_prompt/get_group_tags.py
Normal file
21
scripts/physton_prompt/get_group_tags.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import os
|
||||
|
||||
def get_group_tags(lang):
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
tags_file = os.path.join(current_dir, '../../group_tags/', 'custom.yaml')
|
||||
if not os.path.exists(tags_file):
|
||||
tags_file = os.path.join(current_dir, '../../group_tags/', lang + '.yaml')
|
||||
if not os.path.exists(tags_file):
|
||||
tags_file = os.path.join(current_dir, '../../group_tags/', 'default.yaml')
|
||||
if not os.path.exists(tags_file):
|
||||
return ''
|
||||
|
||||
tags_file = os.path.normpath(tags_file)
|
||||
tags = ''
|
||||
try:
|
||||
with open(tags_file, 'r', encoding='utf8') as f:
|
||||
tags = f.read()
|
||||
except:
|
||||
pass
|
||||
return tags
|
||||
Reference in New Issue
Block a user