New Feature: Keyword Grouping / One-Click Keyword Addition

新功能:关键词分组 / 一键添加关键词
This commit is contained in:
Physton
2023-08-15 15:56:26 +08:00
parent ec53d79bc6
commit 787575aca2
36 changed files with 54071 additions and 60 deletions

View File

@@ -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':

View 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