Spaces:
Running on Zero
Running on Zero
Revert to 77ad1e5b: undo the last deployment
Browse files- app.py +9 -3
- sentence_encode.py +7 -2
app.py
CHANGED
|
@@ -115,8 +115,11 @@ def encode(message, topic, key, attempts):
|
|
| 115 |
return "", (f"Message is {len(message)} characters; the cap is "
|
| 116 |
f"{MAX_MESSAGE_CHARS} so a single run stays inside a "
|
| 117 |
f"reasonable slice of your daily GPU quota.")
|
| 118 |
-
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
bits = pc.compress_to_bits(message)
|
| 122 |
prompt = se.build_prompt(TOK, (topic or "the sea").strip(), think=False)
|
|
@@ -149,6 +152,8 @@ def encode(message, topic, key, attempts):
|
|
| 149 |
+ f" | {dt:.0f}s", flush=True)
|
| 150 |
note = ("Verified: this text decodes back to your message." if ok else
|
| 151 |
"This run did not verify. Try again, or raise Attempts.")
|
|
|
|
|
|
|
| 152 |
return text.strip(), note
|
| 153 |
|
| 154 |
|
|
@@ -169,7 +174,8 @@ with gr.Blocks(title="Garfield-Naruto Encoder") as demo:
|
|
| 169 |
placeholder="Enter your secret message here.")
|
| 170 |
topic = gr.Textbox(label="Topic",
|
| 171 |
placeholder="Choose a topic for the LLM slop.")
|
| 172 |
-
key_in = gr.Textbox(label="Key",
|
|
|
|
| 173 |
type="password")
|
| 174 |
attempts = gr.Number(label="Attempts", value=6, minimum=1, maximum=10,
|
| 175 |
precision=0)
|
|
|
|
| 115 |
return "", (f"Message is {len(message)} characters; the cap is "
|
| 116 |
f"{MAX_MESSAGE_CHARS} so a single run stays inside a "
|
| 117 |
f"reasonable slice of your daily GPU quota.")
|
| 118 |
+
# An empty key is allowed and means no key: the fixed base alphabet, which
|
| 119 |
+
# the site's decoder also uses for an empty key field. The key is passed on
|
| 120 |
+
# untrimmed because the browser decoder does not trim either, so " " is a
|
| 121 |
+
# real key on both sides and they cannot disagree about it.
|
| 122 |
+
key = key or None
|
| 123 |
|
| 124 |
bits = pc.compress_to_bits(message)
|
| 125 |
prompt = se.build_prompt(TOK, (topic or "the sea").strip(), think=False)
|
|
|
|
| 152 |
+ f" | {dt:.0f}s", flush=True)
|
| 153 |
note = ("Verified: this text decodes back to your message." if ok else
|
| 154 |
"This run did not verify. Try again, or raise Attempts.")
|
| 155 |
+
if ok and key is None:
|
| 156 |
+
note += " No key was set, so anyone can decode it."
|
| 157 |
return text.strip(), note
|
| 158 |
|
| 159 |
|
|
|
|
| 174 |
placeholder="Enter your secret message here.")
|
| 175 |
topic = gr.Textbox(label="Topic",
|
| 176 |
placeholder="Choose a topic for the LLM slop.")
|
| 177 |
+
key_in = gr.Textbox(label="Key",
|
| 178 |
+
placeholder="Pick a secret key (optional).",
|
| 179 |
type="password")
|
| 180 |
attempts = gr.Number(label="Attempts", value=6, minimum=1, maximum=10,
|
| 181 |
precision=0)
|
sentence_encode.py
CHANGED
|
@@ -280,7 +280,11 @@ def _letter_roles(key, pos: int) -> np.ndarray:
|
|
| 280 |
text each letter lands in each role about equally. A greedy pass in the keyed
|
| 281 |
order fills the currently lightest role, keeping each role ~1/3 of letter
|
| 282 |
frequency for fluency. key=None returns the fixed base assignment."""
|
| 283 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
return _BASE_ROLE
|
| 285 |
sums = [0.0, 0.0, 0.0]
|
| 286 |
role = np.empty(26, dtype=np.int8)
|
|
@@ -964,7 +968,8 @@ def main() -> None:
|
|
| 964 |
ap.add_argument("--seed", type=int, default=0)
|
| 965 |
ap.add_argument("--key", default=None,
|
| 966 |
help="secret key: shuffles the letter->bit alphabet per character; the "
|
| 967 |
-
"recipient needs the same key to decode (omit
|
|
|
|
| 968 |
ap.add_argument("--clean", action="store_true",
|
| 969 |
help="print only the cover text — no progress, no verification. The "
|
| 970 |
"exit code still reports whether the payload verified.")
|
|
|
|
| 280 |
text each letter lands in each role about equally. A greedy pass in the keyed
|
| 281 |
order fills the currently lightest role, keeping each role ~1/3 of letter
|
| 282 |
frequency for fluency. key=None returns the fixed base assignment."""
|
| 283 |
+
# An empty key means no key, exactly as in the browser decoder (script.js
|
| 284 |
+
# letterRoles: null, undefined and '' all return the base alphabet). Hashing
|
| 285 |
+
# '' as a real key instead meant text encoded with a blank key field could not
|
| 286 |
+
# be decoded on the site. No trimming on either side: " " is a real key.
|
| 287 |
+
if not key:
|
| 288 |
return _BASE_ROLE
|
| 289 |
sums = [0.0, 0.0, 0.0]
|
| 290 |
role = np.empty(26, dtype=np.int8)
|
|
|
|
| 968 |
ap.add_argument("--seed", type=int, default=0)
|
| 969 |
ap.add_argument("--key", default=None,
|
| 970 |
help="secret key: shuffles the letter->bit alphabet per character; the "
|
| 971 |
+
"recipient needs the same key to decode (omit it, or pass an empty "
|
| 972 |
+
"string, for the fixed alphabet that anyone can decode)")
|
| 973 |
ap.add_argument("--clean", action="store_true",
|
| 974 |
help="print only the cover text — no progress, no verification. The "
|
| 975 |
"exit code still reports whether the payload verified.")
|