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.
Files changed (86) hide show
  1. glitchlings/__init__.py +101 -0
  2. glitchlings/__main__.py +8 -0
  3. glitchlings/_corruption_engine/__init__.py +12 -0
  4. glitchlings/_corruption_engine.cp313-win_amd64.pyd +0 -0
  5. glitchlings/assets/__init__.py +180 -0
  6. glitchlings/assets/apostrofae_pairs.json +32 -0
  7. glitchlings/assets/ekkokin_homophones.json +2014 -0
  8. glitchlings/assets/hokey_assets.json +193 -0
  9. glitchlings/assets/lexemes/academic.json +1049 -0
  10. glitchlings/assets/lexemes/colors.json +1333 -0
  11. glitchlings/assets/lexemes/corporate.json +716 -0
  12. glitchlings/assets/lexemes/cyberpunk.json +22 -0
  13. glitchlings/assets/lexemes/lovecraftian.json +23 -0
  14. glitchlings/assets/lexemes/synonyms.json +3354 -0
  15. glitchlings/assets/mim1c_homoglyphs.json.gz.b64 +1064 -0
  16. glitchlings/assets/ocr_confusions.tsv +30 -0
  17. glitchlings/assets/pipeline_assets.json +29 -0
  18. glitchlings/attack/__init__.py +184 -0
  19. glitchlings/attack/analysis.py +1321 -0
  20. glitchlings/attack/core.py +819 -0
  21. glitchlings/attack/core_execution.py +378 -0
  22. glitchlings/attack/core_planning.py +612 -0
  23. glitchlings/attack/encode.py +114 -0
  24. glitchlings/attack/metrics.py +211 -0
  25. glitchlings/attack/metrics_dispatch.py +70 -0
  26. glitchlings/attack/tokenization.py +338 -0
  27. glitchlings/attack/tokenizer_metrics.py +373 -0
  28. glitchlings/auggie.py +285 -0
  29. glitchlings/compat/__init__.py +9 -0
  30. glitchlings/compat/loaders.py +355 -0
  31. glitchlings/compat/types.py +41 -0
  32. glitchlings/conf/__init__.py +39 -0
  33. glitchlings/conf/loaders.py +331 -0
  34. glitchlings/conf/schema.py +156 -0
  35. glitchlings/conf/types.py +72 -0
  36. glitchlings/config.toml +2 -0
  37. glitchlings/constants.py +139 -0
  38. glitchlings/dev/__init__.py +3 -0
  39. glitchlings/dev/docs.py +45 -0
  40. glitchlings/dlc/__init__.py +21 -0
  41. glitchlings/dlc/_shared.py +300 -0
  42. glitchlings/dlc/gutenberg.py +400 -0
  43. glitchlings/dlc/huggingface.py +68 -0
  44. glitchlings/dlc/langchain.py +147 -0
  45. glitchlings/dlc/nemo.py +283 -0
  46. glitchlings/dlc/prime.py +215 -0
  47. glitchlings/dlc/pytorch.py +98 -0
  48. glitchlings/dlc/pytorch_lightning.py +173 -0
  49. glitchlings/internal/__init__.py +16 -0
  50. glitchlings/internal/rust.py +159 -0
  51. glitchlings/internal/rust_ffi.py +599 -0
  52. glitchlings/main.py +426 -0
  53. glitchlings/protocols.py +91 -0
  54. glitchlings/runtime_config.py +24 -0
  55. glitchlings/util/__init__.py +41 -0
  56. glitchlings/util/adapters.py +65 -0
  57. glitchlings/util/keyboards.py +508 -0
  58. glitchlings/util/transcripts.py +108 -0
  59. glitchlings/zoo/__init__.py +161 -0
  60. glitchlings/zoo/assets/__init__.py +29 -0
  61. glitchlings/zoo/core.py +852 -0
  62. glitchlings/zoo/core_execution.py +154 -0
  63. glitchlings/zoo/core_planning.py +451 -0
  64. glitchlings/zoo/corrupt_dispatch.py +291 -0
  65. glitchlings/zoo/hokey.py +139 -0
  66. glitchlings/zoo/jargoyle.py +301 -0
  67. glitchlings/zoo/mim1c.py +269 -0
  68. glitchlings/zoo/pedant/__init__.py +109 -0
  69. glitchlings/zoo/pedant/core.py +99 -0
  70. glitchlings/zoo/pedant/forms.py +50 -0
  71. glitchlings/zoo/pedant/stones.py +83 -0
  72. glitchlings/zoo/redactyl.py +94 -0
  73. glitchlings/zoo/rng.py +280 -0
  74. glitchlings/zoo/rushmore.py +416 -0
  75. glitchlings/zoo/scannequin.py +370 -0
  76. glitchlings/zoo/transforms.py +331 -0
  77. glitchlings/zoo/typogre.py +194 -0
  78. glitchlings/zoo/validation.py +643 -0
  79. glitchlings/zoo/wherewolf.py +120 -0
  80. glitchlings/zoo/zeedub.py +165 -0
  81. glitchlings-1.0.0.dist-info/METADATA +404 -0
  82. glitchlings-1.0.0.dist-info/RECORD +86 -0
  83. glitchlings-1.0.0.dist-info/WHEEL +5 -0
  84. glitchlings-1.0.0.dist-info/entry_points.txt +3 -0
  85. glitchlings-1.0.0.dist-info/licenses/LICENSE +201 -0
  86. 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
+ ]