From 12e35cf163174a48450fe050ba475a5c23fd392a Mon Sep 17 00:00:00 2001 From: Cutshion Date: Fri, 23 Oct 2026 12:58:04 +0900 Subject: [PATCH] Intent bank grown to 4008 wordings (every crowd, dialect, Konglish); new quick answers: frequent questions about Lumi answered at once from known facts, follow-ups left to the LLM Co-Authored-By: Claude Opus 5.5 --- .gitignore | 1 + assistant/intent_bank.py | 214 +++++++++++++++++++++++- assistant/quick_answers.py | 321 ++++++++++++++++++++++++++++++++++++ tests/test_quick_answers.py | 125 ++++++++++++++ 4 files changed, 659 insertions(+), 2 deletions(-) create mode 100644 assistant/quick_answers.py create mode 100644 tests/test_quick_answers.py diff --git a/.gitignore b/.gitignore index f71f021..6999ac0 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ docs/16_FETCH_TASKS.md docs/17_MISSIONS.md notes/ data/intent_bank.npz +data/quick_answers.npz diff --git a/assistant/intent_bank.py b/assistant/intent_bank.py index 80dba89..cd275eb 100644 --- a/assistant/intent_bank.py +++ b/assistant/intent_bank.py @@ -72,7 +72,7 @@ REPEAT = re.compile(r"^\W*(?:(?:\w+\W+){0,2})?(?:again|one more time|once more|d # "again", "한 번만 더 해 줘": what again is the history's (driving.read, the LLM) SEVERAL = re.compile(r"\b(?", "please make your way over to ", "would you be so kind as to go to ", + "could you possibly head to ", "i'd appreciate it if you went to ", "you may go to now", + "go on over to ", "zip over to ", "pop over to ", "nip over to ", "dash over to ", + "go to , chop chop", "hop over to ", ", now please", + "robot, go to !", "go go go to ", "please go to robot", "go to pretty please", + "you go now please", "please moving to ", "go for ", "you must go ", + "go to place", "please go in ", "go at ", "please you moving ", " go please", + "go to asap", "head down to ", "make tracks to ", + "로 가 주세요 루미", "까지 가 보세요", " 쪽으로 가 봐", " 쪽으로 이동", "로 이동", + "로 가 보거라", "로 가거라", "로 가 보게", "로 가 주게", "로 가 주시오", + "로 가 주이소", "로 가 보이소", "로 퍼뜩 가라", "로 가 봐라", "로 가라 마", + "로 가 부러", "로 가 보랑께", "로 가 봐유", "로 가유", "로 가 줘유", + "로 가 주셔유", " 가 주라", "로 가 봐용", "로 가 줘용", "로 가쟈", + "로 출발하세요", "로 출발해 주세요", "로 향해", "로 향해 주세요", "로 이동하세요", + "로 이동 부탁해", "로 이동 부탁해요", "로 좀 가 주실래요?", "로 가 주실 수 있으세요?", + " 가 주세요", "에 가 주실래요?", "까지 이동해 주세요", "까지 가 주실래요?", + "로 가 줘라", "로 가 봐 얼른", "로 ㄱ", " ㄱㄱ", "로 무브 해 줘", + "로 go 해 주세요", "로 고 해 줘", "go to 해 주세요", " 로 이동 please", + "로 고우", "로 가 쥬", "로 가 즈", "로 가 저", "로 가 주새요", +] +COME += [ + "come here, robot!", "come over here, little robot", "robot come here please", "come here come here", + "pwease come here", "come to me robot", "come here quickly please", "c'mon over here", "c'mere", "come 'ere", + "get over here, buddy", "come over this way", "come over here to me", "come here a sec", "come closer please", + "would you kindly come here", "please come over to me", "kindly come here", "could you come closer to me", + "you come to me please", "you come near me", "please coming here", "come to here", "come at me here", + "come to this side", "please you come here", "come in front of me", "come stand in front of me", + "이리 오너라", "이리 와 보거라", "이리 와 보게", "이리 오게", "이리 오시게", "이리 와 보시오", "이리 와 주시오", + "일로 와 봐라", "이리 온나", "퍼뜩 온나", "이리 와 보이소", "이리 오이소", "이리 와 부러", "이리 와 보랑께", + "이리 와 봐유", "이리 와유", "여기로 와유", "이리 와 줘유", "이리 와 봐용", "이리 와 줘용", "이리 와 주라", + "여기로 좀 와 봐", "여기까지 와 봐", "여기까지 와 주세요", "제 앞으로 와 주세요", "내 앞으로 와", "가까이 와 주실래요?", + "가까이 좀 와 봐", "가까이 오세요", "가까이 오십시오", "더 가까이 와 줘", "조금 더 가까이 와 주세요", "이쪽으로 오세요", + "here 와", "come 해", "come 해 줘", "come here 해 주세요", "이리 와 please", "여기 와 줘 please", "컴 히어", + "이리 화", "이리 와 바", "여기로 와 쥬", "가까이 와 쥬", +] +FOLLOW += [ + "follow me, little robot", "robot follow me!", "follow me follow me", "come follow me", "follow me, okay?", + "kindly follow me", "please follow me this way", "would you kindly follow me", "please come along with me", + "follow me if you please", "you will follow me", "you follow behind me", "please you following me", + "following me", "follow to me", "follow me go", "you come with me together", "together with me go", + "stay close behind me", "walk along with me", "trail behind me", "shadow me", "stay on my tail", "keep on my heels", + "come along now", "this way, follow me", "follow me over here", "come with me, robot", "flolow me", "follow meee", + "나 따라오너라", "날 따라오게", "날 따라오시게", "나를 따라오시오", "따라오거라", "따라 온나", "퍼뜩 따라 온나", + "따라오이소", "날 따라와 부러", "따라와 잉", "따라와유", "따라와 줘유", "나 따라와 봐유", "따라와 줘용", "따라와 봐용", + "따라와 주라", "나 좀 따라와", "나 좀 따라와 줘", "저 좀 따라오세요", "저를 따라와 주세요", "저를 따라와 주십시오", + "제 뒤를 따라오세요", "내 뒤를 따라와", "내 뒤에 붙어", "나한테 붙어 와", "나랑 같이 가 줘", "나랑 같이 걸어", + "저랑 같이 가 주세요", "저와 같이 가 주실래요?", "함께 가 주세요", "follow 해 봐", "나 따라 come", "같이 go", + "with me 가자", "팔로우 미 해 줘", "따라와져", "따라 와 쥬", "따라오세여", +] +COME_BACK += [ + "come back to me", "come back now", "come on back", "come back please robot", "please return", "return now", + "go back to where you were before", "back to your old spot please", "go back to your starting place", + "please go back to the place you started", "kindly return to your spot", "you come back please", + "come back to before place", "go back first place", "return back", "come back here robot", + "돌아오너라", "돌아오게", "돌아와 보이소", "돌아온나", "퍼뜩 돌아온나", "돌아와 부러", "돌아와유", "돌아와 줘용", + "다시 돌아와 주세요", "원래 자리로 와", "원래 자리로 돌아와 주세요", "제자리로 와", + "처음 있던 데로 가", "아까 그 자리로 돌아가", "아까 있던 데로 돌아와", "원위치로 돌아가", "원위치 해", "원위치해 주세요", + "돌아가 주십시오", "복귀하십시오", "복귀해 줘", "come back 해", "돌아 come", "comeback 해 줘", "돌아와 주라", +] +MOVE += [ + "scooch forward", "scooch back", "budge up a bit", "move up a little forward", "inch back a bit", "nudge forward", + "nudge back a little", "shuffle left", "shuffle to the right", "back up some more space please", + "kindly move forward a little", "please step back a bit", "could you move back a little", "would you move left a bit", + "you go forward little", "you go back little", "go front little bit", "go little front", "move little left", + "move little bit right", "please moving back", "a little bit back please", + "forward forward", "back back", "move forward a tiny bit", "move a teeny bit to the left", + "move forward 50 centimeters", "move back 30 centimeters", "go left 1 meter", "go right 50 cm", + "앞으로 와", "앞으로 좀 와 봐", "앞으로 조금만 와", "조금 앞으로 와 줘", "뒤로 좀 가 봐", "뒤로 조금만", "뒤로 좀 물러나 봐", + "뒤로 빠져 줘", "뒤로 물러서", "뒤로 물러서 주세요", "옆으로 비켜", "왼쪽으로 좀 비켜 줘", "오른쪽으로 좀 비켜 주세요", + "왼쪽으로 살짝 가", "오른쪽으로 살짝 이동해", "앞으로 살짝", "뒤로 살짝", "앞으로 쪼끔 가", "뒤로 쪼끔만", + "앞으로 가 보거라", "뒤로 물러나게", "뒤로 물러나 보이소", "앞으로 가 보이소", "뒤로 쫌 가라", "앞으로 가 부러", + "뒤로 가 봐유", "앞으로 가유", "뒤로 가 줘용", "왼쪽으로 가 주이소", "오른쪽으로 가 봐유", + "앞으로 1미터만 가", "뒤로 30센티만 가 줘", "왼쪽으로 50센티 가 주세요", "오른쪽으로 1미터 이동하십시오", + "앞으로 이동하세요", "뒤로 이동하세요", "후진하세요", "후진해 주세요", "후진하십시오", + "앞으로 무브", "뒤로 무브", "back 좀 해 줘", "forward 해 줘", "레프트로 가", "라이트로 가", "백 해 줘", + "아프로 가", "뒤루 가", "뒤로 가조", "외쪽으로 가", +] +TURN += [ + "turn left please", "please turn to your left", "kindly turn right", "could you turn to the right", + "would you turn around please", "spin right", "spin left", "turn around robot", "turn round", + "go turn left", "you turn left", "you turn right please", "please turning left", "turn to left side", + "turn to right side", "turn back side", "turn your body around", "rotate around", "rotate yourself around", + "do a 180", "turn 180", "flip around", "swing around", "turn left a bit", "turn right a little", + "turn left 30 degrees please", "rotate 90 degrees left", "spin around once", + "왼쪽으로 돌아 봐", "오른쪽으로 돌아 봐", "뒤로 돌아 봐", "뒤로 돌아 줘", "돌아서", "뒤돌아서 봐", "한 바퀴 돌아 봐", + "한 바퀴 돌아 주세요", "빙글 돌아", "빙그르르 돌아 봐", "왼쪽으로 몸 돌려 주세요", "오른쪽으로 몸 좀 돌려", + "왼쪽으로 돌아 보거라", "오른쪽으로 돌아 보이소", "뒤로 돌아 보이소", "왼쪽으로 돌아 부러", "오른쪽으로 돌아 봐유", + "뒤로 돌아유", "한 바퀴 돌아 봐용", "왼쪽으로 돌아 주라", "오른쪽으로 회전하세요", "왼쪽으로 회전하세요", + "왼쪽으로 30도 돌아 주세요", "오른쪽으로 90도 회전해", "좌로 돌아", "우로 돌아", "뒤로 돌아 실시", + "턴 해", "유턴", "left turn 해 줘", "right turn 해", "turn around 해 줘", "한 바퀴 spin", "오른쪽으로 도라", +] +LOOK += [ + "look at me robot", "look at me, look at me", "look over here robot", "look here look here", "look look", + "kindly look at me", "would you look at me please", "please look this way", "could you look to the left", + "you look at me", "look to me", "look on me", + "please look up", "look up please", "look down please", "look left please", "look right please", + "peek to the left", "peek right", "glance over here", "look straight at me", "keep your eyes on me", + "eyes on me please", "turn your face to me", "face this way", "look the front", "look front", + "날 좀 보거라", "나를 보게", "여길 보게", "여기 보이소", "여 보이소", "이짝 봐", "이짝 보랑께", "날 봐 부러", "여기 봐유", + "나 좀 봐유", "여기 봐 줘용", "날 봐 주라", "저 좀 보세요", "여기 보세요", "이쪽 보세요", "앞에 보세요", "위에 보세요", + "아래 보세요", "왼쪽 보세요", "오른쪽 보세요", "위로 봐", "아래로 봐", "위쪽 좀 봐 줘", "아래쪽 좀 봐 주세요", + "고개 들어 보세요", "고개 숙여 봐", "고개 왼쪽으로 돌려 주세요", "고개 오른쪽으로 돌려 주세요", "고개 위로", + "고개 아래로", "고개 똑바로", "고개 똑바로 해", "앞 봐", "앞에 봐 줘", "정면 보세요", "저 쳐다봐 주세요", "날 쳐다봐 줘", + "날 봐 please", "look 나", "lookat me", "luk at me", "look et me", "날 바", "여기 바", +] +LIFT += [ + "get taller please", "be taller", "be tall", "be shorter", "grow up tall", "make yourself bigger", + "make yourself higher please", "go up up", "up up up", "down down", "go down a little bit", "go up a little bit", + "lower yourself a bit please", "raise yourself a bit", "come down lower", "move your body up", "move your body down", + "you go up please", "you go down", "body up", "body down", "make body up", "make body down", "you more high", + "you more low", "lift yourself higher", "lower yourself down", "drop a little lower", + "올라가 봐", "조금 올라가 봐", "더 올라가", "더 내려가", "조금만 내려가", "조금만 올라가", "위로 올라가 봐", + "아래로 내려와", "내려와", "내려와 봐", "올라와", "키 높여 봐", "키 낮춰 봐", "키 좀 높여 줄래?", "키 좀 낮춰 줄래요?", + "몸 높여", "몸 낮춰 봐", "몸을 높여 주세요", "몸 좀 내려 주세요", "높이 높여", "높이 낮춰", "높이 좀 올려 주세요", + "높이 내려 주세요", "키 크게 해 줘", "키 작게 해 줘", "키 높이세요", "키를 낮추십시오", + "올라가 보거라", "내려가 보게", "올라가 보이소", "내려가 보이소", "올라가 부러", "내려가 봐유", "올라가유", "키 높여 줘용", + "키 up 해 줘", "몸 up", "높이 up", "높이 down", "업 해 줘", "다운 해 줘", "키 업", "키 다운", "오라가", "내려가조", +] +WAVE += [ + "wave to me please", "wave at me robot", "wave wave wave", "robot wave!", "wave bye bye", "bye bye wave", + "wave hi to me", "wave hello to us", "give everyone a wave", "kindly wave to us", "would you wave to us please", + "please wave your hand to me", "you wave hand please", "hand wave please", "do hand wave", + "do wave hand", "hello with hand please", "say bye with your hand", "say goodbye with your hand", + "wave goodbye", "wave goodbye to me", "wave to the camera", "wave to my mom", "wave to my kid", "wave to the crowd", + "give a little wave", "do a little wave", "waive at me", "wave too me", "wave to us all", + "손 흔들어 보거라", "손 흔들어 보게", "손 좀 흔들어 보이소", "손 흔들어 부러", "손 흔들어 봐유", "손 흔들어 줘유", + "손 흔들어 줘용", "손 흔들어 주라", "손 흔들어 주시겠어요?", "손 흔들어 주실래요", "손 흔들어 주시오", + "손 흔들어 인사해 주세요", "손 흔들면서 인사해 주세요", "손 흔들어서 인사해 봐", "손 흔들어 인사해 봐", + "바이바이 해 줘", "빠이빠이 해 줘", "빠이빠이 해 봐", "안녕 손 흔들어 줘", "손으로 안녕 해 봐", "손으로 바이바이 해", + "우리 애한테 손 흔들어 주세요", "엄마한테 손 흔들어 줘", "할머니한테 손 흔들어 드려", "카메라 보고 손 흔들어", + "손 흔들어 봐 줘", "손 한번 흔들어 주세요", "팔 한번 흔들어 봐", "wave 해 주세요", "wave 좀 해 봐", "웨이브 해 봐", + "손 wave 해 줘", "hand wave 해 줘", "바이 해 손으로", "손 흔더러", "손 흔드러 줘", "손 흔들어 쥬", +] +ARM_REACH += [ + "reach out please", "reach out to me please", "kindly reach out your arm", "would you reach out your hand", + "please stretch out your arm", "hold your arm out", "hold your hand out to me", "hand out please", + "put your hand forward", "push your arm out", "arm forward", "arm forward please", "your arm, stretch it out", + "you stretch arm please", "you put arm out", "arm long please", "make arm long", "arm straight please", + "reach reach", "gimme your hand", "give your hand to me", + "팔 뻗어 보거라", "팔 뻗어 보게", "팔 좀 뻗어 보이소", "팔 뻗어 부러", "팔 뻗어 봐유", "팔 뻗어 줘용", "팔 뻗어 주라", + "팔 좀 뻗어 주세요", "팔 쭉 뻗어 주세요", "팔 앞으로 뻗어 주세요", "팔 앞으로 내밀어 주세요", "손 내밀어 주세요", + "손 좀 내밀어 줄래?", "손 앞으로 뻗어", "손 쭉 뻗어 봐", "팔 펴 봐", "팔 펴 주세요", "팔을 펴 주십시오", + "손 줘", "팔 쭉 펴 봐", "팔 길게 뻗어", "arm 펴 줘", "arm out 해 줘", + "팔 out", "손 reach", "팔 뻗어조", "팔 버더", +] +ARM_FOLD += [ + "fold your arm please", "kindly fold your arm", "please put your arm away", "put the arm down please", + "arm down please", "bring your arm back in", "pull your arm back", "take back your arm", + "you fold arm", "arm close please", "arm fold please", "put arm back", "arm go back", "arm rest", + "relax your arm now", "you can put your arm down", "rest your arm now", "lower the arm", + "팔 접어 보거라", "팔 접어 보이소", "팔 접어 부러", "팔 접어 봐유", "팔 접어 줘용", "팔 접어 주라", "팔 좀 접어 주세요", + "팔 거둬 주세요", "팔 넣어 주세요", "팔 내려 주세요", "팔 내려 줘", "팔 내려 봐", "팔 원위치 해 줘", "팔 제자리에 놔", + "팔 다시 접어 주세요", "팔 쉬어", "팔 내려놓으세요", "팔 내리십시오", "팔 접으세요", "팔 접으십시오", "팔 fold 해 줘", + "arm 내려", "arm down 해", "팔 접어조", "팔 저버", +] +ARM_OPEN += [ + "open hand", "open your hand please", "please open your fingers", "open the hand", "hand open", + "open your grip", "release your grip", "let go of your grip", "you open hand", "fingers open", + "손 펴 봐 줘", "손 좀 펴", "손 벌려 봐", "손 좀 벌려 주세요", "손가락 좀 펴 봐", "손 펴 보거라", "손 펴 보이소", + "손 펴 봐유", "손 펴 줘용", "손 열어 주세요", "그리퍼 열어 줘", "그리퍼 좀 열어 봐", "집게 열어", "집게 벌려", + "손 펴세요", "손 펴십시오", "손 오픈", "그리퍼 오픈", "open 해 손", "손 펴조", +] +ARM_CLOSE += [ + "close hand", "close your hand please", "please close your fingers", "close the hand", "hand close", + "close your grip", "tighten your grip", "make a fist please", "you close hand", "fingers close", + "손 쥐어 봐", "손 꽉 쥐어 봐", "주먹 쥐어 줘", "주먹 꽉 쥐어", "손 오므려 봐", "손 오므려 주세요", "손가락 좀 오므려", + "손 쥐어 보거라", "주먹 쥐어 보이소", "손 쥐어 봐유", "주먹 쥐어 줘용", "손 닫아 주세요", "그리퍼 닫아 줘", + "그리퍼 좀 닫아 봐", "집게 닫아", "집게 오므려", "손 쥐세요", "주먹 쥐십시오", "손 클로즈", "그리퍼 클로즈", "주먹 쥐어조", +] +PICK += [ + "pick up the please", "please pick up the ", "kindly pick up the ", "would you pick up the ", + "could you take the please", "please grab the ", "grab the please", "get the please", + "pick the ", "pick up", "you pick up ", "you take please", "please picking the ", + "take up the ", "grab hold of the ", "seize the ", "nab the ", "pick up that there", + "grab the on the table", "take the off the table", "pick that up", "pick up the robot", + "pickup the ", "pik up the ", "pick up da ", "grabb the ", + " 집어 보거라", " 집어 보이소", " 집어 부러", " 집어 봐유", " 집어 줘용", " 집어 주라", + " 좀 집어", " 좀 집어 줘", " 좀 집어 주세요", " 집어 볼래?", " 잡아 봐", " 좀 잡아", + " 쥐어", " 집으십시오", " 들어 올려 주세요", " 집어 올려 주세요", "그 집어 봐", + "저기 집어", " 하나 집어 주세요", " 잡아 주실래요?", " 집어 주실 수 있어요?", + " 픽업", " 그랩 해", " grab", " 잡아조", " 지버", +] +FETCH += [ + "bring me the please", "please bring me a ", "kindly bring me the ", "would you bring me the ", + "could you fetch me the ", "go and get me the ", "get the for me", "fetch me the please", + "bring the over here", "bring the over to me", "bring a to me", "carry the to me", + "you bring me ", "you bring please", "bring to me", "bring me please", "bring here the ", + "go fetch the ", "go grab me a ", "grab me a ", "grab me the ", "fetch ", "brung me the ", + "bring mi the ", " please bring", + " 가져와 봐", " 가져다 줄래?", " 갖다 줄래요?", " 좀 가져다 줘", " 좀 가져와 줘", + " 가져와 주세요", " 갖다 주실래요?", " 가져다 주시겠어요?", " 가져오십시오", " 갖다 주십시오", + " 가져오거라", " 갖다 주게", " 가 온나", " 퍼뜩 가 온나", " 가져와 보이소", " 갖다 주이소", + " 가져와 부러", " 갖다 줘 잉", " 가져와유", " 갖다 줘유", " 가져와 줘용", " 갖다 주라", + " 챙겨 와", " 챙겨 와 줘", " 좀 챙겨다 줘", "나한테 갖다 줘", "저한테 좀 가져다 주세요", + " 여기로 갖다 줘", " 이리 가져와", " 가지고 와 주세요", " 가져와 줄 수 있어?", + " 브링 해 줘", " 갖고 와 please", " fetch 해", " 가저다 줘", " 가져와조", +] +NO += [ + "my robot at home follows me", "my dog follows me everywhere", "the kids waved at you", "you waved so nicely", + "i like how you turn", "your arm reaches far", "can you reach that high?", "do you pick things up often?", + "is your hand strong?", "how many cups can you hold?", "can it bring me coffee?", "does it come when called?", + "우리 집 강아지는 날 따라와", "애들이 손 흔들었어", "팔 진짜 길다", "손 힘 세?", "컵 몇 개 들 수 있어?", + "커피도 가져다 줄 수 있나?", "부르면 오나?", "로봇이 날 따라왔어", "손 흔드는 거 귀엽다", "고개 돌리는 거 신기해", + "bring your own cup", "bring it home", "come as you are", "come to think of it", "look at that", "look at this", + "look at them", "follow the money", "turn the page", "pick your battles", "fetch the ball, boy", + "그거 봐 봐", "다시 출발해", "다시 출발해 주세요", "can you see what's on your right?", "what do you see on your left?", "see anything up there?", "오른쪽에 뭐 보여?", "위에 뭐 있어?", "다시 가", "다시 가 봐", "저거 봐", "저것 좀 봐", "이것 좀 봐", "얘들아 저거 봐", "바이바이", "빠이빠이", "잘 가", "안녕히 가세요", +] KINDS = {"go_to": GO, "come": COME, "follow": FOLLOW, "come_back": COME_BACK, "move": MOVE, "turn": TURN, "look": LOOK, "lift": LIFT, "wave": WAVE, "arm_reach": ARM_REACH, "arm_fold": ARM_FOLD, "arm_open": ARM_OPEN, "arm_close": ARM_CLOSE, "pick": PICK, "put": PUT, "fetch": FETCH, "receive": RECEIVE, "give": GIVE, "no": NO} @@ -674,7 +883,8 @@ def _number(words): def said_amount(text): """(metres, degrees) said with a unit, numbers in digits or words ("a quarter of a meter", "eight centimetres", "오십 센티", "a hundred and eighty degrees", "삼십 도"); each None when not said.""" - t = (text or "").lower() + from assistant import wording + t = wording.numbers(re.sub(r"\b(?:a )?quarter of an? (?:meter|metre)\b", "0.25 m", " " + (text or "").lower() + " ")) # "사 십오 도", "마흔다섯 도", "일 점 오 미터" as digits metres = degrees = None if re.search(r"\bquarter of an? (?:meter|metre)\b", t): metres = 0.25 diff --git a/assistant/quick_answers.py b/assistant/quick_answers.py new file mode 100644 index 0000000..35aa06d --- /dev/null +++ b/assistant/quick_answers.py @@ -0,0 +1,321 @@ +"""Quick answers: frequent standalone questions about Lumi (name, age, who made it, height, battery life, languages, +AI model, robot or alive, hello) answered at once, without the LLM (lumi.Lumi._answer, after the rules, seeing and +status and before the LLM). + +The question is matched by meaning with the embedding server (assistant/knowledge.embed, as assistant/intent_bank.py): +close enough to one kind and far enough from every other kind and from the "no" wordings (camera questions, commands, +company facts, follow-ups) -> one of that kind's answers. Every answer is a fact of knowledge/lumi_about_en.md or +brain.SYSTEM; keep them in step. Only a question of its own: in a talk it must name Lumi ("you", "너", "루미"), and a +fragment ("why?", "really?", "and you?", "how old?") always goes to the LLM, which has the talk before. +"What can you do?" and the battery level now are assistant/abilities.py's and assistant/battery.py's; "thanks" has +two meanings (understood / goodbye) and stays with the LLM. + + .venv/bin/python assistant/quick_answers.py "who made you?" # the kind, the answer and the closest wordings +""" +import hashlib +import pathlib +import random +import re +import sys + +import numpy as np + +ROOT = pathlib.Path(__file__).resolve().parents[1] +CACHE = ROOT / "data" / "quick_answers.npz" +SIM_MIN = 0.86 # the closest wording must be at least this similar (bge-m3 cosine) ... +MARGIN = 0.05 # ... and this much closer than the closest wording of any other kind (the "no" kind too) +MAX_WORDS = 12 # a longer sentence is a story or several questions: the LLM + +# kind: (wordings, {"en": [answers], "ko": [answers]}) +KINDS = { + "name": ([ + "what's your name", "what is your name", "your name?", "what are you called", "what do they call you", + "do you have a name", "tell me your name", "may i know your name", "what should i call you", "whats ur name", + "wat is your name", "what's your name, robot", "name please", "what is the robot's name", + "이름이 뭐야", "이름이 뭐예요", "이름이 어떻게 돼요", "너 이름 뭐야", "성함이 어떻게 되세요", "이름 알려 줘", "이름이 뭡니까", + "넌 이름이 뭐니", "이름 있어요", "뭐라고 부르면 돼요", "니 이름 머야", "너 이름이 뭐꼬", "이름이 뭐당가", "네임이 뭐야", + "your name 뭐야", "이 로봇 이름이 뭐예요", + ], {"en": ["I'm Lumi.", "My name is Lumi.", "Lumi. Nice to meet you."], + "ko": ["저는 루미예요.", "제 이름은 루미예요.", "루미라고 해요. 반가워요."]}), + "name_meaning": ([ + "what does your name mean", "why are you called lumi", "where does the name lumi come from", "what does lumi mean", + "meaning of your name", "why lumi", "who named you lumi", "루미가 무슨 뜻이야", "이름이 무슨 뜻이에요", "왜 이름이 루미예요", + "루미라는 이름은 어디서 왔어요", "루미 뜻이 뭐야", "이름 의미가 뭐예요", + ], {"en": ["My name comes from Lux, Latin for light, and mini, small and agile.", + "Lumi is Lux, the Latin word for light, plus mini, for small and agile."], + "ko": ["빛을 뜻하는 라틴어 룩스와, 작고 날렵하다는 미니에서 온 이름이에요.", + "제 이름은 라틴어로 빛이라는 룩스와 작고 날렵하다는 미니를 합친 거예요."]}), + "who": ([ + "who are you", "who are you?", "what are you", "what are you exactly", "introduce yourself", "tell me about yourself", + "what kind of robot are you", "what is this robot", "what's this robot", "who is this robot", "what are you for", + "what is your job", "what do you do here", "who r u", "hoo are you", "what is lumi", "who is lumi", + "누구야", "넌 누구니", "누구세요", "당신은 누구예요", "너 뭐야", "자기소개 해 줘", "자기소개 좀 해 주세요", "소개해 주세요", + "어떤 로봇이에요", "이 로봇은 뭐예요", "이건 무슨 로봇이야", "루미가 뭐야", "니 누고", "누구당가", "넌 뭐 하는 애야", + "여기서 뭐 하는 로봇이에요", "who are you 너", "넌 who야", + ], {"en": ["I'm Lumi, a mobile robot assistant developed by Cutshion Company.", + "I'm Lumi, a robot assistant made by Cutshion Company. I can talk, see, drive around and use my arm.", + "My name is Lumi. I'm a mobile robot assistant from Cutshion Company."], + "ko": ["저는 루미예요. 쿳션이 개발한 모바일 로봇 어시스턴트예요.", + "저는 쿳션이 만든 로봇 어시스턴트 루미예요. 대화하고, 보고, 움직이고, 팔도 쓸 수 있어요.", + "루미라고 해요. 쿳션에서 개발한 모바일 로봇이에요."]}), + "age": ([ + "how old are you", "what is your age", "what's your age", "how old r u", "how old is lumi", "when were you born", + "when were you made", "when were you built", "how old is this robot", "are you old", "are you new", "your age?", + "how many years old are you", "hau old are you", + "몇 살이야", "몇 살이에요", "나이가 어떻게 돼요", "너 몇 살", "나이가 몇이야", "연세가 어떻게 되세요", "언제 태어났어", + "언제 만들어졌어요", "이 로봇 몇 살이에요", "몇 살인교", "멫 살이여", "몇살", "나이 몇 살이야", "니 몇 살이고", + "how old 너", "너 age가 몇이야", + ], {"en": ["I'm 2 years old.", "I'm two years old.", "Two years old!"], + "ko": ["저는 두 살이에요.", "두 살이에요.", "올해 두 살이에요."]}), + "maker": ([ + "who made you", "who built you", "who created you", "who developed you", "who designed you", "who is your maker", + "who programmed you", "which company made you", "what company made you", "what company are you from", + "where are you from", "where do you come from", "who owns you", "who do you belong to", "who's your creator", + "who mad you", "whoo made you", "made by who", "which company built this robot", "who makes this robot", + "누가 만들었어", "누가 만들었어요", "누가 개발했어요", "누가 널 만들었어", "어느 회사에서 만들었어요", "어디서 만들었어요", + "어느 회사 로봇이에요", "어디 회사 로봇이야", "만든 사람이 누구예요", "제작사가 어디예요", "어디서 왔어", "어디서 왔어요", + "너 어디 소속이야", "누가 맹글었노", "누가 만들었당가", "who made 너", "누가 made 했어", + ], {"en": ["I was developed by Cutshion Company.", + "Cutshion Company made me. It's a robot company in Seoul.", + "I'm from Cutshion Company, a Korean robot company in Seoul."], + "ko": ["쿳션이 저를 개발했어요.", "주식회사 쿳션에서 만들었어요. 서울에 있는 로봇 회사예요.", + "저는 쿳션이라는 한국 로봇 회사에서 왔어요."]}), + "height": ([ + "how tall are you", "what's your height", "what is your height", "how tall is lumi", "how tall is this robot", + "how high are you", "your height?", "hau tall are you", "how tall r u", "how tall can you get", + "how tall are you in centimeters", + "키가 몇이야", "키가 몇이에요", "키 얼마야", "키가 얼마나 돼요", "너 키 몇이야", "키 몇 센티예요", "이 로봇 키가 얼마예요", + "키가 몇 센치고", "키 얼마나 크노", "얼마나 커요", "키 몇이에요", "your 키 몇이야", + ], {"en": ["I'm 146 cm tall, and with my lift I can go up to 186 cm.", + "146 centimetres. My lifting column can raise me by 40 cm, to 186 cm.", + "I'm 146 cm tall; I can stretch up to 186 cm with my lift."], + "ko": ["키는 146cm이고, 리프트로 186cm까지 올라가요.", "146센티미터예요. 리프트로 40cm 더 올라가서 186cm까지 돼요.", + "저는 146cm예요. 리프트를 올리면 186cm까지 커져요."]}), + "weight": ([ + "how heavy are you", "how much do you weigh", "what's your weight", "what is your weight", "how heavy is lumi", + "how heavy is this robot", "are you heavy", + "몸무게가 몇이야", "몸무게 얼마예요", "무게가 얼마나 돼요", "너 몇 킬로야", "몇 키로예요", "얼마나 무거워요", "이 로봇 무게가 얼마예요", + ], {"en": ["I weigh about 96 kg.", "About 96 kilograms; my wheeled base alone is 50 kg."], + "ko": ["저는 약 96kg이에요.", "무게는 약 96킬로그램이에요. 베이스만 50kg이에요."]}), + "battery_life": ([ + "how long does your battery last", "how long can you run", "how long can you work on one charge", + "how many hours does your battery last", "what's your battery life", "how long do you last on a charge", + "how long can you go without charging", "battery life?", "how long can you work", + "배터리 얼마나 가요", "배터리 몇 시간 가", "한 번 충전하면 얼마나 써요", "배터리 수명이 얼마나 돼요", "몇 시간 일할 수 있어요", + "충전 한 번에 몇 시간 가요", "배터리 오래 가요", "배터리 얼마나 버텨", + ], {"en": ["My battery lasts about 10 hours.", "About 10 hours on one charge.", + "Around 10 hours: I have a 24-volt, 45 Ah lithium-ion battery."], + "ko": ["배터리는 약 10시간 가요.", "한 번 충전하면 약 10시간 일할 수 있어요.", "약 10시간이에요. 24볼트 45Ah 리튬이온 배터리예요."]}), + "languages": ([ + "what languages do you speak", "what languages can you speak", "which languages do you understand", + "do you speak english", "do you speak korean", "can you speak korean", "can you speak english", + "can you speak chinese", "do you speak japanese", "can you speak other languages", "what language do you speak", + "how many languages do you speak", "do you understand english", + "무슨 언어 할 수 있어", "어떤 언어 해요", "영어 할 줄 알아", "한국어 할 수 있어요", "몇 개 국어 해요", "중국어 할 줄 알아요", + "일본어 할 수 있어", "영어도 돼요", "한국말 알아들어요", "외국어 할 줄 알아", "english 할 줄 알아", "korean 할 수 있어", + ], {"en": ["I understand and speak English and Korean.", "English and Korean. I answer in the language you use.", + "I speak English and Korean; other languages I don't understand yet."], + "ko": ["영어와 한국어를 이해하고 말할 수 있어요.", "영어와 한국어요. 말씀하시는 언어로 대답해요.", + "영어랑 한국어를 해요. 다른 언어는 아직 이해하지 못해요."]}), + "chatgpt": ([ + "are you chatgpt", "do you use chatgpt", "are you connected to the cloud", "do you use the internet to think", + "is this chatgpt", "are you using gpt", "you are chatgpt?", "챗gpt 써요", "챗지피티야", "gpt 쓰는 거야", "너 챗GPT 써", + "클라우드에 연결돼 있어요", "챗gpt랑 연결돼 있어", + ], {"en": ["No, I don't use ChatGPT or the cloud. I answer with Gemma 4, made by Google, on my own NVIDIA Jetson Thor.", + "No. My language model is Gemma 4 by Google, and it runs on my own computer, not in the cloud."], + "ko": ["아니요, 챗GPT나 클라우드는 쓰지 않아요. 구글이 만든 젬마 4로 제 젯슨 토르에서 직접 대답해요.", + "아니요. 제 언어 모델은 구글의 젬마 4이고, 클라우드가 아니라 제 컴퓨터에서 돌아가요."]}), + "model": ([ + "what ai do you use", "what model do you use", "which language model are you", + "what is your ai model", "what's your brain", "what ai are you", "what llm do you run", + "무슨 ai 써요", "어떤 모델 써요", "언어 모델이 뭐예요", "인공지능 뭐 써", "ai 모델이 뭐야", + ], {"en": ["I answer with Gemma 4, a language model made by Google, running on my own NVIDIA Jetson Thor.", + "My language model is Gemma 4 by Google, and I understand speech with Whisper; both run on my own computer, without the cloud."], + "ko": ["구글이 만든 언어 모델 젬마 4로 대답해요. 제 안의 엔비디아 젯슨 토르에서 돌아가요.", + "제 언어 모델은 구글의 젬마 4이고, 음성 인식은 위스퍼예요. 둘 다 클라우드 없이 제 컴퓨터에서 돌아가요."]}), + "robot": ([ + "are you a robot", "are you human", "are you alive", "are you real", "are you an ai", "are you a person", + "is there a person inside", "is someone controlling you", "do you have feelings", "do you have emotions", + "are you conscious", "is this a real robot", "are you a machine", + "너 로봇이야", "로봇이에요", "사람이야", "살아 있어", "진짜 로봇이에요", "안에 사람 있어요", "누가 조종해요", "감정 있어", + "감정이 있어요", "인공지능이야", "ai야", "기계예요", "의식 있어요", + ], {"en": ["I'm a robot, not a living being: I understand speech and answer with AI running on my own computer.", + "I'm a robot, not alive. I have no feelings or consciousness; my friendliness is how I was made to talk."], + "ko": ["저는 로봇이에요. 살아 있는 건 아니고, 제 컴퓨터에서 돌아가는 AI로 말을 알아듣고 대답해요.", + "저는 로봇이에요. 감정이나 의식은 없고, 친절하게 말하도록 만들어졌어요."]}), + "speed": ([ + "how fast can you go", "how fast do you move", "what's your speed", "what is your top speed", "how fast are you", + "how quick can you drive", "what's your max speed", + "얼마나 빨라요", "속도가 얼마예요", "얼마나 빨리 가요", "최고 속도가 몇이야", "몇 키로로 달려요", "속도 얼마나 나와", + ], {"en": ["I normally drive at 0.6 metres per second, at most 1.2.", + "0.6 m per second normally, up to 1.2 m per second."], + "ko": ["보통 초속 0.6m로 가고, 최대 초속 1.2m예요.", "평소엔 초속 0.6미터, 가장 빠르면 초속 1.2미터예요."]}), + "hello": ([ + "hello", "hi", "hi there", "hello lumi", "hi lumi", "hey there", "good morning", "good afternoon", "good evening", + "nice to meet you", "hello robot", "howdy", "yo", "hiya", "helo", "hallo", + "안녕", "안녕하세요", "루미 안녕하세요", "반가워", "반가워요", "만나서 반가워요", "처음 뵙겠습니다", "좋은 아침이에요", "하이", + "헬로", "안뇽", "안녕하십니까", "하이 루미", + ], {"en": ["Hello! Nice to meet you.", "Hi there!", "Hello! I'm Lumi."], + "ko": ["안녕하세요! 반가워요.", "안녕하세요!", "안녕하세요, 저는 루미예요."]}), + "how_are_you": ([ + "how are you", "how are you doing", "how's it going", "how are you today", "are you okay", "how do you feel", + "what's up", "how have you been", + "잘 지내", "잘 지냈어요", "기분 어때", "오늘 기분 어때요", "괜찮아요", "요즘 어때", "어떻게 지내요", + ], {"en": ["I'm a robot, so I have no feelings, but everything is running fine. Thanks for asking!", + "All good here: as a robot I don't feel things, but my systems are running well."], + "ko": ["저는 로봇이라 감정은 없지만, 다 잘 돌아가고 있어요. 물어봐 주셔서 고마워요!", + "로봇이라 기분은 없지만, 아주 잘 돌아가고 있어요."]}), +} + +NO = [ + # the cameras: assistant/seeing.py's or the LLM's + "can you see me", "do you see me", "what do you see", "what am i holding", "what am i wearing", "how many people do you see", + "what colour is my shirt", "how old do i look", "how tall am i", "who am i", "do you know me", "do you remember me", + "what's in front of you", "can you see the cup", "is there someone behind me", "how old am i", + "나 보여", "내가 보여요", "뭐 보여", "내 옷 무슨 색이야", "나 몇 살 같아", "내 키 몇이야", "나 누군지 알아", "앞에 뭐 있어", + "사람 몇 명 보여", "카메라로 뭐 보여요", + # commands and requests + "come here", "follow me", "wave", "wave at me", "go to the stage", "sing a song", "dance for me", "turn around", + "look at me", "tell me a joke", "say hello to my son", "introduce me to cutshion", "take a picture", + "이리 와", "따라와", "손 흔들어 줘", "노래 불러 줘", "춤 춰 봐", "농담 해 줘", "우리 애한테 인사해 줘", + # abilities: the LLM (or abilities.py) + "what can you do", "can you dance", "can you fly", "can you climb stairs", "can you lift 5 kg", "how much can you lift", + "how far can you reach", "can you open doors", "can you pick up a cup", "how long is your arm", "can you grow taller", + "뭐 할 수 있어", "춤 출 수 있어", "계단 올라갈 수 있어", "몇 킬로까지 들 수 있어", "팔 길이가 얼마야", "문 열 수 있어", + # the company and other things, not Lumi + "what is cutshion", "tell me about cutshion", "how old is cutshion", "when was cutshion founded", "how old is the company", + "how many people work at cutshion", "how many employees does the company have", "who is the ceo", "where is the company", + "how much do you cost", "what's your price", "how long does charging take", "how much battery is left", + "who made the barista robot", "who made your arm", "who made your gripper", "how tall is your arm", + "how heavy is your arm", "how heavy can the items be", "how heavy a thing can you hold", "how heavy can things be", + "얼마나 무거운 거 들 수 있어", "물건 무게는 얼마까지 돼요", "what's the name of the ceo", "what's the company's name", "what's this event called", + "what's the name of this place", "what is this booth", "who made this booth", + "쿳션은 뭐 하는 회사야", "회사 몇 년 됐어요", "직원이 몇 명이에요", "대표가 누구예요", "회사 어디 있어요", "얼마예요", "가격이 얼마예요", + "충전 얼마나 걸려요", "배터리 몇 퍼센트 남았어", "팔은 누가 만들었어요", "그리퍼 무게가 얼마예요", "이 행사 이름이 뭐예요", + "여기가 어디예요", "대표 이름이 뭐예요", "너 얼마야", "how much are you", "is cutshion an american company", + "로봇 미국 회사 맞아요", "중국 회사예요", "is your company chinese", + # follow-ups and fragments: the LLM with the talk before + "why", "really", "and you", "how come", "are you sure", "what about you", "and the arm", "who", "what do you mean", "tell me more", "which one", "why lumi?", "seriously?", + "왜", "진짜", "너는", "그럼 너는", "확실해", "팔은요", "누가", "무슨 뜻이야", "더 알려 줘", + # praise and remarks: the LLM + "you're cool", "you look cute", "you're so tall", "nice robot", "what a cool robot", "you're amazing", "i like you", + "로봇 정말 멋있어요", "귀엽다", "멋있다", "키 크다", "로봇 신기하네요", "너 좋아", "대단하다", + # the weather, the time, closings + "what's the weather", "what time is it", "what day is it", "thanks", "thank you", "bye", "okay", "i see", + "날씨 어때", "지금 몇 시야", "고마워", "감사합니다", "잘 가", "알겠어요", "그렇구나", +] + +# never by meaning: the cameras, the visitor about themselves, a doubt or a fragment of the talk before +CAMERA = re.compile(r"\b(?:see|seeing|saw|look(?:s|ing)?|watch|camera|wearing|holding|in front of|behind|colou?r|" + r"recogni[sz]e|remember)\b|보여|보이|보니|봐|봤|입었|들고|색|카메라|앞에|뒤에|알아봐|기억", re.I) +ABOUT_ME = re.compile(r"\b(?:i|i'm|am i|my|me|mine)\b|(?:^|\s)(?:나|내|제|저|난|전)(?:는|가|를|의)?\s", re.I) +FRAGMENT = re.compile(r"^\W*(?:and|so|but|then|or|also|why|really|seriously|wait|what about|how about|how come|are you sure)\b|" + r"^\W*(?:그럼|그러면|그리고|근데|그런데|그래서|아니|왜|진짜|정말|확실|설마|또)|" + r"\b(?:that|it|they|them|there|this one|the arm|your arm)\b|그거|그건|거기|그분|그 회사|걔", re.I) +OTHER = re.compile(r"\b(?:lift|carry|hold|items?|things?|stuff|price|cost)\b|들 ?수|들어|물건|얼마야|얼마예요|" + r"맞(?:아|지|죠|나|습니까)|아니(?:야|에요|죠)", re.I) # what it can hold, the price, a check: the LLM +SEVERAL = re.compile(r"\band\b|그리고|[??].+\S|하고\s|랑\s", re.I) +NAMES_LUMI = re.compile(r"\b(?:you|your|yourself|u|ur|lumi)\b|(?:^|\s)(?:너|넌|니|네|당신|루미|본인|자기)", re.I) + +_bank = None + + +def examples(): + """[(text, kind)] of every wording.""" + return [(t, k) for k, (texts, _) in KINDS.items() for t in texts] + [(t, "no") for t in NO] + + +def _load(): + """(vectors, kinds): from data/quick_answers.npz when it holds these very wordings, else embedded now.""" + global _bank + if _bank is None: + from assistant import knowledge + ex = examples() + key = hashlib.sha1("\n".join(f"{t}\t{k}" for t, k in ex).encode()).hexdigest() + if CACHE.exists(): + z = np.load(CACHE) + if str(z["key"]) == key: + _bank = (z["vecs"], z["kinds"]) + return _bank + vecs = knowledge.embed([t for t, _ in ex]) + kinds = np.array([k for _, k in ex]) + np.savez(CACHE, vecs=vecs, kinds=kinds, key=key) + _bank = (vecs, kinds) + return _bank + + +def _core(text): + from assistant import brain + t = brain.CALLING.sub("", text or "").strip() + t = re.sub(r"[\s,]*(?:lumi|루미야|루미)?[\s,.!?~]*$", "", t, flags=re.I).strip() + return t or (text or "").strip(" ,.!?~") + + +def guarded(text, history=()): + """Why these words are not a quick answer's (the LLM's or another reader's), or None.""" + t = (text or "").strip() + if not t or len(t.split()) > MAX_WORDS: + return "length" + if CAMERA.search(t): + return "camera" + if ABOUT_ME.search(t): + return "about the visitor" + if FRAGMENT.search(t): + return "fragment" + if SEVERAL.search(t): + return "several" + if OTHER.search(t): + return "other" + if history and not NAMES_LUMI.search(t): + return "in a talk, not naming Lumi" # "how old?" / "몇 살이에요?" after the company: about that + return None + + +def kind_of(text, history=()): + """The kind of question, when sure; else None.""" + if guarded(text, history): + return None + from assistant import knowledge + vecs, kinds = _load() + try: + q = knowledge.embed([_core(text)])[0] + except OSError as e: # no embedding server: the LLM answers + print(f"quick answers: {e}") + return None + sims = vecs @ q + top = int(np.argmax(sims)) + best = str(kinds[top]) + if best == "no" or sims[top] < SIM_MIN or sims[top] - sims[kinds != best].max() < MARGIN: + return None + if best == "hello" and history: + return None # hello in the middle of a talk: the LLM + return best + + +_last = {} + + +def answer(text, lang="en", history=()): + """The spoken answer when `text` is a standalone question this module answers, else None. Never the same line + twice in a row for a kind.""" + kind = kind_of(text, history) + if kind is None: + return None + lines = KINDS[kind][1]["ko" if lang == "ko" else "en"] + choices = [x for x in lines if x != _last.get(kind)] or lines + _last[kind] = random.choice(choices) + return _last[kind] + + +if __name__ == "__main__": + import time + for said in sys.argv[1:]: + t0 = time.time() + got = answer(said, "ko" if re.search(r"[가-힣]", said) else "en") + print(f"{said} | guard: {guarded(said)} | kind: {kind_of(said)} | {got} ({time.time() - t0:.3f} s)") + from assistant import knowledge + vecs, kinds = _load() + sims = vecs @ knowledge.embed([_core(said)])[0] + texts = [t for t, _ in examples()] + for i in np.argsort(-sims)[:4]: + print(f" {sims[i]:.3f} {kinds[i]:12} {texts[i]}") diff --git a/tests/test_quick_answers.py b/tests/test_quick_answers.py new file mode 100644 index 0000000..8b3556f --- /dev/null +++ b/tests/test_quick_answers.py @@ -0,0 +1,125 @@ +"""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 + "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", +} +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", "이리 와", "손 흔들어 줘", "노래 불러 줘", + "how many employees does Cutshion have?", "직원이 몇 명이에요?", "how much do you cost?", "가격이 얼마예요?", + "how long does charging take?", "충전 얼마나 걸려요?", "how old is Cutshion?", "who is the CEO?", "대표가 누구예요?", + "what's the weather?", "what time is it?", "thanks", "고마워요", "okay", "bye", + "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?", "너 얼마야?", "얼마나 무거운 거 들 수 있어?", + "로봇 미국 회사 맞아요?", +] +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 \ + (not re.search(r"(?:요|다)[.!]?$", s) or re.search(r"컷션|커션", s)): + 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)