Improve memory recall in Korean at every speech level

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-26 10:55:13 +09:00
co-authored by Claude Opus 5.5
parent d223ff475f
commit e3a1c123c9
3 changed files with 153 additions and 35 deletions
+60 -23
View File
@@ -290,8 +290,8 @@ def self_answer(text, lang="en"):
if _state.get("holding"):
parts.append(f"I'm holding {_state['holding']}." if not ko else f"손에 {_j(_held_ko(_state['holding']), '을', '를')} 들고 있어요.")
elif _state.get("gripper"):
parts.append({"open": ("My hand is open and empty.", "손은 펴져 있고 비어 있어요."),
"closed": ("My hand is closed, with nothing in it.", "손은 닫혀 있고 비어 있어요.")}[_state["gripper"]][ko])
parts.append({"open": ("My hand is open and empty.", "손은 펴져 있고, 아무것도 안 들고 있어요."),
"closed": ("My hand is closed, with nothing in it.", "손은 닫혀 있고, 아무것도 안 들고 있어요.")}[_state["gripper"]][ko])
return " ".join(parts) or None
@@ -360,6 +360,17 @@ def _object(text):
return None
def _colour(text, name):
"""The colour said with the thing ("a green apple", "초록 사과"), else None ("orange" the fruit is no colour)."""
from assistant import seeing
t = text.lower()
for w in sorted(seeing.COLOURS, key=len, reverse=True):
if w == name or w == "하늘" or not re.search(rf"(?<![a-z가-힣]){w}(?![a-z])", t):
continue
return seeing.COLOURS[w]
return None
def _thing_words(e, lang):
from assistant import seeing
if lang == "ko":
@@ -394,7 +405,14 @@ def seen_answer(text, lang="en", now=None, days="ask"):
(f" {when(other['t'], 'ko', now)}에 본 적은 있어요." if other else "")
return f"I haven't seen {'anyone' if name == 'person' else 'one'} {span_en}." + \
(f" I saw one {when(other['t'], 'en', now)}." if other else "")
e = hits[-1]
colour = _colour(text, name)
if colour and not any(e.get("colour") == colour for e in hits): # "a green apple?" when only a red one was seen
e = hits[-1]
if lang == "ko":
return f"{span_ko} {seeing._j(seeing.COLOUR_KO.get(colour, colour) + ' ' + word_ko, '은', '는')} 못 봤어요. " \
f"{when(e['t'], 'ko', now)}{_where(e, 'ko')} {seeing._j(_thing_words(e, 'ko'), '은', '는')} 봤어요."
return f"I haven't seen {seeing._a(name, colour)} {span_en}. I saw {_thing_words(e, 'en')} {when(e['t'], 'en', now)}{_where(e, 'en')}."
e = next((e for e in reversed(hits) if e.get("colour") == colour), hits[-1])
if lang == "ko":
return f"네, {when(e['t'], 'ko', now)}{_where(e, 'ko')} {seeing._j(_thing_words(e, 'ko'), '을', '를')} 봤어요."
return f"Yes, I saw {_thing_words(e, 'en')} {when(e['t'], 'en', now)}{_where(e, 'en')}."
@@ -435,13 +453,15 @@ SUMMARY_PROMPT = """Here is a conversation between a visitor and Lumi, a robot.
"summary": "<2-3 short sentences: what was asked and answered, in English>",
"facts": ["<each name, place, number or plan the visitor gave, in English>"],
"commands": ["<each command for Lumi agreed in the talk, e.g. go to p3 and wave>"],
"title_ko": "<the title in Korean>", "summary_ko": "<the summary in polite Korean (-요)>"}
"title_ko": "<the title in Korean>", "summary_ko": "<the summary in polite Korean (-요)>",
"facts_ko": ["<each fact in polite Korean (-요)>"]}
Only what is in the conversation; nothing else."""
SUMMARY_SCHEMA = {"type": "object", "properties": {"title": {"type": "string"}, "summary": {"type": "string"},
"facts": {"type": "array", "items": {"type": "string"}},
"commands": {"type": "array", "items": {"type": "string"}},
"title_ko": {"type": "string"}, "summary_ko": {"type": "string"}},
"required": ["title", "summary", "facts", "commands", "title_ko", "summary_ko"]}
"title_ko": {"type": "string"}, "summary_ko": {"type": "string"},
"facts_ko": {"type": "array", "items": {"type": "string"}}},
"required": ["title", "summary", "facts", "commands", "title_ko", "summary_ko", "facts_ko"]}
def _transcript(history):
@@ -463,7 +483,8 @@ def summarise(history, chat=None):
return {"title": str(out.get("title", "")).strip()[:60], "summary": str(out.get("summary", "")).strip()[:600],
"facts": [str(f)[:160] for f in out.get("facts", [])][:10],
"commands": [str(f)[:160] for f in out.get("commands", [])][:5],
"title_ko": str(out.get("title_ko", "")).strip()[:60], "summary_ko": str(out.get("summary_ko", "")).strip()[:600]}
"title_ko": str(out.get("title_ko", "")).strip()[:60], "summary_ko": str(out.get("summary_ko", "")).strip()[:600],
"facts_ko": [str(f)[:160] for f in out.get("facts_ko", [])][:10]}
def keep_talk(history, person=None, t=None, chat=None, embed=None, name=None):
@@ -517,14 +538,15 @@ RECALL_Q = re.compile( # a question about an earlier talk; "I remember when ..
r"\bwe (?:talked|spoke|chatted|discussed|were talking)\b|\bour (?:talk|chat|conversation)\b|"
r"\b(?:what|which) did (?:we|i) (?:talk|speak|chat|say|tell|ask)\b|\bwhat did you (?:tell|say to) me about\b|"
r"\bwhat (?:did )?we (?:talk|talked|discuss|discussed|chat|chatted)\b|\bdid (?:we|i) (?:talk|speak|chat|tell you|ask you|mention)\b|"
r"\bearlier (?:i|we) (?:said|told|asked|talked)\b|\bremember\W*$|\bremind me\b|\bwe had (?:a|our|that) (?:talk|chat|conversation)\b|"
r"\bearlier (?:i|we) (?:said|told|asked|talked)\b|\bremember(?: (?:that|this|it))?\W*$|\bring a bell\b|\bremind me\b|\bwe had (?:a|our|that) (?:talk|chat|conversation)\b|"
r"\bdid we have (?:a|any) (?:talk|chat|conversation)\b|\bdid i (?:tell|give) you\b|\bwhat (?:we|you) (?:said|told me|talked about)\b|"
r"(?:말해|알려|얘기해|이야기해) ?(?:줬|주었|드렸)(?:던|었|지|잖|죠)|(?:했던|나눴던|한) (?:얘기|이야기|대화)|"
r"(?:얘기|이야기|대화)\s*(?:\S+\s+)?(?:했잖|했었|했던|나눴)|무슨\s*(?:topic|주제)(?:였|이었)|"
r"기억\s*(?:이\s*)?(?:나|해|하|날)|생각\s*(?:이\s*)?나|"
r"(?:얘기|이야기|대화|말)(?:를|을)?\s*(?:했던|했었|나눴|나누었|나누셨|하셨|한 거|했지|했잖|했는|했죠|했어|했노|했나|했니|했냐|했더라|했습니까|했을까)",
r"(?:얘기|이야기|대화|말)(?:를|을)?\s*(?:했던|했었|나눴|나누었|나누셨|하셨|한 거|했지|했잖|했는|했죠|했어|했노|했나|했니|했냐|했더라|했습니까|했을까)|"
r"\b(?:remember|recall)\s*(?:해|하|나|돼|되)|\b(?:talk|chat|conversation)\s*(?:했던|했었|한 거|나눴)", # Konglish: "remember 해?"
re.I)
NOT_RECALL = re.compile(r"\bremember (?:to|that you|my|me)\b|\bremember me\?$|\b(?:i|we) (?:don'?t |do not )?remember\b|"
NOT_RECALL = re.compile(r"\bremember (?:to|that you|my|me)\b(?! (?:asking|telling|saying|talking|ask|tell|say|talk))|\bremember me\?$|\b(?:i|we) (?:don'?t |do not )?remember\b|"
r"\b(?:can|could|will|would) you remember\b(?! (?:what|when|our|that we|we))|기억력|기억해\s*(?:줘|주세요|둬|놔)", re.I)
GENERIC = re.compile(r"\b(?:what|which) did (?:we|i) (?:talk|speak|chat|say)(?: about)?\W*(?:today|yesterday|earlier|last time|before)?\W*$|"
r"무슨 ?(?:얘기|이야기|대화|말)|뭐(?:라고)? ?(?:얘기|이야기|말)", re.I)
@@ -547,7 +569,7 @@ CANT_REMEMBER = {"en": "I can't remember that.", "ko": "그건 기억이 안 나
OFFER_WAIT_S = 60 # s a "do you mean ...?" waits for yes / no
DETAIL = re.compile(r"\bremind me\b|\bwhat you (?:told|said)\b|\bmain point\b|\bthe point\b|\bconclusion\b|\bwhat was (?:it|that)(?: again)?\b|결론|요점|포인트|point|\bwhat (?:did|was it) you (?:say|tell|said|told)|\bwhat was (?:it|that|the \w+)\b|"
DETAIL = re.compile(r"\bremind me\b|\b(?:your|the) answer\b|\bwhat was your (?:point|answer)\b|\bwhat you (?:told|said)\b|\bmain point\b|\bthe point\b|\bconclusion\b|\bwhat was (?:it|that)(?: again)?\b|결론|요점|포인트|point|\bwhat (?:did|was it) you (?:say|tell|said|told)|\bwhat was (?:it|that|the \w+)\b|"
r"\btell me (?:more|again|what)\b|\bwhat did you (?:say|tell me)\b|\bwhat (?:you|we) said\b|\bthe details?\b|"
r"무슨 (?:얘기|이야기|말)(?:였|이었)|뭐라고 (?:했|하셨|말했)|다시 (?:말해|알려)|자세히|뭐였", re.I)
@@ -587,9 +609,12 @@ def _told(s, lang, detail=False, turn=-99):
talk has no Korean summary (the LLM then says it from the talk in its prompt)."""
_recall.update(talk=s, offered=[], left=[], turn=turn)
facts = " ".join(f if f.endswith(".") else f + "." for f in s.get("facts", [])[:3])
if lang == "ko":
ko = (s.get("facts_ko") or s.get("summary_ko")) if detail else s.get("summary_ko")
return f"{'' if detail else '네, 기억나요. '}{' '.join(ko) if isinstance(ko, list) else ko}" if ko else None
if lang == "ko": # a detail is the facts (the summary only names the topic)
facts_ko = " ".join(f if f.endswith(".") else f + "." for f in s.get("facts_ko", [])[:3])
if detail:
return facts_ko or (None if s.get("facts") else s.get("summary_ko")) or None
ko = s.get("summary_ko")
return f"네, 기억나요. {ko}" + (f" {facts_ko}" if facts_ko and facts_ko not in ko else "") if ko else None
if detail:
return f"I told you that {facts[:1].lower() + facts[1:]}" if facts else f"We talked about this: {s['summary']}"
return f"Yes, I remember. {s['summary']}" + (f" {facts}" if facts and facts not in s["summary"] else "")
@@ -601,10 +626,14 @@ that this it its was were is are had have has yesterday today tonight earlier mo
day days two right again what which so and oh going back to in on at of with still can could would will any something thing
things then there when where how much go ahead just okay ok well there's what's we've i've you've anything that's again,
tell, remember, now yes yeah no topic topics subject subjects um uh hmm oh wait right pls bro hey talk? chatted?
by way anyway also too stuff""".split())
_STOP_KO = re.compile(r"^(?:기억|얘기|이야기|대화|말|했|한|하|어제|오늘|아까|그저께|그제|이틀|우리|저|제가|내가|나랑|저랑|저와|나와|"
r"루미|그때|그거|그것|뭐|무슨|나눴|나누|거|것|요|혹시|있잖|맞|좀|다시|알려|아침|오전|오후|저녁|지난|전에|"
r"그래서|결론|요점|그러니까|줄|주|줘|알|있|없|해|할|뭔|어떤|무엇|어디|언제|이었|였|이에|예요|입니|이야|주제|remember|recall|talk|yesterday|today)")
by way anyway also too stuff answer point main back asking asked ask didn't don't ring bell""".split())
_STOP_KO = re.compile(r"^(?:기억|얘기|이야기|대화|말씀|말했|말한|했|어제|오늘|아까|그저께|그제|이틀|우리|제가|내가|나랑|저랑|저와|나와|"
r"루미|그때|그거|그것|무슨|나눴|나누|혹시|있잖|맞|좀|다시|알려|아침|오전|오후|저녁|지난|전에|"
r"그래서|결론|요점|그러니까|어떤|무엇|어디|언제|이었|였|이에|예요|입니|이야|주제|remember|recall|talk|yesterday|today|"
r"(?:그리고|그럼|그러면|그런데|근데|잠깐|궁금한|궁금해|참|저기|음|어|아|자|얘|야|위해서|위해|대해|대해서|관해|관해서|대한|관한)$|"
# one-syllable stems only alone or with a verb ending ("한 거", "해 줘"; not "한글", "해변", "주말")
r"(?:말|한|하|거|것|요|주|줘|줄|알|있|없|해|할|뭔|뭐|저)(?:[요어아지죠고던는신셨세시자게니냐나까서면기여였잖든다며라래려줘봐야해했할줄][가-힣]?)?$|"
r"(?:가|이|은|는|을|를|도|에|의|로|으로|에서)$)") # a particle left alone ("point가")
_KO_TAIL = re.compile(r"(?:에\s*대해서?|에\s*관해서?|이랑|랑|하고|얘기|이야기|은|는|을|를|도|에|의|요)+$")
@@ -618,6 +647,8 @@ def topic(text):
so a filler ("Class, listen: ...", "Jason, look") is not taken for a topic."""
m = FOCUS.search(text)
part = next((g for g in m.groups() if g), text) if m else text
if m and m.group(3): # "시청자분들 위해서 어제 한글 얘기": what follows the time word
part = re.split(r"(?:어제|오늘|아까|그저께|그제|이틀 ?전|지난번|저번에|우리|오늘 ?아침)\s*", part)[-1] or part
return (_words(part) if m else "") or _words(text)
@@ -637,10 +668,15 @@ def _words(text):
return " ".join(out)
NAMES_KO = {"cutshion": "쿳션 컷션 커션", "jaka": "자카", "lumi": "루미", "hangul": "한글", "chuseok": "추석", "kimchi": "김치",
"seoul": "서울", "busan": "부산", "jeju": "제주", "everest": "에베레스트"} # names a title may keep in English
def _hits(words, s):
"""The share of the topic words found in a talk's own words (English and Korean title, summary, facts); a
one-syllable Korean word only alone or with a particle ("달" is not in "달해요")."""
text = " ".join([s["title"], s["summary"], s.get("title_ko", ""), s.get("summary_ko", "")] + s.get("facts", [])).lower()
text += "".join(f" {ko}" for en, ko in NAMES_KO.items() if en in text) # "쿳션 얘기" for the talk "Cutshion"
n = 0
for w in words:
if w.isascii():
@@ -648,7 +684,7 @@ def _hits(words, s):
elif len(w) > 1:
n += w in text
else:
n += bool(re.search(rf"(?<![가-힣]){w}(?:[은는이가을를도의]|에서|에)?(?![가-힣])", text))
n += bool(re.search(rf"(?<![가-힣]){w}(?:들)?(?:[은는이가을를도의]|에서|에)?(?![가-힣])", text))
return n / len(words) if words else 0.0
@@ -691,7 +727,7 @@ def recall(text, lang="en", now=None, embed=None, history=()):
other_q = HAND_Q.search(text) or SEEN_Q.search(text) or PLACE_Q.search(text) or LIFT_Q.search(text)
if _recall["offered"] and now - _recall["at"] < OFFER_WAIT_S and not other_q:
yes = brain.confirm_answer(text)
if yes == "yes" or yes == "correction" and re.match(r"\W*(?:yes|yeah|yep|right|exactly|네|응|맞아|그래)\b", text, re.I):
if yes == "yes" or yes == "correction" and re.match(r"\W*(?:yes|yeah|yep|right|exactly|네|예|응|맞아|맞습니다|맞아요|그래|그렇|그거)", text, re.I):
return _told(_recall["offered"][-1], lang, turn=len(past))
if yes in ("no", "cancel") or yes == "correction" and re.match(r"\W*(?:no|nope|not that|아니|아뇨)\b", text, re.I):
if yes == "cancel":
@@ -709,7 +745,7 @@ def recall(text, lang="en", now=None, embed=None, history=()):
_recall["turn"] = len(past)
return out
recent = _recall.get("talk") and len(past) - _recall.get("turn", -99) <= RECENT_TURNS
if recent and DETAIL.search(text) and (not about or PRONOUN.search(text) or _hits(about.split(), _recall["talk"]) >= 0.5):
if recent and DETAIL.search(text) and (not about or _hits(about.split(), _recall["talk"]) >= 0.5): # not "back to chess: what was that?"
return _told(_recall["talk"], lang, detail=True, turn=len(past)) # "remind me what you said", "결론이 뭐였어요?"
if NAME_Q.search(text):
return name_answer(lang)
@@ -717,7 +753,7 @@ def recall(text, lang="en", now=None, embed=None, history=()):
return None
days = _asked_days(text)
words = [w for w in about.split() if len(w) > 2 or len(w) > 1 and not w.isascii()]
if words and days in (None, {0}) and any(w in f"{q} {a}".lower() for q, a in past for w in words):
if words and days in (None, {0}) and any(w in f"{q} {a}".lower() for q, a in past if not RECALL_Q.search(q) for w in words):
return None # a topic of this talk ("아까 배터리에 대해 뭐라고 하셨죠?"): the LLM has it
if days == "too old":
return ONLY_TWO_DAYS[lang]
@@ -819,7 +855,8 @@ def _clean(text):
return re.sub(r"(?<![\w'])(?:ur|u|pls|plz|da|dat|wat|r)(?![\w'])", lambda m: CHAT_EN[m.group(0).lower()], text, flags=re.I)
SEEN_MORE = re.compile(r"\W*(?:(?:and|what about|how about|or|then|so|also|그럼|그러면|그리고|아니면|또|혹시)\W+)*(?:the |an? |any )?"
SEEN_MORE = re.compile(r"\W*(?:(?:and|what about|how about|or|then|so|also|um|uh|oh|okay|ok|well|lumi|그럼|그러면|그리고|아니면|또|혹시|"
r"음|어|아|자|잠깐|저기|근데|그런데|루미야?)\W+)*(?:the |an? |any )?"
r"(?:[\w가-힣]+\s+)?([\w가-힣]+?)(?:은요|는요|이요|은|는|도|이나|나)?(?: either| too| then)?\W*", re.I)
+15 -11
View File
@@ -45,28 +45,32 @@ KO_CACHE = ROOT / "logs" / "memory_check_ko.json" # title -> Korean title / su
_ko = {}
def _korean(title, summary):
"""The Korean title and summary a live talk carries (memory.summarise asks the LLM for both): made once per talk by
the LLM and kept in KO_CACHE, so the rules-only runs need no LLM after the first."""
def _korean(title, summary, facts=()):
"""The Korean title, summary and facts a live talk carries (memory.summarise asks the LLM for them): made once per
talk by the LLM and kept in KO_CACHE, so the rules-only runs need no LLM after the first."""
key = f"{title}|{summary}"
if not _ko and KO_CACHE.exists():
_ko.update(json.loads(KO_CACHE.read_text()))
if key not in _ko:
if key not in _ko or facts and "facts_ko" not in _ko[key]:
from assistant import brain
out = json.loads(brain._chat([{"role": "system", "content": "Translate this robot's memory of a talk into Korean "
"as JSON: {\"title_ko\": \"<the title, 1-4 Korean words>\", \"summary_ko\": \"<the "
"summary in polite Korean (-요)>\"}. Names of people, robots and companies as they are "
"said in Korean (JAKA = 자카)."},
{"role": "user", "content": f"title: {title}\nsummary: {summary}"}],
{"type": "object", "properties": {"title_ko": {"type": "string"}, "summary_ko": {"type": "string"}},
"required": ["title_ko", "summary_ko"]}))
_ko[key] = {"title_ko": out["title_ko"].strip(), "summary_ko": out["summary_ko"].strip()}
"summary in polite Korean (-요)>\", \"facts_ko\": [\"<each fact in polite Korean (-요)>\"]}. "
"Names of people, robots and companies as they are said in Korean (JAKA = 자카)."},
{"role": "user", "content": f"title: {title}\nsummary: {summary}\nfacts: {json.dumps(list(facts))}"}],
{"type": "object", "properties": {"title_ko": {"type": "string"}, "summary_ko": {"type": "string"},
"facts_ko": {"type": "array", "items": {"type": "string"}}},
"required": ["title_ko", "summary_ko", "facts_ko"]}))
old = _ko.get(key, {}) # a title already made stays (the embeddings are cached by it)
_ko[key] = {"title_ko": old.get("title_ko") or out["title_ko"].strip(),
"summary_ko": old.get("summary_ko") or out["summary_ko"].strip(),
"facts_ko": [f.strip() for f in out["facts_ko"]][:len(facts)]}
KO_CACHE.write_text(json.dumps(_ko, ensure_ascii=False, indent=0))
return _ko[key]
def _talk(t):
ko = _korean(t["title"], t["summary"])
ko = _korean(t["title"], t["summary"], t.get("facts", []))
return {"t": epoch(t["when"]), "title": t["title"], "summary": t["summary"], "facts": t.get("facts", []),
"commands": t.get("commands", []), "person": t.get("person"), **ko,
"vec": _vec(f"{t['title']}. {t['summary']}"), "vec_ko": _vec(f"{ko['title_ko']}. {ko['summary_ko']}")}
+78 -1
View File
@@ -219,7 +219,7 @@ for q in ["where is your hand?", "is your hand open?", "Is your gripper closed?"
"what's in your hand?"]:
assert memory.reply(q, "en", NOW) == "My arm is in its resting pose, folded in front of me. My hand is open and empty.", q
for q in ["손 어디 있어?", "손 펴져 있어?", "손에 뭐 있어?", "그리퍼 닫혀 있어요?", "팔은 지금 어떤 상태야?"]:
assert memory.reply(q, "ko", NOW) == "팔은 앞에 접어 둔 기본 자세예요. 손은 펴져 있고 비어 있어요.", q
assert memory.reply(q, "ko", NOW) == "팔은 앞에 접어 둔 기본 자세예요. 손은 펴져 있고, 아무것도 안 들고 있어요.", q
memory._state.update(arm="give", gripper="closed", holding="the red cup")
assert memory.reply("where is your hand?", "en", NOW) == "My hand is held out in front of me. I'm holding the red cup."
assert memory.reply("손에 뭐 있어요?", "ko", NOW) == "손을 앞으로 내밀고 있어요. 손에 빨간색 컵을 들고 있어요."
@@ -259,6 +259,83 @@ assert ask("그저께 앵무 얘기 기억나?", "ko") == "그저께 오후 9시
assert ask("the day before yesterday we talked about the weather, remember?") == "I can't remember that."
memory._recall.update(offered=[], talk=None, listed=[])
# ---------- Korean at every speech level, Konglish, slips (the same meaning, the same answer) ----------
memory.DIR = Path(tempfile.mkdtemp())
memory._talk.update(name=None, track="p2", skip=False)
TOPICS.append(("hangul", "한글", "sejong", "세종"))
TOPICS.append(("cutshion", "쿳션"))
def kept(title, summary, facts, title_ko, summary_ko, facts_ko, hours, commands=()):
memory.keep_talk(birds, "p2", NOW - hours * HOUR, lambda m, fmt=None: json.dumps(
{"title": title, "summary": summary, "facts": facts, "commands": list(commands), "title_ko": title_ko,
"summary_ko": summary_ko, "facts_ko": facts_ko}), fake_embed)
kept("Birds", "Why birds fly south.", ["Many birds migrate south for food in winter."], "새들",
"새들이 왜 남쪽으로 가는지에 대한 이야기예요.", ["많은 새들이 겨울에 먹이를 찾아 남쪽으로 이동해요."], 25)
kept("Hangul", "Who made Hangul.", ["King Sejong made it in the 15th century."], "한글", "한글을 누가 만들었는지에 대한 이야기예요.",
["15세기에 세종대왕이 만들었어요."], 26)
kept("Cutshion", "When Cutshion was founded.", [], "Cutshion", "Cutshion이 언제 세워졌는지에 대한 이야기예요.", [], 27,
["go to p3 and wave"])
memory._recall.update(offered=[], talk=None, listed=[], left=[])
BIRDS_KO = "어제 오후 4시쯤에 새들에 대해 이야기한 거 말씀이세요?"
for q in ["어제 새 얘기 했던 거 기억나?", "어제 새 얘기 했던 거 기억나요?", "어제 새에 대해 이야기했던 것을 기억하십니까?",
"어제 새 얘기한 거 기억하시나요?", "어제 새 얘기 한 거 기억나니?", "어제 새 얘기했던 거 기억하세요?", # 반말 / 해요체 / 하십시오체 / honorific
"어제 새 얘기 했던 거 기억나나?", "어제 새 얘기 했던 거 기억 나냐?", "어제 새 얘기 했던 거 기억나노?", # friendly, dialect
"어제 새 얘기했던 거 생각나요?", "어제 새 얘기 했잖아, 기억 안 나?", "어제 저랑 새 얘기 나누셨던 거 기억나세요?",
"루미야 어제 새 얘기한 거 remember 해?", "Remember 어제 새 얘기?", "음 그 어제 새 얘기 기억나?", # Konglish, fillers
"잠깐, 시청자분들 위해서 어제 새 얘기 한 거 기억나요?"]:
memory._recall.update(offered=[], talk=None, listed=[], left=[])
assert memory.recall(q, "ko", NOW, embed=fake_embed) == BIRDS_KO, (q, memory.recall(q, "ko", NOW, embed=fake_embed))
for q in ["응", "네", "맞아요", "그렇습니다", "어 맞아"]: # yes at any level
memory.recall("어제 새 얘기 했던 거 기억나?", "ko", NOW, embed=fake_embed)
assert (memory.recall(q, "ko", NOW, embed=fake_embed) or "").startswith("네, 기억나요. 새들이 왜 남쪽으로"), (q, memory.recall(q, "ko", NOW, embed=fake_embed))
for q in ["그래서 결론이 뭐였어요?", "그때 뭐라고 했었지?", "그때 뭐라고 하셨죠?", "뭐라고 했는지 다시 말해 줄래?", "그때 point가 뭐였어요?",
"다시 remind 해 줘, 뭐라고 했어?"]: # the detail is the facts, in Korean
assert memory.recall(q, "ko", NOW, embed=fake_embed) == "많은 새들이 겨울에 먹이를 찾아 남쪽으로 이동해요.", q
memory._recall.update(offered=[], talk=None, listed=[], left=[])
assert memory.recall("한글 얘기 기억나세요? 어제 했던 거요.", "ko", NOW, embed=fake_embed) == "어제 오후 3시쯤에 한글에 대해 이야기한 거 말씀이세요?"
assert memory.recall("Remember 어제 쿳션 얘기?", "ko", NOW, embed=fake_embed).endswith("Cutshion에 대해 이야기한 거 말씀이세요?")
assert memory.recall("Going back to chess: what was that again?", "en", NOW, embed=fake_embed) is None # not the talk recalled
assert memory.recall("어제 문어 얘기 했던 거 기억나?", "ko", NOW, embed=fake_embed) == "그건 기억이 안 나요."
assert memory.recall("우리 무슨 주제로 얘기했었지?", "ko", NOW, embed=fake_embed).startswith("최근 이틀 동안") # "주제" is no topic
for q in ["지난주에 우리 무슨 얘기 했지?", "저번 주 월요일에 우리 뭐 얘기했어?", "last weekend 얘기 기억나?", "사흘 전에 내가 뭐라고 했는지 기억나?",
"what did we talk about last weekend?", "Remember what I told you three days ago?"]:
assert memory.recall(q, "ko", NOW, embed=fake_embed) in memory.ONLY_TWO_DAYS.values(), q
assert memory.recall("그저께 얘기한 거 기억나?", "ko", NOW, embed=fake_embed) == "그건 기억이 안 나요." # none that day
talk_now = [("배터리 얼마나 가?", "약 10시간 가요."), ("고마워", "천만에요.")]
assert memory.recall("아까 배터리에 대해 뭐라고 하셨습니까?", "ko", NOW, embed=fake_embed, history=talk_now) is None # this talk: the LLM
for q in ["어제 말한 거 해 줘", "어제 얘기한 대로 해 주세요", "어제 하기로 한 거 해", "어제 말씀드린 거 진행해 주십시오", "Do what we said yesterday."]:
out = memory.recall(q, "ko" if "어" in q else "en", NOW, embed=fake_embed)
assert "go to p3 and wave" in out and ("할까요" in out or "Shall I" in out), (q, out) # read back, asked, never done
for q in ["내 얘기 delete 해 줘", "그 대화 delete 좀 해 주세요", "I'd rather you didn't keep that", "Erase our talk, please.",
"다 잊어 주세요", "잊어 줘", "잊어버려", "제 이야기는 기억에서 지워 주십시오", "기억하지 마세요", "Please 잊어 주세요"]:
assert memory.FORGET.search(memory._clean(q)), q
# seen things: Korean levels, a colour asked, an elliptic follow-up, the hand state asked in Konglish
memory.saw([{"name": "bottle", "colour": "white"}], "", now=NOW - HOUR)
memory.saw([{"name": "cup", "colour": "red"}], "", now=NOW - 2 * HOUR)
for q in ["오늘 흰 병 봤어?", "오늘 흰 병 봤어요?", "오늘 흰 병 보셨습니까?", "오늘 흰 병 보셨어요?", "오늘 흰 병 봤나?", "오늘 white bottle 봤어?"]:
assert memory.reply(q, "ko", NOW).startswith("네, 오늘 오후 4시쯤"), q
assert memory.reply("그럼 빨간 컵은?", "ko", NOW).startswith("네, 오늘 오후 3시쯤")
assert memory.reply("음 그럼 초록 컵은?", "ko", NOW).startswith("오늘은 초록색 컵은 못 봤어요.")
assert memory.reply("did you see a green cup today?", "en", NOW).startswith("I haven't seen a green cup today. I saw a red cup")
memory._state.update(arm="look", gripper="open", holding=None, at=time.time())
for q in ["hand에 뭐 있어?", "너 hand에 뭐 있어?", "손에 뭐 있어요?", "손에 뭐 들고 계세요?", "그리퍼 열려 있어요?"]:
out = memory.reply(q, "ko", NOW)
assert out and "아무것도" in out, (q, out)
memory._state["at"] = 0.0
# privacy: only text, nothing of audio; a forget deletes only this person's talks; past 48 h gone
assert "audio" not in json.dumps(json.loads((memory.DIR / "talks.json").read_text()))
memory.keep_talk(birds, "p8", NOW - HOUR, fake_chat("Moon", "The moon."), fake_embed)
memory._talk.update(track="p2")
assert memory.reply("다 잊어 줘", "ko", NOW) == memory.FORGOT["ko"]
assert [s["title"] for s in memory._load("talks")] == ["Moon"]
memory.clock = lambda: NOW + 49 * HOUR
assert memory._load("talks") == [] and memory._load("seen") == []
memory.clock = lambda: NOW
memory._talk.update(name=None, track=None, skip=False)
# ---------- speed: a turn's lookups ----------
memory._state.update(body="Your body now: lift 75 mm.", at=time.time())
t = time.time()