glitchlings 1.0.0__cp313-cp313-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- glitchlings/__init__.py +101 -0
- glitchlings/__main__.py +8 -0
- glitchlings/_corruption_engine/__init__.py +12 -0
- glitchlings/_corruption_engine.cp313-win_amd64.pyd +0 -0
- glitchlings/assets/__init__.py +180 -0
- glitchlings/assets/apostrofae_pairs.json +32 -0
- glitchlings/assets/ekkokin_homophones.json +2014 -0
- glitchlings/assets/hokey_assets.json +193 -0
- glitchlings/assets/lexemes/academic.json +1049 -0
- glitchlings/assets/lexemes/colors.json +1333 -0
- glitchlings/assets/lexemes/corporate.json +716 -0
- glitchlings/assets/lexemes/cyberpunk.json +22 -0
- glitchlings/assets/lexemes/lovecraftian.json +23 -0
- glitchlings/assets/lexemes/synonyms.json +3354 -0
- glitchlings/assets/mim1c_homoglyphs.json.gz.b64 +1064 -0
- glitchlings/assets/ocr_confusions.tsv +30 -0
- glitchlings/assets/pipeline_assets.json +29 -0
- glitchlings/attack/__init__.py +184 -0
- glitchlings/attack/analysis.py +1321 -0
- glitchlings/attack/core.py +819 -0
- glitchlings/attack/core_execution.py +378 -0
- glitchlings/attack/core_planning.py +612 -0
- glitchlings/attack/encode.py +114 -0
- glitchlings/attack/metrics.py +211 -0
- glitchlings/attack/metrics_dispatch.py +70 -0
- glitchlings/attack/tokenization.py +338 -0
- glitchlings/attack/tokenizer_metrics.py +373 -0
- glitchlings/auggie.py +285 -0
- glitchlings/compat/__init__.py +9 -0
- glitchlings/compat/loaders.py +355 -0
- glitchlings/compat/types.py +41 -0
- glitchlings/conf/__init__.py +39 -0
- glitchlings/conf/loaders.py +331 -0
- glitchlings/conf/schema.py +156 -0
- glitchlings/conf/types.py +72 -0
- glitchlings/config.toml +2 -0
- glitchlings/constants.py +139 -0
- glitchlings/dev/__init__.py +3 -0
- glitchlings/dev/docs.py +45 -0
- glitchlings/dlc/__init__.py +21 -0
- glitchlings/dlc/_shared.py +300 -0
- glitchlings/dlc/gutenberg.py +400 -0
- glitchlings/dlc/huggingface.py +68 -0
- glitchlings/dlc/langchain.py +147 -0
- glitchlings/dlc/nemo.py +283 -0
- glitchlings/dlc/prime.py +215 -0
- glitchlings/dlc/pytorch.py +98 -0
- glitchlings/dlc/pytorch_lightning.py +173 -0
- glitchlings/internal/__init__.py +16 -0
- glitchlings/internal/rust.py +159 -0
- glitchlings/internal/rust_ffi.py +599 -0
- glitchlings/main.py +426 -0
- glitchlings/protocols.py +91 -0
- glitchlings/runtime_config.py +24 -0
- glitchlings/util/__init__.py +41 -0
- glitchlings/util/adapters.py +65 -0
- glitchlings/util/keyboards.py +508 -0
- glitchlings/util/transcripts.py +108 -0
- glitchlings/zoo/__init__.py +161 -0
- glitchlings/zoo/assets/__init__.py +29 -0
- glitchlings/zoo/core.py +852 -0
- glitchlings/zoo/core_execution.py +154 -0
- glitchlings/zoo/core_planning.py +451 -0
- glitchlings/zoo/corrupt_dispatch.py +291 -0
- glitchlings/zoo/hokey.py +139 -0
- glitchlings/zoo/jargoyle.py +301 -0
- glitchlings/zoo/mim1c.py +269 -0
- glitchlings/zoo/pedant/__init__.py +109 -0
- glitchlings/zoo/pedant/core.py +99 -0
- glitchlings/zoo/pedant/forms.py +50 -0
- glitchlings/zoo/pedant/stones.py +83 -0
- glitchlings/zoo/redactyl.py +94 -0
- glitchlings/zoo/rng.py +280 -0
- glitchlings/zoo/rushmore.py +416 -0
- glitchlings/zoo/scannequin.py +370 -0
- glitchlings/zoo/transforms.py +331 -0
- glitchlings/zoo/typogre.py +194 -0
- glitchlings/zoo/validation.py +643 -0
- glitchlings/zoo/wherewolf.py +120 -0
- glitchlings/zoo/zeedub.py +165 -0
- glitchlings-1.0.0.dist-info/METADATA +404 -0
- glitchlings-1.0.0.dist-info/RECORD +86 -0
- glitchlings-1.0.0.dist-info/WHEEL +5 -0
- glitchlings-1.0.0.dist-info/entry_points.txt +3 -0
- glitchlings-1.0.0.dist-info/licenses/LICENSE +201 -0
- glitchlings-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import ast
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from .core import Gaggle, Glitchling, plan_operations
|
|
7
|
+
from .hokey import Hokey, hokey
|
|
8
|
+
from .jargoyle import Jargoyle, jargoyle
|
|
9
|
+
from .mim1c import Mim1c, mim1c
|
|
10
|
+
from .pedant import Pedant, pedant
|
|
11
|
+
from .redactyl import Redactyl, redactyl
|
|
12
|
+
from .rushmore import Rushmore, RushmoreMode, rushmore
|
|
13
|
+
from .scannequin import Scannequin, scannequin
|
|
14
|
+
from .typogre import Typogre, typogre
|
|
15
|
+
from .wherewolf import Wherewolf, wherewolf
|
|
16
|
+
from .zeedub import Zeedub, zeedub
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"Typogre",
|
|
20
|
+
"typogre",
|
|
21
|
+
"Mim1c",
|
|
22
|
+
"mim1c",
|
|
23
|
+
"Jargoyle",
|
|
24
|
+
"jargoyle",
|
|
25
|
+
"Wherewolf",
|
|
26
|
+
"wherewolf",
|
|
27
|
+
"Hokey",
|
|
28
|
+
"hokey",
|
|
29
|
+
"Rushmore",
|
|
30
|
+
"RushmoreMode",
|
|
31
|
+
"rushmore",
|
|
32
|
+
"Redactyl",
|
|
33
|
+
"redactyl",
|
|
34
|
+
"Scannequin",
|
|
35
|
+
"scannequin",
|
|
36
|
+
"Zeedub",
|
|
37
|
+
"zeedub",
|
|
38
|
+
"Pedant",
|
|
39
|
+
"pedant",
|
|
40
|
+
"Glitchling",
|
|
41
|
+
"Gaggle",
|
|
42
|
+
"plan_operations",
|
|
43
|
+
"summon",
|
|
44
|
+
"BUILTIN_GLITCHLINGS",
|
|
45
|
+
"DEFAULT_GLITCHLING_NAMES",
|
|
46
|
+
"parse_glitchling_spec",
|
|
47
|
+
"get_glitchling_class",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
_BUILTIN_GLITCHLING_LIST: list[Glitchling] = [
|
|
51
|
+
typogre,
|
|
52
|
+
hokey,
|
|
53
|
+
mim1c,
|
|
54
|
+
wherewolf,
|
|
55
|
+
pedant,
|
|
56
|
+
jargoyle,
|
|
57
|
+
rushmore,
|
|
58
|
+
redactyl,
|
|
59
|
+
scannequin,
|
|
60
|
+
zeedub,
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
BUILTIN_GLITCHLINGS: dict[str, Glitchling] = {
|
|
64
|
+
glitchling.name.lower(): glitchling for glitchling in _BUILTIN_GLITCHLING_LIST
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
_BUILTIN_GLITCHLING_TYPES: dict[str, type[Glitchling]] = {
|
|
68
|
+
typogre.name.lower(): Typogre,
|
|
69
|
+
wherewolf.name.lower(): Wherewolf,
|
|
70
|
+
hokey.name.lower(): Hokey,
|
|
71
|
+
mim1c.name.lower(): Mim1c,
|
|
72
|
+
pedant.name.lower(): Pedant,
|
|
73
|
+
jargoyle.name.lower(): Jargoyle,
|
|
74
|
+
rushmore.name.lower(): Rushmore,
|
|
75
|
+
redactyl.name.lower(): Redactyl,
|
|
76
|
+
scannequin.name.lower(): Scannequin,
|
|
77
|
+
zeedub.name.lower(): Zeedub,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
DEFAULT_GLITCHLING_NAMES: list[str] = ["typogre", "scannequin"]
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def parse_glitchling_spec(specification: str) -> Glitchling:
|
|
84
|
+
"""Return a glitchling instance configured according to ``specification``."""
|
|
85
|
+
text = specification.strip()
|
|
86
|
+
if not text:
|
|
87
|
+
raise ValueError("Glitchling specification cannot be empty.")
|
|
88
|
+
|
|
89
|
+
if "(" not in text:
|
|
90
|
+
glitchling = BUILTIN_GLITCHLINGS.get(text.lower())
|
|
91
|
+
if glitchling is None:
|
|
92
|
+
raise ValueError(f"Glitchling '{text}' not found.")
|
|
93
|
+
return glitchling
|
|
94
|
+
|
|
95
|
+
if not text.endswith(")"):
|
|
96
|
+
raise ValueError(f"Invalid parameter syntax for glitchling '{text}'.")
|
|
97
|
+
|
|
98
|
+
name_part, arg_source = text[:-1].split("(", 1)
|
|
99
|
+
name = name_part.strip()
|
|
100
|
+
if not name:
|
|
101
|
+
raise ValueError(f"Invalid glitchling specification '{text}'.")
|
|
102
|
+
|
|
103
|
+
lower_name = name.lower()
|
|
104
|
+
glitchling_type = _BUILTIN_GLITCHLING_TYPES.get(lower_name)
|
|
105
|
+
if glitchling_type is None:
|
|
106
|
+
raise ValueError(f"Glitchling '{name}' not found.")
|
|
107
|
+
|
|
108
|
+
try:
|
|
109
|
+
call_expr = ast.parse(f"_({arg_source})", mode="eval").body
|
|
110
|
+
except SyntaxError as exc:
|
|
111
|
+
raise ValueError(f"Invalid parameter syntax for glitchling '{name}': {exc.msg}") from exc
|
|
112
|
+
|
|
113
|
+
if not isinstance(call_expr, ast.Call) or call_expr.args:
|
|
114
|
+
raise ValueError(f"Glitchling '{name}' parameters must be provided as keyword arguments.")
|
|
115
|
+
|
|
116
|
+
kwargs: dict[str, Any] = {}
|
|
117
|
+
for keyword in call_expr.keywords:
|
|
118
|
+
if keyword.arg is None:
|
|
119
|
+
raise ValueError(
|
|
120
|
+
f"Glitchling '{name}' does not support unpacking arbitrary keyword arguments."
|
|
121
|
+
)
|
|
122
|
+
try:
|
|
123
|
+
kwargs[keyword.arg] = ast.literal_eval(keyword.value)
|
|
124
|
+
except (ValueError, SyntaxError) as exc:
|
|
125
|
+
raise ValueError(
|
|
126
|
+
f"Failed to parse value for parameter '{keyword.arg}' on glitchling '{name}': {exc}"
|
|
127
|
+
) from exc
|
|
128
|
+
|
|
129
|
+
try:
|
|
130
|
+
return glitchling_type(**kwargs)
|
|
131
|
+
except TypeError as exc:
|
|
132
|
+
raise ValueError(f"Failed to instantiate glitchling '{name}': {exc}") from exc
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def get_glitchling_class(name: str) -> type[Glitchling]:
|
|
136
|
+
"""Look up the glitchling class registered under ``name``."""
|
|
137
|
+
key = name.strip().lower()
|
|
138
|
+
if not key:
|
|
139
|
+
raise ValueError("Glitchling name cannot be empty.")
|
|
140
|
+
|
|
141
|
+
glitchling_type = _BUILTIN_GLITCHLING_TYPES.get(key)
|
|
142
|
+
if glitchling_type is None:
|
|
143
|
+
raise ValueError(f"Glitchling '{name}' not found.")
|
|
144
|
+
|
|
145
|
+
return glitchling_type
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def summon(glitchlings: list[str | Glitchling], seed: int = 151) -> Gaggle:
|
|
149
|
+
"""Summon glitchlings by name (using defaults) or instance (to change parameters)."""
|
|
150
|
+
summoned: list[Glitchling] = []
|
|
151
|
+
for entry in glitchlings:
|
|
152
|
+
if isinstance(entry, Glitchling):
|
|
153
|
+
summoned.append(entry)
|
|
154
|
+
continue
|
|
155
|
+
|
|
156
|
+
try:
|
|
157
|
+
summoned.append(parse_glitchling_spec(entry))
|
|
158
|
+
except ValueError as exc:
|
|
159
|
+
raise ValueError(str(exc)) from exc
|
|
160
|
+
|
|
161
|
+
return Gaggle(summoned, seed=seed)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Compatibility shim for the relocated asset helpers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from glitchlings.assets import (
|
|
6
|
+
PIPELINE_ASSET_SPECS,
|
|
7
|
+
PIPELINE_ASSETS,
|
|
8
|
+
AssetKind,
|
|
9
|
+
PipelineAsset,
|
|
10
|
+
hash_asset,
|
|
11
|
+
load_homophone_groups,
|
|
12
|
+
load_json,
|
|
13
|
+
open_binary,
|
|
14
|
+
open_text,
|
|
15
|
+
read_text,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"AssetKind",
|
|
20
|
+
"PipelineAsset",
|
|
21
|
+
"PIPELINE_ASSETS",
|
|
22
|
+
"PIPELINE_ASSET_SPECS",
|
|
23
|
+
"hash_asset",
|
|
24
|
+
"load_homophone_groups",
|
|
25
|
+
"load_json",
|
|
26
|
+
"open_binary",
|
|
27
|
+
"open_text",
|
|
28
|
+
"read_text",
|
|
29
|
+
]
|