glasschain 2.1.0__py3-none-any.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.
@@ -0,0 +1,61 @@
1
+ """GlassChain: Mechanistic interpretability library, CLI, and benchmark for Chain-of-Thought faithfulness."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from cot_faithfulness._version import __version__
6
+ from cot_faithfulness.banner import maybe_print_banner, render_banner
7
+ from cot_faithfulness.models import (
8
+ MODEL_REGISTRY,
9
+ ModelBackend,
10
+ ModelSpec,
11
+ TransformerLensBackend,
12
+ get_model_spec,
13
+ list_model_specs,
14
+ )
15
+ from cot_faithfulness.schema import (
16
+ SCHEMA_VERSION,
17
+ AblationStepResult,
18
+ BenchmarkIndex,
19
+ BenchmarkManifest,
20
+ ComponentPatchingStats,
21
+ ContrastivePair,
22
+ DatasetSummary,
23
+ DualMetricResult,
24
+ InterventionResult,
25
+ PatchingResult,
26
+ ProbeMetrics,
27
+ ProbingResult,
28
+ RigorChecklist,
29
+ RunProvenance,
30
+ SampleTrace,
31
+ )
32
+ from cot_faithfulness.tasks import get_task, list_tasks
33
+
34
+ __all__ = [
35
+ "__version__",
36
+ "SCHEMA_VERSION",
37
+ "MODEL_REGISTRY",
38
+ "ModelBackend",
39
+ "ModelSpec",
40
+ "TransformerLensBackend",
41
+ "get_model_spec",
42
+ "list_model_specs",
43
+ "get_task",
44
+ "list_tasks",
45
+ "maybe_print_banner",
46
+ "render_banner",
47
+ "AblationStepResult",
48
+ "BenchmarkIndex",
49
+ "BenchmarkManifest",
50
+ "ComponentPatchingStats",
51
+ "ContrastivePair",
52
+ "DatasetSummary",
53
+ "DualMetricResult",
54
+ "InterventionResult",
55
+ "PatchingResult",
56
+ "ProbeMetrics",
57
+ "ProbingResult",
58
+ "RigorChecklist",
59
+ "RunProvenance",
60
+ "SampleTrace",
61
+ ]
@@ -0,0 +1,5 @@
1
+ """Single-sourced package version for GlassChain (`glasschain` / `cot_faithfulness`)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ __version__ = "2.1.0"
@@ -0,0 +1,90 @@
1
+ """Bold, TTY-aware ASCII terminal banner for the GlassChain CLI."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import sys
7
+ from typing import TextIO
8
+
9
+ from cot_faithfulness._version import __version__
10
+
11
+ DOCS_URL = "https://ashioyajotham.github.io/cot-faithfulness-mech-interp/"
12
+
13
+ _ANSI_EMERALD = "\033[1;38;5;42m"
14
+ _ANSI_AMBER = "\033[1;38;5;214m"
15
+ _ANSI_DIM = "\033[2m"
16
+ _ANSI_RESET = "\033[0m"
17
+
18
+ _WORDMARK_LINES: tuple[str, ...] = (
19
+ " ██████╗ ██╗ █████╗ ███████╗███████╗ ██████╗██╗ ██╗ █████╗ ██╗███╗ ██╗",
20
+ "██╔════╝ ██║ ██╔══██╗██╔════╝██╔════╝██╔════╝██║ ██║██╔══██╗██║████╗ ██║",
21
+ "██║ ███╗██║ ███████║███████╗███████╗██║ ███████║███████║██║██╔██╗ ██║",
22
+ "██║ ██║██║ ██╔══██║╚════██║╚════██║██║ ██╔══██║██╔══██║██║██║╚██╗██║",
23
+ "╚██████╔╝███████╗██║ ██║███████║███████║╚██████╗██║ ██║██║ ██║██║██║ ╚████║",
24
+ " ╚═════╝ ╚══════╝╚═╝ ╚═╝╚══════╝╚══════╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝",
25
+ )
26
+
27
+
28
+ def _is_tty(stream: TextIO | None) -> bool:
29
+ target = sys.stdout if stream is None else stream
30
+ isatty = getattr(target, "isatty", None)
31
+ return bool(isatty()) if callable(isatty) else False
32
+
33
+
34
+ def should_use_color(stream: TextIO | None = None) -> bool:
35
+ """Return True iff `stream` is a TTY and `NO_COLOR` is unset."""
36
+ if os.environ.get("NO_COLOR") is not None:
37
+ return False
38
+ return _is_tty(stream)
39
+
40
+
41
+ def render_banner(color: bool | None = None, stream: TextIO | None = None) -> str:
42
+ """Render the GlassChain ASCII wordmark and faithful-vs-shortcut circuit visual."""
43
+ use_color = should_use_color(stream) if color is None else bool(color)
44
+
45
+ if use_color:
46
+ wordmark = "\n".join(f"{_ANSI_EMERALD}{line}{_ANSI_RESET}" for line in _WORDMARK_LINES)
47
+ faithful_line = (
48
+ f" {_ANSI_EMERALD}[STEP 1] ──▶ [STEP 2] ──▶ [ANSWER]{_ANSI_RESET}"
49
+ f" {_ANSI_DIM}· CoT Faithfulness Mechanistic Workbench{_ANSI_RESET}"
50
+ )
51
+ shortcut_line = (
52
+ f" {_ANSI_AMBER}╰── hidden shortcut? ──╯{_ANSI_RESET}"
53
+ f" {_ANSI_DIM}· v{__version__} · {DOCS_URL}{_ANSI_RESET}"
54
+ )
55
+ else:
56
+ wordmark = "\n".join(_WORDMARK_LINES)
57
+ faithful_line = (
58
+ " [STEP 1] ──▶ [STEP 2] ──▶ [ANSWER]"
59
+ " · CoT Faithfulness Mechanistic Workbench"
60
+ )
61
+ shortcut_line = (
62
+ " ╰── hidden shortcut? ──╯"
63
+ f" · v{__version__} · {DOCS_URL}"
64
+ )
65
+
66
+ return f"{wordmark}\n\n{faithful_line}\n{shortcut_line}\n"
67
+
68
+
69
+ def maybe_print_banner(
70
+ no_banner: bool = False,
71
+ stream: TextIO | None = None,
72
+ *,
73
+ force: bool = False,
74
+ color: bool | None = None,
75
+ ) -> bool:
76
+ """Print the GlassChain banner when interactive, unless suppressed.
77
+
78
+ Auto-suppressed when `no_banner=True`, `GLASSCHAIN_NO_BANNER=1`, or
79
+ `not stream.isatty()` (unless `force=True`, e.g. for `glasschain banner`).
80
+ """
81
+ target = sys.stdout if stream is None else stream
82
+ if not force:
83
+ if no_banner or os.environ.get("GLASSCHAIN_NO_BANNER") == "1":
84
+ return False
85
+ if not _is_tty(target):
86
+ return False
87
+
88
+ target.write(render_banner(color=color, stream=target))
89
+ target.flush()
90
+ return True