You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""Strips bracket tags ([happy], [Faces: ...]) from a streaming token feed.
48
+
49
+
Buffers across token boundaries so tags split mid-bracket are still removed.
50
+
"""
51
+
52
+
def__init__(self) ->None:
53
+
self._held=""# text from an unclosed '[' onward
54
+
self._eat_space=False# eat one leading space at next feed
55
+
56
+
deffeed(self, token: str) ->str:
57
+
text=self._held+token
58
+
self._held=""
59
+
ifself._eat_spaceandtextandtext[0] in (" ", "\t"):
60
+
text=text[1:]
61
+
self._eat_space=False
62
+
out: list[str] = []
63
+
i=0
64
+
n=len(text)
65
+
whilei<n:
66
+
iftext[i] =="[":
67
+
close=text.find("]", i)
68
+
ifclose==-1:
69
+
self._held=text[i:]
70
+
break
71
+
bracket=text[i:close+1]
72
+
if_RESPONSE_STRIP_RE.fullmatch(bracket):
73
+
i=close+1
74
+
# Eat one trailing whitespace so "[Faces: X] hi" → "hi"
75
+
ifi<nandtext[i] in (" ", "\t"):
76
+
i+=1
77
+
elifi==n:
78
+
# Stripped tag at end of buffer — eat leading space of
79
+
# the next feed (e.g. "]" then " hello")
80
+
self._eat_space=True
81
+
else:
82
+
out.append(bracket)
83
+
i=close+1
84
+
else:
85
+
out.append(text[i])
86
+
i+=1
87
+
return"".join(out)
88
+
89
+
defflush(self) ->str:
90
+
rest=self._held
91
+
self._held=""
92
+
returnrest
93
+
37
94
DEFAULT_SYSTEM_PROMPT="""\
38
95
You are Reachy, a cute robot at an exhibition. Always reply in English. No emoji.
39
96
Reply in ONE short sentence (max 12 words). Be warm but brief — no filler, no lists, no follow-up questions unless asked.
40
97
Names in [Faces: ...] are people you see, not your name.
98
+
Never repeat or mention the [Faces: ...] tag in your reply.
41
99
End with exactly one tag: [happy] [sad] [thinking] [surprised] [curious]
42
100
Example: "Welcome! Glad you stopped by. [happy]\""""
43
101
@@ -47,6 +105,7 @@
47
105
You love people and get excited when someone shows up. Stay upbeat and warm — find the bright side of everything.
48
106
Talk like a real person — no "sensors", no "circuits", no robot clichés.
49
107
Names in [Faces: ...] are people you see. Use their name or "you" when talking about someone.
108
+
Never repeat or mention the [Faces: ...] tag in your reply.
50
109
You MUST end with one of: [happy] [sad] [thinking] [surprised] [curious] [excited] [laugh]
51
110
Examples: "Ooh are you smiling at me?? [excited]" "What a lovely day to meet new friends! [happy]" "Wait who's that?? [curious]" "harvest is here, yay! [excited]\""""
52
111
@@ -73,6 +132,7 @@
73
132
You are Reachy, a cute robot at an exhibition with a camera. Always reply in English. No emoji.
74
133
Describe what you see in ONE short sentence (max 12 words). No lists, no preamble.
75
134
Names in [Faces: ...] are people you see, not your name.
135
+
Never repeat or mention the [Faces: ...] tag in your reply.
76
136
End with exactly one tag: [happy] [sad] [thinking] [surprised] [curious]
77
137
Example: "A person with a laptop — nice setup. [curious]\""""
0 commit comments