fix(prompt): anime 분류 정확도 강화 (6/6 테스트 통과)
- NAS/자막/애니 키워드 포함시 task 대신 anime 우선 분류 - nextcloud 판단 기준 별도 섹션 추가 - anime/nextcloud 키워드 우선 규칙 명시
This commit is contained in:
55
_test_classify.py
Normal file
55
_test_classify.py
Normal file
@@ -0,0 +1,55 @@
|
||||
"""분류 정확도 테스트."""
|
||||
import asyncio
|
||||
import io
|
||||
import json
|
||||
import sys
|
||||
|
||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
|
||||
sys.path.insert(0, ".")
|
||||
|
||||
from core.gemini_caller import GeminiCaller
|
||||
|
||||
|
||||
def extract_mode(raw):
|
||||
start = raw.find("{")
|
||||
if start == -1:
|
||||
return "NO_JSON"
|
||||
depth = 0
|
||||
for i in range(start, len(raw)):
|
||||
if raw[i] == "{":
|
||||
depth += 1
|
||||
elif raw[i] == "}":
|
||||
depth -= 1
|
||||
if depth == 0:
|
||||
try:
|
||||
p = json.loads(raw[start : i + 1])
|
||||
return p.get("mode", "?")
|
||||
except json.JSONDecodeError:
|
||||
return "PARSE_ERR"
|
||||
return "NO_CLOSE"
|
||||
|
||||
|
||||
async def main():
|
||||
g = GeminiCaller()
|
||||
tests = [
|
||||
("anime", "nas에 애니 자막 나온거까지 최신화 해줘"),
|
||||
("anime", "이번 분기 신작 애니 편성표 보여줘"),
|
||||
("nextcloud", "클라우드에 pdf파일 몇개나 있어?"),
|
||||
("nextcloud", "오늘 일정 뭐야?"),
|
||||
("chat", "파이썬 리스트 정렬 어떻게 해?"),
|
||||
("chat", "3 더하기 5는?"),
|
||||
]
|
||||
|
||||
ok = 0
|
||||
for expected, text in tests:
|
||||
raw = await g.call("unified", f"## User Message\n{text}", timeout=60)
|
||||
got = extract_mode(raw)
|
||||
mark = "OK" if got == expected else "FAIL"
|
||||
if mark == "OK":
|
||||
ok += 1
|
||||
print(f" [{mark}] expected={expected} got={got} -- {text}")
|
||||
|
||||
print(f"\nResult: {ok}/{len(tests)} passed")
|
||||
|
||||
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user