diff --git a/api/server.py b/api/server.py index 0d80d72..bebc56b 100644 --- a/api/server.py +++ b/api/server.py @@ -1097,8 +1097,8 @@ def task_parse(body: ParseBody): if hand[0] == "receive" and not held: got = [{"do": "receive", "object": hand[1], "from_hand": True}] return {"action": "steps", "steps": got, "lang": lang, "sender": None, "read_by": "rules", **_steps_said(got, markers)} - if hand[0] in ("give", "place"): - return _held_parse(body, markers) if held else _talk("–", ["My hand is empty, I'm not holding anything."]) + if hand[0] in ("give", "place"): # voice's reading of the hand (brain.hand_request), not a second one + return _held_parse(body, markers, hand[0]) if held else _talk("–", ["My hand is empty, I'm not holding anything."]) return _talk(hand[1][0] if hand[0] == "refuse" else "–", kind="refuse") if kind == "mission": got, unread, by = data @@ -1114,13 +1114,16 @@ def task_parse(body: ParseBody): if kind == "quick" and data[0] == "fetch": return _fetch_parse(body, markers) if kind == "quick" and data[0] == "put": - return _held_parse(body, markers) if held else _talk("–", ["My hand is empty, I'm not holding anything."]) + return _held_parse(body, markers, "place") if held else _talk("–", ["My hand is empty, I'm not holding anything."]) if kind == "quick" and data[0] in ("weather", "search"): return _answer(fixed, "Look it up and answer.", "lookup") if kind == "quick": if held and data[0] == "go_to": return _held_parse(body, markers) # holding: a carry there got = _rule_steps(data) + prefer = data[0] == "pick" and got and brain.pick_prefer(fixed)[0] + if prefer: + got[0]["prefer"] = prefer # "왼쪽 컵 집어", "the smaller cup": which of several (fetch picks it) if got: return {"action": "steps", "steps": got, "lang": lang, "sender": None, "read_by": "rules", **_steps_said(got, markers)} @@ -1129,9 +1132,9 @@ def task_parse(body: ParseBody): problem = brain.place_problem(fixed, markers) if problem: # quick_command says it: "I don't have a place called p12" return _talk(problem[0], kind="refuse") - if held and kind is None and (brain.held_command(fixed) and brain.direct_order(fixed) and not brain.not_an_order(fixed) - or brain.held_carry(fixed, markers)): # "p5로 가져가": a carry there - return _held_parse(body, markers) + if held and kind is None and brain.held_carry(fixed, markers) and not brain.ARM_TALK.search(fixed) and \ + not brain.to_someone_else(fixed): # "p5로 가져가": a carry there. Nothing else the rules left is done + return _held_parse(body, markers) # with the hand here: as by voice, the LLM reads it (no motion) if kind is None and body.llm: # the rules leave it: the LLM, one call, as by voice gen = brain.Brain().respond_stream(fixed, markers) head = next(gen) @@ -1236,10 +1239,11 @@ def _choices(): "then": [t for t in fetch.THEN if t]} -def _held_parse(body, markers): +def _held_parse(body, markers, said=None): """A command while something is held: what to do with it, read by the rules only (fast; the object named in it is the held one, so "give me the cup" is a give, not a new fetch). A marker named anywhere in the text is where to - bring it, else the dialog's To; then put it on a table, hand it over or keep holding it.""" + bring it, else the dialog's To; then put it on a table, hand it over or keep holding it. said: what voice's reader + (lumi.route: the hand, the put rule) already made of the words, "give" or "place".""" from assistant import brain, steps from tasks import fetch held, text = fetch.held_name(), brain.give_clause(body.text) # not where the person it is for goes @@ -1251,7 +1255,7 @@ def _held_parse(body, markers): named = [p for p in named if isinstance(p, dict)] dest = named[0] if named else (body.dest if body.dest not in (None, "here") else None) on = brain.place_on(text) # "on the orange chair": what to put it on - then = "place" if on else brain.held_command(text) or ("place" if m.get("finish") == "place" else None) + then = said or ("place" if on else brain.held_command(text) or ("place" if m.get("finish") == "place" else None)) if then == "give" and named and not re.search(r"\b(give|hand)\b|줘|주세요|건네", t): then = None # "bring it to p2" is a carry, not a hand-over table = "dining table" if re.search(r"\bdin+(?:n|i)?ing\b|\bdinner table\b", t) else "table" # as it was said diff --git a/assistant/bank_words/arm_more.py b/assistant/bank_words/arm_more.py index d6da6f0..d3fb473 100644 --- a/assistant/bank_words/arm_more.py +++ b/assistant/bank_words/arm_more.py @@ -500,5 +500,137 @@ NO += [ "wave hello to my friend on the phone, no wait, never mind", "pick it up? no, leave it", ] + +# ---------- a reason before or after the order ("…, my mom wants a picture", "리허설 중이에요, …"), train-set gaps ---------- +EN_CORE = { + "WAVE": ["wave", "say bye with your hand", "shake my hand", "wave at the kids"], + "ARM_REACH": ["hold your hand out to me", "give me your hand", "reach out your arm"], + "ARM_FOLD": ["put your arm down", "rest your arm", "fold your arm"], + "ARM_OPEN": ["open your hand", "hand open"], + "ARM_CLOSE": ["close your hand", "make a fist"], + "PICK": ["pick up the ", "pick the up"], +} +KO_CORE = { + "WAVE": ["손 흔들어 줘", "악수해요", "손으로 인사해 줘"], + "ARM_REACH": ["손 줘 봐", "팔 뻗어 줘", "손 내밀어 줘"], + "ARM_FOLD": ["팔 접어 줘", "손 내려 줘"], + "ARM_OPEN": ["손 펴 줘", "그리퍼 열어 줘"], + "ARM_CLOSE": ["주먹 꽉 쥐어 줘", "손 쥐어 줘"], + "PICK": [" 집어 줘", " 잡아 주세요"], +} +EN_AFTER = ["{}, my mom wants a picture", "{}, we're making a video", "{} for the photo", + "{}, it's for a video", "{}, i'm filming"] +EN_BEFORE = ["we're filming, {}", "for the video, {}", "ok so my friend dared me, {}", "smile for the camera and {}", + "one, two, three, {}", "3, 2, 1, {}", "let's see you {}", "i'd love to see you {}", "i want you {}"] +KO_AFTER = ["{}, 사진 찍게", "{}, 애들이 좋아해", "{}, 영상 찍고 있어", "{} 기념으로", "{}, 할머니가 보고 싶대"] +KO_BEFORE = ["리허설 중이에요, {}", "촬영 중인데 {}", "녹음 중인데, {}", "하나 둘 셋, {}", "자 이제 {}", "기념 사진 찍을게, {}"] +_REASON = {} +for k, cores in EN_CORE.items(): + _REASON[k] = [f.format(c) for c in cores for f in EN_AFTER + EN_BEFORE] +for k, cores in KO_CORE.items(): + _REASON[k] += [f.format(c) for c in cores for f in KO_AFTER + KO_BEFORE] +WAVE += _REASON["WAVE"] +ARM_REACH += _REASON["ARM_REACH"] +ARM_FOLD += _REASON["ARM_FOLD"] +ARM_OPEN += _REASON["ARM_OPEN"] +ARM_CLOSE += _REASON["ARM_CLOSE"] +PICK += _REASON["PICK"] +ARM_OPEN += ["let go", "let go now", "okay, let go", "let go of it", "release", "release now", "손 놔", "손 놓아", + "그리퍼 놔", "hand open 해 줄래", "손 오픈 해 줄래"] +ARM_CLOSE += ["꽉 쥐어", "꽉 쥐어 줘", "꽉 쥐어 주면 좋겠어", "주먹 꽉 쥐어 주게", "손 꽉 쥐시게"] +ARM_REACH += ["give me 손", "give me 손 해 줘", "손 give me", "your hand to me, robot", "robot, your hand to me", + "손 줘 봐 손", "손 손 줘", "할머니한테 손 줘 봐", "애기한테 손 줘", "손님한테 손 줘 봐요"] +WAVE += ["악수하세", "악수하세나", "에구 악수하세", "악수 한번 하세나", "let's see you wave like a queen", "wave like a king", + "wave like a princess", "wave like a superstar", "wave like a pro", "핸드 웨이브 해", "손 웨이브"] +ARM_FOLD += ["rest your arn", "fold your arn", "put your arn down", "back to look position please", + "look position please", "go back to the look position", "팔 룩 포지션"] +PICK += [" 좀 들게", " 잡게나", " 들어부러", " 집어부러", " 좀 쪼까 집어 줘", + " 집어 주시기 바랍니다", " 잡아 주시기 바랍니다", " 들어 주시기 바랍니다", "좀들어주시기바랍니다", + "you have to take the ", "you must pick up the ", "you are can take the ", + "i am tourist, please lift the ", " 픽업해", " 픽업해 줘요"] +FETCH += [" 브링해 줘", " 브링해", " 브링해 주시겠습니까", "에서 브링해", "에서 브링해 줘", + " 가져와 주시기 바랍니다", " 갖다 주시기 바랍니다", "에서 가져와 주시기 바랍니다", + "에서 가져와 주시기 부탁드립니다", "에 있는 갖다 주시겠어요", "에서 갖다주게나", + " 갖다 줘 ㅎㅎ", "you bring please", "you bring from please"] + + +# ---------- hard negatives for every capability: negation, past, ability, condition, later, remarks ---------- +NEG_EN = {"wave": ("wave", "waved", "waving"), "shake hands": ("shake hands", "shook hands", "shaking hands"), + "hold out your hand": ("hold out your hand", "held out your hand", "holding out your hand"), + "fold your arm": ("fold your arm", "folded your arm", "folding your arm"), + "open your hand": ("open your hand", "opened your hand", "opening your hand"), + "close your hand": ("close your hand", "closed your hand", "closing your hand"), + "pick up the cup": ("pick up the cup", "picked up the cup", "picking up the cup"), + "bring me the cup": ("bring me the cup", "brought me the cup", "bringing me the cup")} +NEG_KO = {"손 흔들어": ("손 흔들", "손 흔들었", "손 흔드는", "손 흔들"), "악수해": ("악수하", "악수했", "악수하는", "악수할"), + "손 내밀어": ("손 내밀", "손 내밀었", "손 내미는", "손 내밀"), "팔 접어": ("팔 접", "팔 접었", "팔 접는", "팔 접을"), + "손 펴": ("손 펴", "손 폈", "손 펴는", "손 펼"), "주먹 쥐어": ("주먹 쥐", "주먹 쥐었", "주먹 쥐는", "주먹 쥘"), + "컵 집어": ("컵 집", "컵 집었", "컵 집는", "컵 집을"), "컵 가져와": ("컵 가져오", "컵 가져왔", "컵 가져오는", "컵 가져올")} +_neg = [] +for base, past, ing in NEG_EN.values(): + _neg += [f"don't {base}", f"please don't {base}", f"never {base} again", f"you don't have to {base}", f"no need to {base}", + f"you {past} earlier", f"you {past} yesterday", f"did you {base}?", f"can you really {base}?", f"have you ever {past}?", + f"if the guests come, {base}", f"{base} when i say so", f"{base} later", f"{base} tomorrow", f"minsu, {base}", + f"mom, {base}", f"i saw you {base}", f"stop {ing}", f"i love {ing}", f"{ing} is fun", f"you're good at {ing}", + f"why did you {base}?", f"who told you to {base}?", f"robots can {base}", f"i wonder if you can {base}", + f"do you know how to {base}?", f"i'd rather you didn't {base}", f"you shouldn't {base} now", f"wait, don't {base}"] +for imp, (stem, past, adn, fut) in NEG_KO.items(): + _neg += [f"{stem}지 마", f"{stem}지 마세요", f"{stem}지 마십시오", f"{stem}지 마시게", f"{stem}지 마이소", f"{stem}지 말아 주세요", + f"{past}어?", f"{past}잖아", f"아까 {past}어요", f"어제 {past}습니다", f"{fut} 수 있어?", f"{fut} 줄 알아?", + f"{adn} 거 봤어", f"{adn} 거 멋있다", f"{adn} 거 신기하네요", f"{adn} 로봇이네", f"손님 오면 {imp}", f"나중에 {imp}", + f"내일 {imp}", f"민수야 {imp}", f"엄마 {imp} 봐", f"{imp} 달라고 누가 그랬어?", f"왜 {past}어?", f"{imp} 안 해도 돼", + f"{imp} 필요 없어", f"{imp}도 돼?", f"{adn} 게 좋아", f"{imp} 그만", f"{adn} 건 나중에 하자"] +NO += [t for t in _neg if not t.startswith(("minsu,", "mom,", "민수야", "엄마", "can you really"))] # a name or "can you" is +# also how a real request starts: those stay with the guards (For B2) + + +# ---------- Korean kids / elderly / non-native / chat slang ---------- +WAVE += ["로봇아 손 흔들어 흔들어", "손 흔들어 흔들어", "안녕 안녕 손 흔들어", "빠빠이 해 빠빠이", "로봇 빠이빠이", "로봇 안녕 해 손으로", + "어이 로봇 양반 손 좀 흔들어 보게", "이 사람아 악수나 하세", "젊은이 악수 한번 하세", "로봇 양반 손 한번 흔들어 보시게", + "손 흔들어 주세요 로봇 씨", "로봇 손 흔들어요 제발", "악수 해요 우리", "손 흔들어 주세요 부탁", "손 흔들어 ㄱㄱ", "악수 ㄱ", + "웨이브 ㄱㄱ", "손 흔들어 ㅇㅇ", "손인사 ㄱㄱ", "악수 ㄱㄱ해", "손 흔들어줘 ㅎㅎ", "악수하자 ㅋㅋ", "손 흔들어 주세용 ㅎㅎ", + "로봇아 우리 애한테 손 흔들어 줘라", "애기한테 빠빠이 해 줘", "우리 손주한테 손 좀 흔들어 주게"] +ARM_REACH += ["로봇 손 줘 손", "손 손 손 줘", "손 줘 손", "로봇아 손", "손 내밀어 내밀어", "젊은이 손 좀 내밀어 보게", + "로봇 양반 손 좀 줘 보게", "이 사람아 손 좀 내밀어 보게나", "손 주세요 부탁", "로봇 씨 손 주세요", "팔 뻗어 ㄱ", + "손 내밀어 ㅇㅇ", "손 줘 ㅎㅎ", "팔 쭉 ㄱㄱ", "우리 애가 손 잡게 손 좀 내밀어 줘", "애기 손 잡게 손 내밀어 줘"] +ARM_FOLD += ["팔 접어 접어", "팔 넣어 넣어", "로봇 팔 접어", "로봇 양반 팔 좀 접게", "이 사람아 팔 거두게", "팔 접어 주세요 부탁", + "로봇 씨 팔 접어요", "팔 접어 ㄱㄱ", "팔 ㄴㄴ 접어", "팔 넣어 ㅇㅇ", "팔 접어줘 ㅎㅎ", "팔 원위치 ㄱ"] +ARM_OPEN += ["손 펴 펴", "로봇 손 펴", "손 펴 보게 젊은이", "손 펴 주세요 부탁", "손 펴 ㄱㄱ", "손 쫙 펴 ㅎㅎ", "그리퍼 오픈 ㄱ"] +ARM_CLOSE += ["주먹 쥐어 쥐어", "주먹 좀 쥐어 보게 젊은이", "주먹 쥐어 주세요 부탁", "주먹 ㄱㄱ", "손 꽉 ㅎㅎ", + "그리퍼 클로즈 ㄱ"] +PICK += [" 집어 집어", "로봇 집어", " 좀 집어 보게 젊은이", "로봇 양반 좀 집어 주게", " 집어 주세요 부탁", + " 잡아 ㄱㄱ", " 집어 ㅇㅇ", " 들어 봐 ㅎㅎ", " 픽 ㄱ"] +FETCH += [" 가져와 가져와", "로봇 가져와", " 좀 가져오게 젊은이", "로봇 양반 좀 가져다 주게", " 가져와 주세요 부탁", + " 갖다 줘 ㄱㄱ", " 가져와 ㅇㅇ", " 갖다 줘 ㅋㅋ"] + + +# ---------- whisper slips from the train sets (송 = 손, 해져 = 해 줘, hend, weib, gib) and more frames ---------- +SLIP_FRAMES = ["any chance you could {}", "{}, chop chop", "{}, there's a good robot", "let's have you {}", "{}, test one", + "hey you, {}", "{}, can?", "{}, ok?"] +SLIP_CORES = {"wave": ["wave", "shake hands", "wave hello"], "arm_reach": ["hold out your hand", "reach toward me", "offer me your hand"], + "arm_fold": ["fold your arm", "put your arm down"], "arm_open": ["open your hand"], "arm_close": ["close your hand"], + "pick": ["pick up the ", "pick the up"]} +for _k, _v in SLIP_CORES.items(): + {"wave": WAVE, "arm_reach": ARM_REACH, "arm_fold": ARM_FOLD, "arm_open": ARM_OPEN, "arm_close": ARM_CLOSE, + "pick": PICK}[_k].extend(f.format(c) for c in _v for f in SLIP_FRAMES) +WAVE += ["gib me a shake", "pliz gib me a shake", "give me a shek", "give everyone a wave", "give everyone weib", + "weib please", "give weib", "wayve like a queen", "wave one more itme", "하이 웨이브 해", "하이 웨이브", + "나랑 악수", "나랑악수", "저랑 악수", "우리 악수", "안녕 해져 손으로", "웨이브 해져", "손 흔들어 져", "악수 해져", + "손 흔드러 주소", "악수 shake 해 줄래", "hello wave 해 줄래", "손 wave 한번 해 봐"] +ARM_REACH += ["송 줘", "송 이리 줘", "송 한번 줘요", "저한테 송 줘", "송 이리 주면 안 돼?", "송 내밀어", "송 좀 내밀어 줘", + "손 내밀어 져", "손 줘 져", "reach for me for mi", "reach for mi", "giv hand", "gib hand", "gib me hand", + "손!", "손 쫌 주이소", "앞으로 팔 내밀어 주실래요", "reach 해 봐"] +ARM_FOLD += ["기본 pose 로 해", "기본 포즈로 해", "기본 포즈로 돌아가", "기본 자세로 돌아가", "기본 자세", "기본 pose", + "팔 기본 포즈", "팔 접어 져", "손 다시 넣어 져", "팔 넣어 져", "folf your arm", "fold yuor arm", "put yor arm down"] +ARM_OPEN += ["송 좀 펴 줄래요", "송 펴", "송 펴 줘", "손 펴 져", "opeen your hand", "open yor hand", "open hend", + "release ㄱㄱ", "release 해", "release 해 줘", "릴리즈 해 줘"] +ARM_CLOSE += ["clench your hend", "cllose hand", "close hend", "close yor hand", "clos hend", "손 쥐어 져", + "주먹 쥐어 져", "손가락 쥐어", "손가락 쥐어 줘", "손가락 쥐어 주겠나", "꽉 쥐세요", "그리퍼 오므리시겠어요", + "집게 꽉 닫아 봐", "그리퍼 클로즈 해 줘"] +PICK += [" 픽업 해", " 픽업 해 줘", " grab 해 줄 수 있어", "take 해 주이소", "grab the 가능?", + " 집어 져", " 잡아 져", " 집어! 가즈아", " 들어라", " 잡아 봐요"] +NO += ["송 불러 줘", "송 하나 불러", "송 틀어 줘", "생일 송 불러 줘", "노래 송 틀어", "손 송 노래", "drop the beat", "drop the mic", + "let it go 불러 줘", "sing let it go", "release the song", "give everyone a break", "give everyone a minute"] + INTENT = {"wave": WAVE, "arm_reach": ARM_REACH, "arm_fold": ARM_FOLD, "arm_open": ARM_OPEN, "arm_close": ARM_CLOSE, "pick": PICK, "fetch": FETCH, "put": PUT, "give": GIVE, "receive": RECEIVE, "no": NO} diff --git a/assistant/bank_words/company.py b/assistant/bank_words/company.py index beb3f68..5cba71b 100644 --- a/assistant/bank_words/company.py +++ b/assistant/bank_words/company.py @@ -316,3 +316,9 @@ QUICK["no"] += [ "엔비디아 대표 누구야", "테슬라 대표 누구예요", "삼성 회장 누구야", "who's the boss of openai", "who runs google", "1달러에 원화로 얼마야", "1달러 원화로 얼만가", "환율 얼마예요", "달러 환율 알려 줘", "엔화 얼마야", "how much is a dollar in won", "what's the exchange rate", "배터리 얼만가", "배터리 얼마예요", "배터리 얼마야", "배터리 얼마 남았는가"] +QUICK["co_what"] = QUICK.get("co_what", []) + ["tell me a bit about cutshion", "tell me a little about cutshion", "a few words about cutshion", + "what is cutshion like", "cutshion 소개 좀", "쿳션 소개 부탁해요", "쿳션 얘기 좀 해 줘"] +QUICK["co_founded"] += _ko(["쿳션 창업한 지 얼마나 됐", "회사 창업한 지 얼마나 됐", "쿳션 설립된 지 얼마나 됐", "쿳션 세워진 지 몇 년 됐"], + ["어", "어요", "니", "습니까", "나요", "노", "어유", "는가"]) +QUICK["co_hq"] += ["where is cutshion's office", "where's cutshion's office", "where is the cutshion office", "cutshion office location", + "where is your company's office", "쿳션 오피스 어디예요"] diff --git a/assistant/bank_words/questions.py b/assistant/bank_words/questions.py index 5408d66..c5da91d 100644 --- a/assistant/bank_words/questions.py +++ b/assistant/bank_words/questions.py @@ -738,3 +738,42 @@ QUICK["no"] += ["한 번에 몇 초 걸려", "몇 초 걸려", "몇 초나 걸 "how long does it take", "얼마나 걸려요", "시간 얼마나 걸려"] QUICK["mics"] += ["clip mic 있어요", "클립 마이크 있어요", "무선 마이크 있어요", "시끄러우면 마이크 써", "시끄러우면 마이크 씀", "do you have a clip mic", "is there a wireless microphone", "can i use a microphone", "마이크 따로 있어요"] +# what Lumi can do is assistant/abilities.py's: "기능" asked is never what it is used for (used_where) +QUICK["no"] += _ko(["기능 ", "너 기능 ", "기능이 ", "루미 기능 ", "할 수 있는 기능 ", "니 기능 "], _WHAT) + [ + "what are your functions", "what functions do you have", "your functions what", "what features do you have", "기능 뭐 있어", + "무슨 기능 있어요", "어떤 기능 있어요", "기능 좀 알려 줘", "function 뭐 있어"] +QUICK["battery_life"] += _ko(["배터리 타임 ", "배터리 time ", "battery 타임 "], ["얼마나 돼", "얼마나 돼요", "얼마나 되세요", "얼마야", "얼마예요", + "몇 시간이야", "몇 시간이에요", "얼마나 가요", "어떻게 돼요"]) +# round 5 (first-words sweep): commands and status questions that came out as fact kinds +QUICK["no"] += [ + "손", "손!", "손 다시 넣어", "손 넣어", "팔 넣어", "집게 열어", "집게 닫아", "손가락 펴", "손가락 여시면 좋겠어요", "손 펴 주시겠어요", "손 펴", + "open your fingers", "could you open your fingers", "close your gripper", "please you can grip", "you can grip", "grip it", "grip please", + "바닥에 놔", "바닥에 놓으시겠어요", "바닥 체크", "바닥 봐", "바닥에 내려놔", "put it on the floor", + "where is your arm", "where's your arm now", "팔 지금 어디야", "팔 지금 어디예요", "팔 어디 있어", "arm where now", + "고개 원위치로 돌려 주세요", "고개 돌려 주세요", "머리 원위치", "허리 왼쪽으로 틀어 주세요", "turn your head ten degrees down", + "가까이 오시게", "이리 오시게", "가까이 와", "가까이 와 주세요", "come closer", "홀로 가시지요", "홈으로 가", "go plug yourself in", + "go charge yourself", "충전하러 가", "lumi what's your battery", "what's your battery level", "배터리 몇이야", + "would you raise your height", "raise your height a little", "키 좀 높여 주시겠어요", "make yourself taller", "키 높여 줘"] +# round 6 (own new phrasings, 135 written apart from the bank) +QUICK["maker"] += _ko(["너 누구 작품", "누구 작품", "이 로봇 누구 작품", "어디 작품"], ["이야", "이에요", "이니", "입니까", "인가요", "이고", "인교", "이여"]) + [ + "whose work are you", "who's your creator", "who is behind this robot", "which company is behind you"] +QUICK["height"] += ["are you taller than a person", "are you as tall as a man", "are you taller than me", "사람보다 커", "사람보다 키 커요", + "어른만 해요", "사람만 해", "are you bigger than a person"] +QUICK["weight"] += _ko(["몸무게 몇 ", "무게 몇 ", "너 몇 "], ["키로예요", "키로야", "키로", "키로입니까", "키로고", "킬로예요", "킬로야", "kg이에요", "kg이야"]) +QUICK["battery_life"] += ["how long can you run before charging", "how long before you need to charge", "how long can you go without charging", + "how long until your battery is empty", "충전 안 하고 얼마나 버텨", "충전 없이 몇 시간 가요"] +QUICK["model"] += ["what brain do you use to talk", "what's your brain", "what thinks for you", "what ai thinks for you", "which ai do you have inside", + "무슨 두뇌로 말해", "어떤 머리로 생각해요"] +QUICK["robot"] += ["are you a person in a costume", "is someone wearing you", "are you a costume", "is there a person in there", + "사람이 들어가 있는 거야", "탈 쓴 사람이에요", "사람이 인형 옷 입은 거예요"] +QUICK["time_now"] += ["time check", "time check please", "현재 시각 알려 줘", "현재 시각이 어떻게 돼요", "현재 시각 좀", "시각 좀 알려 주세요", + "do you know what time it is", "can you tell me what time it is"] +QUICK["how_are_you"] += _ko(["오늘 기분 좋", "기분 좋", "기분 괜찮", "오늘 컨디션 좋"], ["아", "아요", "니", "으세요", "습니까", "나", "노"]) +QUICK["no"] += ["이거 몇 살짜리 장난감이야", "몇 살짜리가 쓰는 거야", "몇 살부터 탈 수 있어", "몇 살 이상 이용 가능해요", "what age is this toy for"] +QUICK["hello"] = QUICK.get("hello", []) + ["hi there lumi", "hello there lumi", "hey there lumi", "hi there robot", "hello there robot", + "hi lumi nice to meet you", "안녕 로봇아", "안녕하세요 로봇님", "루미 반가워요", "하이 로봇"] +QUICK["safety"] += _ko(["너 위험한 로봇", "위험한 로봇", "이 로봇 위험한 거"], ["이야", "이에요", "이니", "입니까", "인가요", "이고", "임"]) +QUICK["tts"] += ["what speech synthesis do you use", "what voice synthesis do you use", "which speech synthesizer do you use", "음성 합성 엔진 뭐예요"] +QUICK["no"] += ["can you open the window", "open the window", "창문 열어 줘", "창문 열 수 있어", "turn on the internet", "인터넷 켜 줘", + "connect to the wifi", "와이파이 연결해 줘", "여기 안전해", "is it safe here", "이 동네 안전해요", "is this area safe", + "바닥 안전해", "is the floor safe"] diff --git a/assistant/brain.py b/assistant/brain.py index 7c9a069..405e41a 100644 --- a/assistant/brain.py +++ b/assistant/brain.py @@ -677,7 +677,7 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said ("follow", r"\b(?:follow|following|come with|come along with|come together with|walk with|tag along with)\s+(?:me|us)\b(?!\s+(?:on|at)\b)|" # not "follow r"\bcome along\b|(?= 2 or re.search(r"[가-힣]{4}", rest): # "hello there", "hi lumi" stay whole + words = re.sub(r"\b(?:there|lumi|robot)\b|[^\w\s]", " ", rest, flags=re.I).split() + if len(words) >= 2 or re.search(r"[가-힣]{4}", rest): # "hello there", "hi there, Lumi!" stay whole t = rest t = ASKING.sub("", brain.CALLING.sub("", t).strip()).strip() or text or "" if not re.search(r"\b(?:is|was|name|named|called)\s+lumi\W*$|이름(?:이|은|을)?\s*루미", t, re.I): # "How wide is Lumi?", @@ -386,8 +390,12 @@ def _core(text): lambda m: m.group(1) + ("이에요" if (ord(m.group(1)) - 0xAC00) % 28 else "예요"), t) t = re.sub(r"(?<=[가-힣])는지 (?:궁금|알고 싶|알려|말해|알 수 있|여쭤)\S*(?: \S+)?$", "나요", t) # "몇 살인지 궁금해요" t = re.sub(r"(?:뭔가|무엇인가)$", "뭐예요", re.sub(r"(?<=[가-힣])(?:는교|남유|는감)$", "나요", t)) # 하게체, dialect + t = re.sub(r"(?<=[가-힣])인교$", "인가요", t) t = re.sub(r"얼만가$", "얼마예요", re.sub(r"(?<=[가-힣])는가$", "나요", re.sub(r"(?<=[가-힣])인가$", "인가요", t))) - return t or (text or "").strip(" ,.!?~") # 하게체 questions ("키 얼만가", "얼마나 되는가") as 해요체 + # 하게체 questions ("키 얼만가", "얼마나 되는가") as 해요체 + if re.fullmatch(r"(?:there|all|everyone|everybody)\W*", t, re.I): + t = "" # "Hi there, Lumi!": a hello, said whole + return t or (text or "").strip(" ,.!?~") def guarded(text, history=()): @@ -418,12 +426,16 @@ def guarded(text, history=()): return "event time" if re.search(r"타워|빌딩|건물|(?= 2: text = text[fix[-1].end():] # "배터리, 아 아니, 지금 뭐 해?": what is said after the correction + if not ASKS.search(text): + return None # "몇 살이야? 아 됐고, 검정 컵 잡으시지요", "70cm, I mean 150 cm" parts = [p for p in SENTENCES.split(text) if p.strip() and not REMARK.fullmatch(p.strip(" ,.!??~")) and OPENER.sub("", p).strip(" ,.!??~")] if len(parts) > 1: - if any(ORDER.search(p) for p in parts): + if any(ORDER.search(p) or REQUEST.search(p) or re.search(r"봐\W*$", p) for p in parts): return None # "fold it! your arm!", "손! 손 내밀어!": a command, the rules' asked = [p for p in parts if ASKS.search(p)] kinds = {kind_of(p, history) for p in asked} @@ -487,7 +509,7 @@ def kind_of(text, history=(), _whole=True): m = list(ASIDE.finditer(rest)) head, comma, tail = (rest[:m[-1].start()], ",", rest[m[-1].end():]) if m else (rest, "", "") if comma and len(tail.split()) >= (2 if re.search(r"[가-힣]", tail) else 3) and ASKS.search(tail) and \ - not ASKS.search(head) and not ORDER.search(head): # "Your voice, what program?": the head is the topic + not ASKS.search(head) and not ORDER.search(head) and not REQUEST.search(head): # "Your voice, what program?": the head is the topic last = kind_of(tail, history, False) if got and last and last != got: return None # "저기 평가 항목, 루미, 오늘 무슨 요일이야?" read whole as another kind diff --git a/assistant/steps.py b/assistant/steps.py index 8acc132..81724c6 100644 --- a/assistant/steps.py +++ b/assistant/steps.py @@ -40,6 +40,7 @@ _FILL = (r"(?:(?:저기 |그 )?(?:이보게(?: 루미)?|어이(?: 로봇아?| r"번거로우시겠지만)|" # calls of every level ("이보게 루미", "루미 님께서") before "루미" alone r"please|let'?s|lets|hey lumi|hi lumi|hey|hi|lumi|loomi|rumi|okay|ok|alright|all right|so|well|real quick|if you can|if you could|자|저기|저기요|혹시|instead|um+|uh+|er|hmm|thank you|thanks|now|then|and|also|first|next|" r"finally|after that|there|for me|for us|again|carefully|slowly|could you|can you|would you|will you|could u|can u|would u|will u|" + r"could ya|can ya|would ya|will ya|" r"pls|plz|yo|would it be possible to|is it possible to|could i ask you to|would you mind|lumi야|루미야|루미|음|응|어|야 로봇|로봇아|로봇야|" r"감사합니다|고마워요|고마워|고맙습니다|좀|먼저|우선|일단|그다음|그 다음|마지막으로|다시|lastly|first of all|" r"(?:i'?d|i would) like you to|i want you to|i need you to|you should|kindly|go ahead and|maybe|possibly|" @@ -58,6 +59,8 @@ def _norm(text, markers=()): "0.5 m", "오십 센치" -> "0.5 m", "table front" -> "table_front" on a map with it), titles without their dot.""" t = re.sub(r"\b(mr|mrs|ms|dr|prof)\. ", r"\1 ", wording.durations(brain.unfill(brain.ko_slips(wording.norm(text, markers)))) + " ") t = re.sub(r"\b(?:take|pick up|pick|grab)\s?(?:해서|하고)", "집어서", t) # "컵 take해서": mixed + t = re.sub(r"(?:(?<=들고)|(?<=집고)|(?<=잡고)|(?<=가서)|(?<=와서)|(?<=챙겨서)|(?<=가지고)|(?<=받아서)|(?<=집어서)|(?<=갔다가))" + r"(?=[가-힣a-z0-9])", " ", t) # "컵들고exit가서기다려" (typed or heard run together): its parts t = re.sub(r"(?<=[가-힣])고\s*나서(?=[\s,]|$)", "고", t) # "가고 나서" = "가고" t = re.sub(r"(? 0: those come first. Objects of the wrong width + raise.""" plan_pick(obj) tried = [] - for seeds in (IK_SEEDS[:1], IK_SEEDS[1:]): # the proven `ready` configuration at every turn first - for yaw in GRASP_YAWS: + for wrist, seeds in ((1, IK_SEEDS[:1]), (1, IK_SEEDS[1:]), (-1, IK_SEEDS[:1]), (-1, IK_SEEDS[1:])): + for yaw in GRASP_YAWS: # the proven wrist (J5 > 0) and `ready` configuration first if max_yaw is not None and abs(yaw) > max_yaw: continue waypoints = plan_pick(obj, yaw) for ja in above_joints(waypoints[0][1], start, seeds): - if any(y == yaw and max(abs(a - b) for a, b in zip(t, ja)) <= 1.0 for y, t in tried): + if ja[4] * wrist < 0 or any(y == yaw and max(abs(a - b) for a, b in zip(t, ja)) <= 1.0 + for y, t in tried): continue # another seed found the same solution tried.append((yaw, ja)) rows = ik_chain(waypoints[1:], ja) diff --git a/tasks/fetch.py b/tasks/fetch.py index 1ec0c4a..fee3ed0 100644 --- a/tasks/fetch.py +++ b/tasks/fetch.py @@ -98,13 +98,15 @@ SAME_BASE_RAD = 0.035 WAIST_REACH_STEPS = (0.0, 15.0, -15.0, 30.0, -30.0) # deg; a pick out of reach: waist turns tried around the one # that brings the object to PICK_ZONE_CENTRE's bearing about the column (the waist carries # the arm round the column: what it reaches beside it, it reaches ahead), before a base move +GOAL_SLACK_MM = 20.0 # mm; a goal further out must also be reached this much further (the base stops short) GOAL_OUT_MM = range(0, 201, 20) # mm; the pick goal moves this far out from PICK_ZONE_CENTRE when the torso camera # would not see the cup there (a low table at lift 0) VIEW_MARGIN_PX = 10 # px; "in view" means this far inside the torso camera's image KEPT_MM = 150.0 # mm; after a base move the thing is the one seen this near where its map place says TORSO_HALF_DEG = 30.0 # deg; a kept thing further than this to a side of the torso camera's view: the waist turns WAIST_FOUND_MM = 80.0 # mm; after that turn the object is looked for this near where it should be seen -APPROACH_TRIES = 5 # base moves to bring an object out of reach to PICK_ZONE_CENTRE before asking the person +APPROACH_TRIES = 8 # base moves to bring an object out of reach to PICK_ZONE_CENTRE before asking the person + # (a move cut short by the base stopping at a chair still counts: 5 ran out, X1) STRAIGHT_MAX_M = 0.6 # m; a straight drive (after a turn on the spot) at most this long, else navigation STANDOFF_M = 0.4 # m; navigation goes to this far back from the pick pose, then straight in APPROACH_SIDES = (0, 45, -45, 90, -90, 135, -135, 180) # deg; ways in to the object tried by navigation, the @@ -126,6 +128,7 @@ FURNITURE_MAP_M = 0.5 # on the map this near): tables, chairs, bo NEAR_GAP_M = 0.4 # m; something this near the base's outline when nothing is seen ahead: back off ... NEAR_RING_M = 0.5 # m from the base centre where _near_look probes for something near after a failed search NEAR_VIEWS = (0.0, 60.0, -60.0) # deg; _near_look's views after it turned to what is near +NEAR_BACKS = 2 # _near_look backs off this many times (a cup on a low table is seen from ~0.7 m only) NEAR_BACK_M = 0.3 # ... this much and look again before the whole search (a cup < ~450 mm from the column # is below both cameras, X1's sweep) LOST_BACK_M = 0.15 # an object lost after a base move: back off this much (the camera sees more) ... @@ -1137,10 +1140,14 @@ def _near_look(attempt, holding=False): _straight_clear(-NEAR_BACK_M) if abs(d) >= TURN_MIN_DEG: _turn(d, holding, why="to look at what is near me") - for view in NEAR_VIEWS: # ahead, then the waist each way once (X1: a cup 60 deg aside) - got = _look_at(view, attempt) - if got is not None: - return got + for k in range(NEAR_BACKS): # a low table: the cup's middle comes into view only further off + if k: + _waist_front() + _straight_clear(-NEAR_BACK_M) + for view in NEAR_VIEWS: # ahead, then the waist each way once (X1: a cup 60 deg aside) + got = _look_at(view, attempt) + if got is not None: + return got _waist_front() return None @@ -1272,8 +1279,9 @@ def _approach(obj, yaw, tried, goal=PICK_ZONE_CENTRE, holding=False): x, y, _ = agv.pose() g, before = (goal[0] + dx, goal[1]), left() move = approach_move(now(), yaw, t, g) - if dx and agv.clearance(x, y) < BASE_HALF_M + CLEAR_M + PROBE_STEP_M: - break # flush at something: a small turn won't get it in (X1's sweep) + if dx and (agv.clearance(x, y) < BASE_HALF_M + CLEAR_M + PROBE_STEP_M or "stood" in tried): + break # flush at something, or the base stood still on the straight + # way in: a small turn won't get it in (X1's sweep) if move is None or abs(move[1]) > STRAIGHT_MAX_M or any( k[0] == "straight" and k[3] == dx and math.hypot(k[1] - x, k[2] - y) < SAME_PLACE_M for k in tried if isinstance(k, tuple)): @@ -1288,9 +1296,13 @@ def _approach(obj, yaw, tried, goal=PICK_ZONE_CENTRE, holding=False): why.append("turning") continue if abs(s) >= PROBE_STEP_M: + p0 = agv.pose() _straight_clear(s) + if math.hypot(agv.pose()[0] - p0[0], agv.pose()[1] - p0[1]) < PROBE_STEP_M: + tried.add("stood") # (forgotten again once the base gets elsewhere) gain = before - left() if gain >= PROGRESS_MM: + tried.discard("stood") return True log(f"that move brought it only {gain:.0f} mm nearer: another way") why.append("something in front of me") @@ -1331,6 +1343,7 @@ def _approach(obj, yaw, tried, goal=PICK_ZONE_CENTRE, holding=False): p = agv.pose() if math.hypot(p[0] - x, p[1] - y) >= PROGRESS_MM / 1000.0 or \ abs((p[2] - th + math.pi) % (2 * math.pi) - math.pi) >= math.radians(TURN_MIN_DEG): + tried.discard("stood") return True # at another side: the straight way in follows from there tried.add(("nav", sx, sy)) log("navigation left me where I was: another side") @@ -1479,12 +1492,13 @@ def pick_goal(obj): to z ~-375 at y 580 only (a cup on a lower table was lost at the pick zone and chased again, X1's sweep). No goal both seen and reached: FetchError saying so at once (a low table at lift 0), never a goal out of view.""" z = obj["top_mm"] - (obj.get("height_mm") or 2 * skills.BELOW_RIM_MM) / 2 - for dy in GOAL_OUT_MM: - g = (PICK_ZONE_CENTRE[0], PICK_ZONE_CENTRE[1] + dy) - if at_edge({"x": g[0], "y": g[1]}): - break - if in_view(g[0], g[1], z) and (not dy or _reach_at(obj, g)): - return g + for slack in (GOAL_SLACK_MM, 0.0): # reached a little further too (the base stops short), else just + for dy in GOAL_OUT_MM: + g = (PICK_ZONE_CENTRE[0], PICK_ZONE_CENTRE[1] + dy) + if at_edge({"x": g[0], "y": g[1]}): + break + if in_view(g[0], g[1], z) and (not dy or _reach_at(obj, (g[0], g[1] + slack))): + return g raise FetchError("The table is too low for me: where my arm reaches the cup, my camera can't see it.", "테이블이 너무 낮아요. 팔이 닿는 곳에서는 카메라로 컵이 보이지 않아요.") @@ -2259,6 +2273,14 @@ def _forget_held(): skills._held.clear() +def held_by_skill(what): + """Record a hold made outside a fetch (assistant/lumi.py's voice pick: skills.pick directly): `what` {"object", + "colour"} becomes the held object, so the state file, the dashboard and every reply name it ("the white cup").""" + with _lock: + skills._held["what"] = {"object": what.get("object"), "colour": what.get("colour")} + _set(holding=True, held_object=skills._held["what"], status="holding", step="holding") + + def _hold_again(): """The hand holds something the state does not: it is the thing forgotten last (_forget_held), its name and what put down needs. Live 2026-10-26 18:53:00 one hand read said empty with the cup in it; after that every reply said diff --git a/tests/bank_check.py b/tests/bank_check.py index 12cf962..3aa63ed 100644 --- a/tests/bank_check.py +++ b/tests/bank_check.py @@ -137,7 +137,7 @@ def _save_queries(known): def _run(job): """One share of the cases: (counts by set, wrong, hits, read times, missed, new query vectors).""" - part, stress, fast, marks = job + part, stress, fast, marks, misses = job known = KNOWN # the embed wrapper's own dict (in a forked job: its copy) n0 = set(known) from assistant import detour, steps @@ -169,6 +169,14 @@ def _run(job): times.append(time.time() - t0) if not got: by[name]["llm" if ruled in (None, "llm?") else "rules"] += 1 + if ruled == "llm?" and fast and misses and expect.startswith("action:"): + intent_bank.read = lambda *a, **k: None # --misses: the rules asked only here (true misses) + try: + ruled = command_check.rules(text, state, mk, b) + except command_check.NoLLM: + pass + finally: + intent_bank.read = real if ruled in (None, "llm?") and expect.startswith("action:"): missed.append(f"- [{name}/{state}] {text!r} (want {expect})") continue @@ -186,7 +194,8 @@ def _run(job): def main(args): """--fast: the rules are not run (0.8 s a case): wrong and llm are the same, hit and agree are counted together as - hit. --jobs N: N processes (the embedding server is shared).""" + hit. --misses (with --fast): the rules read only the cases the bank leaves, so the "Left to the LLM" list holds + only what nothing but the LLM answers. --jobs N: N processes (the embedding server is shared).""" global OUT if "--rounds" in args: ROUNDS[:] = args[args.index("--rounds") + 1].split(",") @@ -199,7 +208,7 @@ def main(args): jobs = int(args[args.index("--jobs") + 1]) if "--jobs" in args else 1 intent_bank._load(), intent_bank._codes() # loaded once, shared by the forked jobs every = cases("--blind" in args) - parts = [(every[i::jobs], stress, fast, marks) for i in range(jobs)] + parts = [(every[i::jobs], stress, fast, marks, "--misses" in args) for i in range(jobs)] if jobs > 1: import multiprocessing with multiprocessing.get_context("fork").Pool(jobs) as pool: diff --git a/tests/pick_sweep.py b/tests/pick_sweep.py index 2231409..14eaf55 100644 --- a/tests/pick_sweep.py +++ b/tests/pick_sweep.py @@ -431,7 +431,8 @@ def _moved(kind, want, before): after = W["base"] W["rec"]["moves"].append([kind, round(float(want), 3), round(float(math.hypot(after[0] - before[0], after[1] - before[1])), 3), - round(math.degrees((after[2] - before[2] + math.pi) % (2 * math.pi) - math.pi), 1)]) + round(math.degrees((after[2] - before[2] + math.pi) % (2 * math.pi) - math.pi), 1), + [round(float(v), 3) for v in before]]) def f_go_point(x, y, th): @@ -750,6 +751,11 @@ def run_scene(sc, cam=1.0): rec["still"] = sum(1 for m in mv if m[2] < 0.02 and abs(m[3]) < 2.0) rec["repeats"] = sum(1 for a, b in zip(mv, mv[1:]) if a[0] == b[0] and abs(a[1] - b[1]) < 0.02 and a[2] < 0.02 and abs(a[3]) < 2.0) + nowhere = lambda m: m[2] < 0.02 and abs(m[3]) < 2.0 + same_spot = lambda a, b: math.hypot(a[4][0] - b[4][0], a[4][1] - b[4][1]) < 0.05 and \ + abs((a[4][2] - b[4][2] + math.pi) % (2 * math.pi) - math.pi) < math.radians(3) + rec["loops"] = sum(1 for k, b in enumerate(mv) if nowhere(b) and any( + a[0] == b[0] and abs(a[1] - b[1]) < 0.02 and nowhere(a) and same_spot(a, b) for a in mv[:k])) if sc["kind"] == "pick" and rec["result"] != "ok" and sc["cup"]["grip"] >= 72.0: lines_kept = list(W["lines"]) try: @@ -874,7 +880,9 @@ def report(rows, path, title, mtimes): f"- moves that went nowhere (< 2 cm, < 2 deg): {sum(r['still'] for r in mv)} in " f"{sum(r['still'] > 0 for r in mv)} scenes", f"- the same move repeated after one that went nowhere: {sum(r['repeats'] for r in mv)} in " - f"{sum(r['repeats'] > 0 for r in mv)} scenes", ""] + f"{sum(r['repeats'] > 0 for r in mv)} scenes", + f"- a move that went nowhere tried again later from the same spot: {sum(r.get('loops', 0) for r in mv)} in " + f"{sum(r.get('loops', 0) > 0 for r in mv)} scenes", ""] if places: ok = sum(r["result"] == "ok" for r in places) out += [f"## Places: {ok}/{len(places)} ok ({100 * ok / len(places):.1f} %)", "", @@ -882,7 +890,9 @@ def report(rows, path, title, mtimes): table(places, ("beside L", "left", "ahead", "right", "beside R", "behind"), ["in reach", "near (< 1 m)", "far"], "sector") out += [f"- moves that went nowhere: {sum(r['still'] for r in places)} in " - f"{sum(r['still'] > 0 for r in places)} scenes; repeated: {sum(r['repeats'] for r in places)}", ""] + f"{sum(r['still'] > 0 for r in places)} scenes; repeated: {sum(r['repeats'] for r in places)}; tried again " + f"later from the same spot: {sum(r.get('loops', 0) for r in places)} in " + f"{sum(r.get('loops', 0) > 0 for r in places)} scenes", ""] rel = [r["released"] for r in places if r.get("released") and r["released"]["above_table_mm"] is not None] if rel: hz = [x["above_table_mm"] for x in rel] diff --git a/tests/qa_eval.py b/tests/qa_eval.py index 497b58f..e63136e 100644 --- a/tests/qa_eval.py +++ b/tests/qa_eval.py @@ -155,6 +155,81 @@ NEG += ["내일 며칠이야?", "어제 무슨 요일이었어?", "what's the da "그거 몇 킬로야?", "that one, how heavy?", "저 로봇 이름 뭐야?", "옆에 로봇은 몇 살이야?", "what's the name of that robot?"] +# night 5, rounds 6-7: new phrasings written apart from the bank (every Korean level), and new "no" risks +POS_a = { + "name": ["I didn't catch your name, what was it?", "Sorry, your name again?", "Got a name, little guy?", "What should I call you, robot?", + "니 이름이 뭐였더라?", "이름이 뭐라 그랬지?", "이름을 여쭤봐도 될까요?", "로봇님 존함이 어떻게 되십니까?", "이름 뭐라카노?", + "이름이 뭐시여?", "너 이름 뭐냐고", "네임 좀 알려 주세요", "what's ur name lol", "이름 있으세요?"], + "age": ["How long ago were you built?", "Are you old or new?", "When's your birthday?", "how many years old is lumi", + "너 태어난 지 얼마나 됐어?", "몇 살이나 먹었니?", "연식이 어떻게 돼요?", "나이 좀 물어봐도 돼요?", "니 몇 살이고?", + "몇 살이당가?", "올해로 몇 살 되셨어요?", "your age, please?"], + "maker": ["Who's behind you, which company?", "Who built this robot?", "What company are you from?", "Who created you?", + "누가 널 만든 거야?", "어디서 만든 로봇이에요?", "제작사가 어디죠?", "만든 곳이 어디예요?", "누가 맹글었노?", "어디 제품인교?", + "who's your creator?", "너 누구 작품이야?"], + "height": ["How tall do you stand?", "What's your height exactly?", "Are you taller than a person?", "키가 어느 정도 돼요?", + "몇 센티나 돼?", "키가 몇 센치야?", "신장이 어떻게 되십니까?", "키 얼마나 되노?", "키가 몇이여?", "how tall r u lumi"], + "weight": ["How much do you weigh exactly?", "Are you heavy?", "What's your weight in kilograms?", "무게가 어느 정도 돼요?", + "몇 키로 나가?", "몸무게 몇 키로예요?", "중량이 얼마입니까?", "무게 우째 되노?", "얼마나 무거워요?", "how heavy is lumi"], + "battery_life": ["How long can you run before charging?", "How many hours does a full battery give you?", "What's your runtime on battery?", + "충전 한 번에 몇 시간 일해요?", "배터리 몇 시간 버텨요?", "한 번 충전하면 하루 종일 가요?", "배터리가 몇 시간이나 갑니까?", + "배터리 오래가노?", "배터리 지속 시간이 어떻게 되세요?"], + "languages": ["What languages do you understand?", "Do you understand Korean?", "Can I talk to you in Japanese?", "Do you speak French?", + "한국어로 말해도 돼?", "영어도 알아들어요?", "일본어 돼요?", "몇 개 언어 하세요?", "중국말 할 줄 아나?", "외국어 할 수 있습니까?"], + "chatgpt": ["Is this ChatGPT talking?", "Are you powered by OpenAI?", "Do you use GPT-4?", "챗GPT로 대답하는 거야?", "너 GPT 기반이야?", + "오픈AI 거 써요?"], + "model": ["What brain do you use to talk?", "Which AI answers me?", "What's the name of your language model?", "너 무슨 모델로 대답해?", + "어떤 인공지능으로 말해요?", "언어 모델 이름이 뭐예요?", "LLM 뭐 쓰세요?"], + "robot": ["Are you a person in a costume?", "Is there a human inside?", "Do you have a soul?", "Can you feel pain?", "너 사람이니 로봇이니?", + "안에 사람 들어 있어요?", "감정이 있으세요?", "아픈 거 느껴?", "너 기계 맞아?", "are you conscious?"], + "speed": ["How fast do you drive?", "What's your top speed in km/h?", "Can you go quickly?", "속도가 얼마나 나와요?", "최고 속력이 얼마예요?", + "얼마나 빨리 움직여?", "빠르게 갈 수 있어요?", "속도 우째 되노?"], + "time_now": ["Do you know what time it is?", "What's the time please?", "Time check?", "지금 몇 시예요?", "몇 시쯤 됐어요?", "시간 좀 알려 주시겠어요?", + "지금 몇 시나 됐노?", "현재 시각 알려 줘"], + "date_today": ["What's today's date?", "What day is it today?", "Which day of the week is today?", "오늘 날짜 좀 알려 주세요", "오늘 무슨 요일이에요?", + "오늘이 며칠이죠?", "오늘 몇 월 며칠이고?", "today date?"], + "hello": ["Hi there, Lumi!", "Good afternoon!", "Hey robot!", "안녕하십니까!", "하이~", "반가워 루미!"], + "how_are_you": ["How's your day been?", "Are you having a good day?", "오늘 기분 좋아?", "잘 지내셨어요?", "컨디션 괜찮아?"], +} +NEG_a = ["Can you see my hand?", "What's on the table?", "Where did my friend go?", "How old is my son?", "What am I holding?", + "Come with me please", "Turn to the left", "Bring me the cup", "Sing me a song", "Tell me a story", + "What's the weather tomorrow?", "Who won the game yesterday?", "What's the capital of France?", "How tall is BTS Jungkook?", + "How old is the CEO?", "When does the exhibition close?", "What time does the bus come?", "Where is the restroom?", + "내 손 보여?", "책상 위에 뭐 있어?", "우리 아들 몇 살로 보여?", "왼쪽으로 돌아", "컵 가져와", "노래 불러 줘", "이야기 해 줘", + "내일 날씨 어때?", "어제 경기 누가 이겼어?", "프랑스 수도가 어디야?", "대표님 나이가 어떻게 돼요?", "전시회 몇 시에 끝나요?", + "버스 몇 시에 와요?", "화장실 어디예요?", "고마워", "잘 가", "그래서?", "진짜야?", "왜?", "알았어", "음...", "그럼 이건?", + "이 컵 무게 얼마야?", "how heavy is this cup?", "how tall is the table?", "책상 높이 얼마야?", "이거 몇 살짜리 장난감이야?", + "how old is this building?", "what's your favorite food?", "좋아하는 음식 뭐야?", "do you love me?", "나 좋아해?"] +POS_b = { + "co_what": ["쿳션은 어떤 회사입니까?", "쿳션 뭐 하는 회사여?", "Tell me a bit about Cutshion", "쿳션이 뭐 하는 곳이에요?"], + "co_founded": ["When was your company set up?", "쿳션은 몇 년도에 생겼어요?", "회사 설립이 언제입니까?", "쿳션 창업한 지 얼마나 됐어?"], + "co_ceo": ["Who runs Cutshion?", "쿳션 사장님이 누구세요?", "쿳션 대표님 이름이 뭐예요?", "Who's the boss of Cutshion?"], + "co_hq": ["Where is Cutshion's office?", "쿳션 사무실이 어디 있어요?", "회사가 어디에 있습니까?", "쿳션 본사가 어디고?"], + "co_contact": ["How do I contact Cutshion?", "쿳션 이메일이 뭐예요?", "회사 전화번호 좀 알려 주세요", "쿳션에 연락하려면 어떻게 해요?"], + "safety": ["Is it safe for my kids to be near you?", "로봇 옆에 있어도 위험하지 않나요?", "너 위험한 로봇이야?", "Can you hurt someone?"], + "cameras": ["How many cameras are on you?", "카메라가 몇 개 달려 있어요?", "What camera do you have in your head?", "카메라 어떤 거 쓰세요?"], + "mics": ["Do you have a microphone?", "마이크가 몇 개 있어요?", "How far away can you hear people?", "멀리서도 들려요?"], + "stt": ["How do you understand my words?", "말을 어떻게 알아들어요?", "음성 인식 뭐 써요?", "Do you use Whisper?"], + "tts": ["How do you make your voice?", "목소리는 어떻게 내세요?", "What speech synthesis do you use?", "TTS 뭐 씁니까?"], + "internet": ["Are you connected to the internet?", "인터넷 연결돼 있어요?", "Can you work without wifi?", "와이파이 써?"], + "computer": ["What computer is inside you?", "안에 무슨 컴퓨터 들어 있어요?", "Do you use an NVIDIA chip?", "컴퓨터 사양이 어떻게 돼요?"], + "stairs": ["Can you climb stairs?", "계단 올라갈 수 있어요?", "Can you go over a step?", "턱 넘을 수 있어?"], + "doors": ["Can you open a door?", "문 열 수 있어요?", "문 열 줄 아니?"], + "lidar": ["Do you have a lidar?", "라이다 있어요?", "How far does your lidar see?"], + "gripper": ["What gripper do you have?", "그리퍼 뭐 써요?", "How many fingers do you have?", "손가락 몇 개야?"], + "payload": ["How much can your arm carry?", "팔 가반하중이 얼마예요?", "What's your payload?"], + "dance": ["Can you dance?", "춤출 수 있어요?", "Can you walk?", "걸을 수 있어?"], + "touch": ["Can I touch you?", "만져 봐도 돼요?", "Is it okay to touch the robot?"], +} +NEG_b = ["Where can I buy a robot like you?", "쿳션 주식 살 수 있어요?", "Is Cutshion's CEO married?", "대표님 몇 살이에요?", + "Can you open the window?", "문 좀 열어 줘", "Climb the stairs now", "계단으로 가", "Dance for me!", "춤 춰 봐", "Touch my hand", + "내 손 만져 봐", "Show me your camera", "카메라 보여 줘", "Turn on the internet", "와이파이 비밀번호 뭐야?", "What's the wifi password?", + "Pick up the bottle", "병 집어 줘", "How heavy is this bottle?", "이 병 몇 킬로야?", "Is the floor safe?", "여기 안전해?"] +for _p in (POS_a, POS_b): + for _k, _t in _p.items(): + POS.setdefault(_k, []).extend(_t) +NEG += NEG_a + NEG_b + + def run(): ok = bad = miss = 0 lines = [] diff --git a/tests/qa_sweep.py b/tests/qa_sweep.py index c0b6d0f..230ad93 100644 --- a/tests/qa_sweep.py +++ b/tests/qa_sweep.py @@ -3,17 +3,19 @@ python tests/qa_sweep.py # first words (commands: 'text' with no 'before'; dialogues: first turn # 'say') of train, r2-r4, r6, r8, r9, r10: the hits, for review python tests/qa_sweep.py r9 r10 # only these rounds' train sets + python tests/qa_sweep.py --sample 3000 # at most 3000 first words per round (seeded, the same each run) python tests/qa_sweep.py --questions r6 r8 r9 # questions_world: want-quick answered at once, and every quick # answer that misses the case's must / says its must_not (wrong) python tests/qa_sweep.py --questions -v r9 # ... and the questions left to the LLM The words are embedded in batches first (the embedding server is shared), then read from memory. """ -import glob, importlib, re, sys +import glob, importlib, random, re, sys sys.path.insert(0, __file__.rsplit("/tests/", 1)[0]) from assistant import knowledge, quick_answers as qa QUESTIONS, VERBOSE = "--questions" in sys.argv, "-v" in sys.argv -ROUNDS = [a for a in sys.argv[1:] if not a.startswith("-")] or \ +SAMPLE = int(sys.argv[sys.argv.index("--sample") + 1]) if "--sample" in sys.argv else None +ROUNDS = [a for a in sys.argv[1:] if not a.startswith("-") and not a.isdigit()] or \ (["r6", "r8", "r9"] if QUESTIONS else ["train", "r2", "r3", "r4", "r6", "r8", "r9", "r10"]) _embed, _known = knowledge.embed, {} @@ -45,6 +47,7 @@ def sets(r, questions): def first_words(): seen, todo = set(), [] for r in ROUNDS: + mine = [] for f, m in sets(r, False): texts = [(c["text"], c.get("expect") or c.get("kind")) for c in getattr(m, "CASES", []) if isinstance(c, dict) and c.get("text") and not c.get("before") and not c.get("ctx")] @@ -53,7 +56,8 @@ def first_words(): for t, e in texts: if t not in seen: seen.add(t) - todo.append((t, e, f"{r}/{f.rsplit('/', 1)[1][:-3]}")) + mine.append((t, e, f"{r}/{f.rsplit('/', 1)[1][:-3]}")) + todo += random.Random(1).sample(mine, SAMPLE) if SAMPLE and len(mine) > SAMPLE else mine embed([p for t, _, _ in todo for p in pieces(t)]) hits = 0 for t, e, where in todo: @@ -61,7 +65,7 @@ def first_words(): if k: hits += 1 print(f"{k:12} {where:22} {t!r} want={e}") - print("texts", len(seen), "quick", hits) + print("texts", len(todo), "quick", hits) def questions(): @@ -69,10 +73,15 @@ def questions(): cases = [c for r in ROUNDS for _, m in sets(r, True) for c in m.CASES] embed([p for c in cases for p in pieces(c["text"])]) want = hit = wrong = 0 + levels = {} for c in cases: k = qa.kind_of(c["text"]) quick = c["expect"] == "quick" want += quick + if quick: + lv = levels.setdefault(c.get("level") or c["lang"], [0, 0]) + lv[0] += 1 + lv[1] += k is not None if k is None: if quick and VERBOSE: print(f"miss [{c['q']}] {c['text']!r}") @@ -86,6 +95,7 @@ def questions(): if probs: wrong += 1 print(f"WRONG [{c['q']}, {c['expect']}] {c['text']!r} -> {k} {probs[:2]}") + print("want quick answered at once, by level: " + ", ".join(f"{lv} {h}/{n}" for lv, (n, h) in sorted(levels.items()))) print(f"{' '.join(ROUNDS)}: cases {len(cases)}, want quick {want}, answered at once {hit}, wrong quick answers {wrong}") diff --git a/tests/test_arm_bank.py b/tests/test_arm_bank.py index fb387bc..2360590 100644 --- a/tests/test_arm_bank.py +++ b/tests/test_arm_bank.py @@ -51,6 +51,8 @@ NEVER = [ # no motion at all from the bank ("shake your head", False), ("pick up the pace", False), ("give it up for lumi", False), ("thanks for the wave", False), ("악수해 줘서 고마워요", False), ("close your eyes", False), ("의자 들어 줄래?", False), ("the kids want to wave at you", False), ("can my son shake your hand", False), + ("shaking hands is fun", False), ("you folded your arm earlier", False), ("손 펴도 돼?", False), + ("팔 접는 게 좋아", False), ("you're good at opening your hand", False), ] diff --git a/tests/test_command_box.py b/tests/test_command_box.py index 84e64bf..988d90b 100644 --- a/tests/test_command_box.py +++ b/tests/test_command_box.py @@ -171,14 +171,16 @@ def plan(text, held=False): for st in r["steps"]) + (" !" + r["problems"][0] if r["problems"] else "") if a == "fetch": t = r["task"] - return " ".join(x for x in ("fetch", t["colour"], t["object"], f"{where(t['source'])}>{where(t['dest'])}", t["finish"]) if x) + return " ".join(x for x in ("fetch", t.get("prefer"), t["colour"], t["object"], f"{where(t['source'])}>{where(t['dest'])}", + t["finish"]) if x) if a in ("place", "give"): return a + (" on " + where(r["task"]["on"]) if (r.get("task") or {}).get("on") else "") if a == "carry": return f"carry {where(r['task']['dest'])} {r['task'].get('then') or 'hold'}" if a == "command": return "stop" if r["sentence"] == "Stop." else "chain" if "parts" in r else \ - "rule " + " ".join(x for x in r["rule"] if x) if "rule" in r else "talk" + "rule " + " ".join(x for x in r["rule"] if x) if "rule" in r else \ + "talk:status" if r.get("talk") == "status" else "talk" p = r.get("problems") or [] return "empty" if p and "hand is empty" in p[0] else "ask: " + p[0] if p else \ "ask: " + r["sentence"] if r.get("talk") == "refuse" else "talk" @@ -330,7 +332,47 @@ READ = [ # the owner's Korean cup / delivery list (2026-10-26 18:40), then mor ("excuse me robot, first look me, then follow me", False, "chain"), ("야 루미, 오른쪽 보고 손 흔들어라", False, "chain"), ("hello robot, first turn left, then lower yourself", False, "chain"), ("악수하고 lower yourself 해 주세요", False, "chain"), ("오늘 날짜 알리고 look left 해 주세요", False, "chain"), - ("wave 하고 look left 해 줘", False, "chain"), + ("wave 하고 look left 해 줘", False, "chain"), ("루미 님, 손 흔드시고 몸 내러 주시길 부탁드립니다", False, "chain"), + ("몸내리고오른쪽으로돌아주라", False, "chain"), ("컵들고exit가서기다려", False, "pick cup; go exit; wait"), + ("컵들고p5가서민수한테줘", False, "pick cup; go p5; give 민수"), ("컵 들구 p5 가서 기다리", False, "pick cup; go p5; wait"), + ("wait at p5 with the cup", False, "pick cup; go p5; wait"), ("lemme see you go charge", False, "go home"), + ("let me see you wave", False, "rule wave"), ("okay see you", False, "talk"), ("you come behind me", False, "rule follow"), + ("here's your task: get over here", False, "talk"), ("Mina, what are you doing over there?", False, "talk"), + ("민수야, 너 거기서 뭐 하고 있어?", False, "talk"), ("루미야 뭐 하고 있어?", False, "talk:status"), + ("계속 들고 있어 주세요", True, "talk"), ("keep holding it", True, "talk"), ("just hold it", True, "talk"), + ("give it back", True, "give"), ("돌려줘", True, "give"), ("hand it back to me", True, "give"), ("그거 다시 줘", True, "give"), + ("put it back where you found it", True, "place"), ("원래 있던 데 놔 주세요", True, "place"), + ("할머니께 이거 전해 드려", True, "give"), ("이거 저분께 드리세요", True, "give"), ("사장님께 드려 주십시오", True, "give"), + ("그 컵 저 주시면 돼요", True, "give"), ("저한테 주시겠어요?", True, "give"), ("내놔", True, "give"), ("그거 이리 내", True, "give"), + ("pass it to me", True, "give"), ("could I have it please", True, "give"), ("lemme have it", True, "give"), + ("give it to that lady", True, "give"), ("테이블에 놔 주시면 돼요", True, "place on table"), ("내려놔 주십시오", True, "place"), + ("p5로 가 주시겠어요?", True, "carry p5 hold"), + ("gimme the cup", False, "pick cup; give"), ("could ya grab the cup", False, "pick cup"), + ("can ya bring the cup to p5", False, "fetch cup here>p5 hold"), ("컵 줘요 빨리", False, "pick cup; give"), + ("would you be a dear and fetch the cup from p1", False, "fetch cup p1>here hold"), + ("kindly deliver the cup to p5", False, "pick cup; go p5; give"), + # which one and which side + ("왼쪽 컵 집어", False, "pick cup left"), ("pick up the cup on the left", False, "pick cup left"), + ("오른쪽에 있는 컵 집어 줘", False, "pick cup right"), ("grab the cup on your right", False, "pick cup right"), + ("grab the smaller cup", False, "pick cup small"), ("작은 컵 집어 줘", False, "pick cup small"), + ("제일 가까운 컵 집어", False, "pick cup near"), + ("컵 p3 왼쪽 테이블에 놔", False, "pick cup; go p3; place left table"), + ("put the cup on the left table at p3", False, "pick cup; go p3; place left table"), + ("p3 왼쪽 테이블에 놔", True, "go p3; place left table"), ("put it on the left table at p3", True, "go p3; place left table"), + ("오른쪽 테이블에 내려놔", True, "place right table"), ("오른쪽 테이블에 내려놔", False, "empty"), + ("왼쪽 테이블에 있는 컵 가져와", False, "fetch left cup here>here hold"), + ("bring me the cup from the right table", False, "fetch right cup here>here hold"), + # holding: the box reads the hand as voice does (E1's parity run, 2026-10-27): no motion on talk about it + ("give me a shake", True, "talk"), ("you wave hand please", True, "talk"), ("로봇아, 핸드 오픈 해 주세요", True, "talk"), + ("컵 내려놓지 마", True, "talk"), ("제자리에 놓지 마~", True, "talk"), ("탁자 위에 놓지 마 ㅋㅋ", True, "talk"), + ("옆 테이블에 놓지 마세요", True, "talk"), ("루미는 나한테 건네줄 수 있대", True, "talk"), ("루미가 나한테 건네주는 걸 봤나", True, "talk"), + ("mira mira put ur phone away honey", True, "talk"), ("캘리브레이션 보게, 아까 컵 내려어놓는 거 봤어?", True, "talk"), + ("애들 재우고 싶다, 루미, 내놔 제발", True, "talk"), ("우리 루미, 이리 내놔 봐", True, "give"), + ("로봇 씨, 나한테 지금 주십시오", True, "give"), ("할머니께 드려 봐", True, "give"), ("Lumi, I want you pass it to me", True, "give"), + ("저한테 주실 수 있으신가요?", True, "give"), ("선생님께 드리세요", True, "give"), ("lower it down", True, "place"), + ("you putt dawn that", True, "place"), ("lay it on this table lay it on this table please", True, "place"), + ("왼쪽에 내려놓고 오른편 컵 잡아 줘", True, "chain"), ("put it back", True, "place"), ("제자리에 갖다 놔", True, "place"), + ("pick up the cup on the left table", False, "pick cup left"), ("오른쪽 테이블에 있는 빨간 컵 집어 줘", False, "pick cup red right"), ("컵이랑 같이 p5로 가", False, "fetch cup here>p5 hold"), ("컵 하고 같이 exit 가 줘", False, "fetch cup here>exit hold"), ("컵 가지고 p5에서 기다려", False, "pick cup; go p5; wait"), ("컵 들고 p5에 가 있어", False, "pick cup; go p5; wait"), ("이 컵 p5까지 좀 날라 줘", False, "fetch cup here>p5 hold"), ("컵 좀 p5로 옮겨 줘", False, "fetch cup here>p5 hold"), diff --git a/tests/test_fetch.py b/tests/test_fetch.py index 2053d74..9b0c511 100644 --- a/tests/test_fetch.py +++ b/tests/test_fetch.py @@ -1135,6 +1135,9 @@ fetch._give = lambda say: (named.append(fetch.held_name()), fetch._set(holding=F st = run(fetch.run_steps, [{"do": "give"}]) fetch._give = real_give assert st["status"] == "done" and named == ["the white cup"], (st["log"], named) +fetch.held_by_skill({"object": "cup", "colour": "white"}) # a voice pick (skills.pick, not a fetch) +assert fetch.state()["held_object"] == {"object": "cup", "colour": "white"} and fetch.state()["status"] == "holding" +assert fetch.held_name() == "the white cup" and skills._held["what"]["object"] == "cup" fetch._set(holding=True, held_object={"object": "cup", "colour": "white"}) assert fetch.held_name("ko") == "흰 컵" fetch._set(holding=True, held_object={"object": "bottle", "colour": None}) diff --git a/tests/test_intents.py b/tests/test_intents.py index cf67b0e..d9bec69 100644 --- a/tests/test_intents.py +++ b/tests/test_intents.py @@ -159,7 +159,8 @@ HAND = { ("put it on that table", True): ("place", {"name": "dining table", "colour": None}), ("open your hand", True): ("refuse", brain.REFUSE_OPEN), ("손 펴", True): ("refuse", brain.REFUSE_OPEN), ("open your hand", False): None, ("take the cup", False): None, ("give me the cup", False): None, - ("grab that cup on the table", False): None, ("give it to Mina", True): None, ("put it back", True): None, + ("grab that cup on the table", False): None, ("give it to Mina", True): ("give", None), # as "미나한테 줘": given here + ("put it back", True): None, ("take it to p2 and put it on the table", True): None, ("just hold it", True): None, ("can you give things to people?", False): None, ("don't give it to him", True): None, ("팔 거둬", True): None, ("what happens if I put something in your hand?", False): None, ("I get it", False): None, diff --git a/tests/test_talk.py b/tests/test_talk.py index 5f3c901..961383b 100644 --- a/tests/test_talk.py +++ b/tests/test_talk.py @@ -57,6 +57,10 @@ def main(): ("", "블루투스 이름은 왜 그렇게 지었나?", ["블루투스"]), ("", "에펠탑의 높이는 얼마예요?", ["에펠탑"]), ("", "너 이름은 뭐야?", []), + ("emoji 얘기 좀 해 줘요", "Hey, 실례지만 처음 만든 해 언제인지 알려 주시겠습니까", ["emoji"]), + ("", "tell me about mirrors", ["mirrors"]), + ("", "아까 그 얘기 다시 해 줘", []), + ("", "네 얘기 좀 해 봐", []), ("", "루미 이름은 누가 지었어?", []), ("문어는 피가 무슨 색이야?", "심장은 몇 개고?", ["문어", "심장"])]: b = brain.Brain() @@ -70,6 +74,16 @@ def main(): assert b._after(none, "몇 살이야?")["action"] == "search" assert b._after(none, "그게 뭐예요?")["action"] == "search" + b = brain.Brain() # back to an earlier topic: that turn's answer as a hint + b.history = [("페트라가 뭐야?", "ACTION: none -\n요르단에 있는 바위를 깎아 만든 도시예요."), + ("물곰은 얼마나 작아?", "ACTION: none -\n0.5mm 정도예요."), ("그거 사실이야?", "ACTION: none -\n네.")] + assert "요르단" in b._back_to("다시 페트라 얘기로 돌아가서, 뭐라고 했지?") + assert "요르단" in b._fragment_hint("다시 페트라 얘기로 돌아가서, 뭐라고 했지?") + assert b._back_to("물곰은 왜 안 죽어?") == "" + b.history = [("Tell me about hydrogen", "ACTION: none -\nHydrogen is the most common element."), + ("What is salt for?", "ACTION: none -\nSeasoning."), ("ok", "ACTION: none -\nSure.")] + assert "most common" in b._back_to("again about hydrogen, what did you say?") + picked = [] talk_examples.pick = lambda said, lang, k=4, bank=None: picked.append(bank) or [] brain._examples("윤초는 뭐예요?", world=True)