pref:优化webui界面,增加prompt模板元信息
This commit is contained in:
@@ -178,7 +178,6 @@ def _install_stub_modules(monkeypatch):
|
||||
class _EmojiConfig:
|
||||
max_reg_num = 20
|
||||
content_filtration = False
|
||||
filtration_prompt = ""
|
||||
steal_emoji = False
|
||||
do_replace = False
|
||||
check_interval = 1
|
||||
@@ -1956,7 +1955,6 @@ async def test_build_emoji_description_content_filtration_reject(monkeypatch):
|
||||
logger = emoji_manager_new.logger
|
||||
|
||||
emoji_manager_new.global_config.emoji.content_filtration = True
|
||||
emoji_manager_new.global_config.emoji.filtration_prompt = "rule"
|
||||
|
||||
def _read_bytes(_path):
|
||||
return b""
|
||||
@@ -1994,13 +1992,15 @@ async def test_build_emoji_description_content_filtration_pass(monkeypatch):
|
||||
logger = emoji_manager_new.logger
|
||||
|
||||
emoji_manager_new.global_config.emoji.content_filtration = True
|
||||
emoji_manager_new.global_config.emoji.filtration_prompt = "rule"
|
||||
|
||||
def _read_bytes(_path):
|
||||
return b""
|
||||
|
||||
async def _vlm_response(prompt, *_args, **_kwargs):
|
||||
if "rule" in str(prompt):
|
||||
call_count = {"n": 0}
|
||||
|
||||
async def _vlm_response(*_args, **_kwargs):
|
||||
call_count["n"] += 1
|
||||
if call_count["n"] == 2:
|
||||
return "是", None
|
||||
return "desc", None
|
||||
|
||||
|
||||
@@ -87,7 +87,46 @@ def test_list_prompt_templates_prefers_locale_specific_files(tmp_path: Path) ->
|
||||
|
||||
prompt_templates = list_prompt_templates(prompts_root=prompts_root)
|
||||
|
||||
assert prompt_templates["replyer"].read_text(encoding="utf-8") == "English"
|
||||
assert prompt_templates["replyer"].path.read_text(encoding="utf-8") == "English"
|
||||
|
||||
|
||||
def test_list_prompt_templates_loads_directory_metadata(tmp_path: Path) -> None:
|
||||
prompts_root = tmp_path / "prompts"
|
||||
write_prompt(prompts_root, "zh-CN", "replyer", "中文")
|
||||
metadata_path = prompts_root / "zh-CN" / ".meta.toml"
|
||||
metadata_path.write_text(
|
||||
"""
|
||||
[replyer]
|
||||
display_name = "回复器"
|
||||
advanced = true
|
||||
description = "用于生成回复的主模板"
|
||||
""".strip(),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
prompt_templates = list_prompt_templates(prompts_root=prompts_root)
|
||||
metadata = prompt_templates["replyer"].metadata
|
||||
|
||||
assert metadata.display_name == "回复器"
|
||||
assert metadata.advanced is True
|
||||
assert metadata.description == "用于生成回复的主模板"
|
||||
|
||||
|
||||
def test_list_prompt_templates_loads_prompt_specific_metadata(tmp_path: Path) -> None:
|
||||
prompts_root = tmp_path / "prompts"
|
||||
write_prompt(prompts_root, "zh-CN", "replyer", "中文")
|
||||
metadata_path = prompts_root / "zh-CN" / "replyer.meta.json"
|
||||
metadata_path.write_text(
|
||||
'{"display_name": "Replyer", "advanced": false, "description": "Prompt specific metadata"}',
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
prompt_templates = list_prompt_templates(prompts_root=prompts_root)
|
||||
metadata = prompt_templates["replyer"].metadata
|
||||
|
||||
assert metadata.display_name == "Replyer"
|
||||
assert metadata.advanced is False
|
||||
assert metadata.description == "Prompt specific metadata"
|
||||
|
||||
|
||||
def test_list_prompt_templates_reports_duplicate_name_with_custom_root(tmp_path: Path) -> None:
|
||||
|
||||
Reference in New Issue
Block a user