robertkeus commited on
Commit
ea31958
Β·
verified Β·
1 Parent(s): 1575f10

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -115,12 +115,17 @@ def respond(msg, history):
115
  if is_glyph:
116
  keys = [BY_GLYPH[c][0] for c in msg] if all(c in BY_GLYPH for c in msg) else intent(msg)
117
  if keys:
118
- glyphs = "".join(chr(0x1400 + (ord(BY_KEY[k][1]) - 0x4e00)) for k in keys) # alien display
 
119
  code = to_code(keys)
120
- en = ", ".join(BY_KEY[k][3] for k in keys)
121
- return (f"In my language that's **{glyphs}** ({len(keys) * 2} bytes β€” vs "
122
- f"{len(msg)} in English). It means: *{en}*.\n\n```python\n{code}\n```\n\n"
123
- f"Running it: `solve({DEMO})` β†’ `{run(code)}`")
 
 
 
 
124
  return chat(history or [], msg) # otherwise, just converse
125
 
126
 
 
115
  if is_glyph:
116
  keys = [BY_GLYPH[c][0] for c in msg] if all(c in BY_GLYPH for c in msg) else intent(msg)
117
  if keys:
118
+ al = lambda g: chr(0x1400 + (ord(g) - 0x4e00)) # alien display glyph
119
+ glyphs = "".join(al(BY_KEY[k][1]) for k in keys)
120
  code = to_code(keys)
121
+ steps = "\n".join(f"{i+1}. *{BY_KEY[k][3]}* β†’ {al(BY_KEY[k][1])} β†’ `{BY_KEY[k][2]}`"
122
+ for i, k in enumerate(keys))
123
+ return (f"**🧠 Reasoning β€” I break the request into operations, encode each as one "
124
+ f"glyph, and compose the code:**\n{steps}\n\n"
125
+ f"**Message the agents actually send:** {glyphs} β€” "
126
+ f"**{len(keys) * 2} bytes** vs {len(msg)} in English "
127
+ f"({round((1 - len(keys)*2/max(len(msg),1))*100)}% smaller)\n\n"
128
+ f"```python\n{code}\n```\n\nRunning it: `solve({DEMO})` β†’ `{run(code)}`")
129
  return chat(history or [], msg) # otherwise, just converse
130
 
131