Files
variet-agent/_test_classify.py

42 lines
1.2 KiB
Python

"""분류 정확도 테스트."""
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
from api.discord_bot import _parse_unified_response
def extract_mode(raw):
parsed = _parse_unified_response(raw)
return parsed.get("mode", "?")
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())