2026-10-23 12:58:04 +09:00
|
|
|
"""Self-check of the quick answers (assistant/quick_answers.py): python tests/test_quick_answers.py
|
|
|
|
|
|
|
|
|
|
Needs the embedding server (assistant/knowledge.embed starts it); nothing moves. Standalone questions get their kind,
|
|
|
|
|
in other words than the bank's too; follow-ups, camera questions, commands and company facts never do."""
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
from assistant import quick_answers as qa
|
|
|
|
|
|
|
|
|
|
TALK = [("what does cutshion make?", "Cutshion makes robot applications, such as barista and cooking robots.")]
|
|
|
|
|
|
|
|
|
|
KIND = { # words (no talk before) -> kind
|
2026-10-26 06:27:06 +09:00
|
|
|
"how many employees does Cutshion have?": "co_unknown", "직원이 몇 명이에요?": "co_unknown",
|
|
|
|
|
"how old is Cutshion?": "co_founded", "대표가 누구예요?": "co_ceo", # company kinds: bank_words/company.py
|
2026-10-23 12:58:04 +09:00
|
|
|
"who made you?": "maker", "Lumi, who built you?": "maker", "누가 만들었어요?": "maker", "어느 회사 로봇이에요?": "maker",
|
|
|
|
|
"what's your name?": "name", "이름이 뭐예요?": "name", "니 이름 머야": "name",
|
|
|
|
|
"how old are you?": "age", "몇 살이에요?": "age", "너 몇 살이야?": "age",
|
|
|
|
|
"who are you?": "who", "넌 누구니?": "who", "introduce yourself please": "who",
|
|
|
|
|
"how tall are you?": "height", "키가 몇이에요?": "height",
|
|
|
|
|
"how long does your battery last?": "battery_life", "배터리 몇 시간 가요?": "battery_life",
|
|
|
|
|
"what languages do you speak?": "languages", "영어 할 줄 알아?": "languages",
|
|
|
|
|
"are you chatgpt?": "chatgpt", "너 챗GPT 써?": "chatgpt", "무슨 AI 써요?": "model",
|
|
|
|
|
"are you a robot?": "robot", "감정 있어요?": "robot",
|
|
|
|
|
"hello": "hello", "안녕하세요": "hello", "hi lumi": "hello",
|
|
|
|
|
"how much do you weigh?": "weight", "how fast can you go?": "speed",
|
2026-10-26 05:43:03 +09:00
|
|
|
"what time is it?": "time_now", "지금 몇 시야?": "time_now", "오늘 며칠이에요?": "date_today",
|
|
|
|
|
"what day is it today?": "date_today", "오늘 무슨 요일이야?": "date_today",
|
|
|
|
|
"are you a Korean robot?": "country", "어느 나라 로봇이에요?": "country", "what computer do you use?": "computer",
|
|
|
|
|
"관절이 몇 개예요?": "dof", "음성 인식 뭐 써요?": "stt", "how fast do you answer?": "reply_time",
|
|
|
|
|
"where are you used?": "used_where", "인터넷 써요?": "internet",
|
2026-10-23 12:58:04 +09:00
|
|
|
}
|
|
|
|
|
IN_TALK = { # words after TALK -> kind or None
|
|
|
|
|
"how old are you?": "age", "who made you?": "maker", "what's your name?": "name",
|
|
|
|
|
"how old?": None, "몇 살이에요?": None, "hello": None, "why?": None, "really?": None, "and you?": None,
|
|
|
|
|
"who runs it?": None, "how many people work there?": None, "진짜?": None, "왜요?": None, "너는?": None, "무겁습니까?": None, "어떤 로봇이요?": None,
|
|
|
|
|
}
|
|
|
|
|
NEVER = [ # no talk before: never a quick answer
|
|
|
|
|
"can you see me?", "what am I holding?", "what colour is my shirt?", "how old do I look?", "how tall am I?",
|
|
|
|
|
"나 보여?", "내 옷 무슨 색이야?", "카메라로 뭐 보여요?",
|
|
|
|
|
"come here", "follow me", "wave at me", "sing a song", "이리 와", "손 흔들어 줘", "노래 불러 줘",
|
2026-10-26 06:27:06 +09:00
|
|
|
"how much do you cost?", "가격이 얼마예요?",
|
|
|
|
|
"how long does charging take?", "충전 얼마나 걸려요?", "who is the CEO?",
|
2026-10-26 05:43:03 +09:00
|
|
|
"what's the weather?", "what time does the show start?", "몇 시에 끝나요?", "thanks", "고마워요", "okay", "bye",
|
|
|
|
|
"goodbye", "May I ask you something?",
|
2026-10-23 12:58:04 +09:00
|
|
|
"what's your name and how old are you?", "who made you? and why?", "how much can you lift?",
|
|
|
|
|
"what can you do?", "how much battery is left?", "who made your arm?", "너 얼마야?", "얼마나 무거운 거 들 수 있어?",
|
|
|
|
|
"로봇 미국 회사 맞아요?",
|
2026-10-26 05:43:03 +09:00
|
|
|
"when is your birthday?", "생일이 언제예요?", "완충까지 몇 시간이에요?", "how slow can you drive?", "what are you doing?",
|
|
|
|
|
"너 자카 로봇이야?", "can you hear me?", "키 줄여 줘", "Price of the ice cream robot?",
|
2026-10-23 12:58:04 +09:00
|
|
|
]
|
|
|
|
|
FACT = {"chatgpt": r"\bno\b|아니", "name": r"lumi|루미", "who": r"lumi|루미", "age": r"\b2\b|two|두 살", "maker": r"cutshion|쿳션",
|
|
|
|
|
"height": r"146", "battery_life": r"10", "languages": r"english|영어", "model": r"gemma|젬마",
|
|
|
|
|
"robot": r"robot|로봇", "weight": r"96", "speed": r"0\.6"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _ToLLM(Exception):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def through_answer():
|
|
|
|
|
"""lumi.Lumi.answer(): the quick answer is said and kept in the talk; "why?" next goes to the LLM."""
|
|
|
|
|
import types
|
|
|
|
|
from assistant import lumi
|
|
|
|
|
from audio import mouth
|
|
|
|
|
from tasks import fetch
|
|
|
|
|
said = []
|
|
|
|
|
lumi.LOG_FILE = "/dev/null"
|
|
|
|
|
mouth.say = lambda text, lang=None, abort=None: said.append(text)
|
|
|
|
|
lumi.ears.understood = lambda *a: True
|
|
|
|
|
lumi.ears.last_stt = {"language": "english", "logprob": -0.1}
|
|
|
|
|
fetch.check_hand = lambda: False
|
|
|
|
|
L = lumi.Lumi.__new__(lumi.Lumi)
|
|
|
|
|
L.lang, L.current, L.closing_pending, L.markers = "en", None, None, ["home", "stage"]
|
|
|
|
|
|
|
|
|
|
def llm(*a, **k):
|
|
|
|
|
raise _ToLLM()
|
|
|
|
|
L.brain = types.SimpleNamespace(history=[], topic=llm, is_lookup_follow_up=lambda t: False)
|
|
|
|
|
for name in ("follow_stop", "drive_words", "fetch_voice", "quick_command"):
|
|
|
|
|
setattr(L, name, lambda *a: False)
|
|
|
|
|
L.voice_setting = lambda text, last: False
|
|
|
|
|
L.mission_running = L.chain_busy = lambda: False
|
|
|
|
|
L.fetch_status = lambda: None
|
|
|
|
|
L.keep_listening = lambda: None
|
|
|
|
|
L.speak_abort = lambda: False
|
|
|
|
|
bad = 0
|
|
|
|
|
L.answer("who made you?")
|
|
|
|
|
if not said or not re.search(r"cutshion", said[-1], re.I) or L.brain.history[-1][0] != "who made you?":
|
|
|
|
|
bad += 1
|
|
|
|
|
print(f"FAIL through answer: {said} {L.brain.history}")
|
|
|
|
|
try:
|
|
|
|
|
L.answer("why?")
|
|
|
|
|
bad += 1
|
|
|
|
|
print("FAIL: why? after a quick answer did not go to the LLM")
|
|
|
|
|
except _ToLLM:
|
|
|
|
|
pass
|
|
|
|
|
return bad
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
bad = 0
|
|
|
|
|
for words, want in KIND.items():
|
|
|
|
|
got = qa.kind_of(words)
|
|
|
|
|
if got != want:
|
|
|
|
|
bad += 1
|
|
|
|
|
print(f"FAIL kind {words!r}: {got} (want {want})")
|
|
|
|
|
for words, want in IN_TALK.items():
|
|
|
|
|
got = qa.kind_of(words, TALK)
|
|
|
|
|
if got != want:
|
|
|
|
|
bad += 1
|
|
|
|
|
print(f"FAIL in talk {words!r}: {got} (want {want})")
|
|
|
|
|
for words in NEVER:
|
|
|
|
|
got = qa.kind_of(words)
|
|
|
|
|
if got:
|
|
|
|
|
bad += 1
|
|
|
|
|
print(f"FAIL never {words!r}: {got}")
|
|
|
|
|
for kind, (_, lines) in qa.KINDS.items(): # every answer says its fact; Korean polite, the right name
|
|
|
|
|
for lang, says in lines.items():
|
|
|
|
|
for s in says:
|
|
|
|
|
if kind in FACT and not re.search(FACT[kind], s, re.I) or lang == "ko" and \
|
2026-10-26 06:27:06 +09:00
|
|
|
(not re.search(r"(?:요|다)[.!?]?$", s) or re.search(r"컷션|커션", s)):
|
2026-10-23 12:58:04 +09:00
|
|
|
bad += 1
|
|
|
|
|
print(f"FAIL answer {kind}/{lang}: {s}")
|
|
|
|
|
a, b = qa.answer("how old are you?", "en"), qa.answer("how old are you?", "en")
|
|
|
|
|
if not a or a == b:
|
|
|
|
|
bad += 1
|
|
|
|
|
print(f"FAIL variety: {a!r} then {b!r}")
|
|
|
|
|
if not re.search(r"[가-힣]", qa.answer("몇 살이에요?", "ko") or ""):
|
|
|
|
|
bad += 1
|
|
|
|
|
print("FAIL Korean answer")
|
|
|
|
|
bad += through_answer()
|
|
|
|
|
print("quick answers:", "all passed" if not bad else f"{bad} failed")
|
|
|
|
|
return bad
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
raise SystemExit(1 if main() else 0)
|