syntaxmatrix 1.4.6__py3-none-any.whl → 2.5.5.4__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.
- syntaxmatrix/__init__.py +13 -8
- syntaxmatrix/agentic/__init__.py +0 -0
- syntaxmatrix/agentic/agent_tools.py +24 -0
- syntaxmatrix/agentic/agents.py +810 -0
- syntaxmatrix/agentic/code_tools_registry.py +37 -0
- syntaxmatrix/agentic/model_templates.py +1790 -0
- syntaxmatrix/auth.py +308 -14
- syntaxmatrix/commentary.py +328 -0
- syntaxmatrix/core.py +993 -375
- syntaxmatrix/dataset_preprocessing.py +218 -0
- syntaxmatrix/db.py +92 -95
- syntaxmatrix/display.py +95 -121
- syntaxmatrix/generate_page.py +634 -0
- syntaxmatrix/gpt_models_latest.py +46 -0
- syntaxmatrix/history_store.py +26 -29
- syntaxmatrix/kernel_manager.py +96 -17
- syntaxmatrix/llm_store.py +1 -1
- syntaxmatrix/plottings.py +6 -0
- syntaxmatrix/profiles.py +64 -8
- syntaxmatrix/project_root.py +55 -43
- syntaxmatrix/routes.py +5072 -1398
- syntaxmatrix/session.py +19 -0
- syntaxmatrix/settings/logging.py +40 -0
- syntaxmatrix/settings/model_map.py +300 -33
- syntaxmatrix/settings/prompts.py +273 -62
- syntaxmatrix/settings/string_navbar.py +3 -3
- syntaxmatrix/static/docs.md +272 -0
- syntaxmatrix/static/icons/favicon.png +0 -0
- syntaxmatrix/static/icons/hero_bg.jpg +0 -0
- syntaxmatrix/templates/dashboard.html +608 -147
- syntaxmatrix/templates/docs.html +71 -0
- syntaxmatrix/templates/error.html +2 -3
- syntaxmatrix/templates/login.html +1 -0
- syntaxmatrix/templates/register.html +1 -0
- syntaxmatrix/ui_modes.py +14 -0
- syntaxmatrix/utils.py +2482 -159
- syntaxmatrix/vectorizer.py +16 -12
- {syntaxmatrix-1.4.6.dist-info → syntaxmatrix-2.5.5.4.dist-info}/METADATA +20 -17
- syntaxmatrix-2.5.5.4.dist-info/RECORD +68 -0
- syntaxmatrix/model_templates.py +0 -30
- syntaxmatrix/static/icons/favicon.ico +0 -0
- syntaxmatrix-1.4.6.dist-info/RECORD +0 -54
- {syntaxmatrix-1.4.6.dist-info → syntaxmatrix-2.5.5.4.dist-info}/WHEEL +0 -0
- {syntaxmatrix-1.4.6.dist-info → syntaxmatrix-2.5.5.4.dist-info}/licenses/LICENSE.txt +0 -0
- {syntaxmatrix-1.4.6.dist-info → syntaxmatrix-2.5.5.4.dist-info}/top_level.txt +0 -0
syntaxmatrix/display.py
CHANGED
|
@@ -1,132 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
#
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
#
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
# return
|
|
55
|
-
# if len(obj) == 4: # e.g. χ²
|
|
56
|
-
# chi2, p, dof, _ = obj
|
|
57
|
-
# print(f"chi² = {chi2:.3g} dof = {dof} p-value = {p:.4g}")
|
|
58
|
-
# print("Result: " + ("significant ✅" if p < 0.05 else "not significant ❌"))
|
|
59
|
-
# return
|
|
60
|
-
# # Treat as regression metrics if r2 is ≤ 1 and mse ≥ 0
|
|
61
|
-
# if 0 <= r2 <= 1 and mse >= 0:
|
|
62
|
-
# df_ = pd.DataFrame(
|
|
63
|
-
# {"metric": ["Mean-squared error", "R²"],
|
|
64
|
-
# "value": [mse, r2]}
|
|
65
|
-
# )
|
|
66
|
-
# display(HTML(datatable_box(df_)))
|
|
67
|
-
# return
|
|
68
|
-
|
|
69
|
-
# # dict → nice key:value printout
|
|
70
|
-
# if isinstance(obj, dict):
|
|
71
|
-
# for k, v in obj.items():
|
|
72
|
-
# print(f"{k:<25} {v}")
|
|
73
|
-
# return
|
|
74
|
-
|
|
75
|
-
# # fallback
|
|
76
|
-
# print(obj)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
# -----------------------------------------------------------------
|
|
80
|
-
# Paste *inside* syntaxmatrix/display.py – only the show() body
|
|
81
|
-
# -----------------------------------------------------------------
|
|
82
|
-
def show(obj):
|
|
1
|
+
"""
|
|
2
|
+
syntaxmatrix.display
|
|
3
|
+
--------------------
|
|
4
|
+
Single responsibility: render arbitrary Python objects in the SMX UI.
|
|
5
|
+
|
|
6
|
+
- Matplotlib figures: displayed directly.
|
|
7
|
+
- Pandas Styler (with .set_caption): rendered to HTML so captions always show.
|
|
8
|
+
- Pandas DataFrame/Series: rendered to HTML (no caption path).
|
|
9
|
+
- Dict of scalars: rendered as a small table.
|
|
10
|
+
- Tuple of two numbers (e.g., mse, r2): rendered as a labelled 2-row table.
|
|
11
|
+
- Everything else: shown as <pre> for safe inspection.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from typing import Any
|
|
15
|
+
import numbers
|
|
16
|
+
|
|
17
|
+
import pandas as pd
|
|
18
|
+
import matplotlib.figure as mpfig
|
|
19
|
+
from IPython.display import display, HTML
|
|
20
|
+
|
|
21
|
+
try:
|
|
22
|
+
# Optional: if pandas Styler exists, we can keep captions reliably
|
|
23
|
+
from pandas.io.formats.style import Styler as _Styler # type: ignore
|
|
24
|
+
except Exception: # pragma: no cover
|
|
25
|
+
_Styler = None # type: ignore
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
__all__ = ["show"]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# ---- internal helpers -------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _wrap_html_table(html: str) -> str:
|
|
35
|
+
"""Apply consistent UI styling and horizontal scrolling."""
|
|
36
|
+
return (
|
|
37
|
+
"<style>"
|
|
38
|
+
"caption{caption-side: top; font-weight:600; margin:0 0 6px 0;}"
|
|
39
|
+
"table{border-collapse:collapse;font-size:0.9em;white-space:nowrap;}"
|
|
40
|
+
"th{background:#f0f2f5;text-align:left;padding:6px 8px;border:1px solid gray;}"
|
|
41
|
+
"td{border:1px solid #ddd;padding:6px 8px;}"
|
|
42
|
+
"tbody tr:nth-child(even){background-color:#f9f9f9;}"
|
|
43
|
+
"</style>"
|
|
44
|
+
"<div style='overflow-x:auto;max-width:100%;margin-bottom:1rem;'>"
|
|
45
|
+
+ html +
|
|
46
|
+
"</div>"
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# ---- public API -------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def show(obj: Any) -> None:
|
|
83
54
|
"""
|
|
84
55
|
Render common objects so the Dashboard (or chat) always shows output.
|
|
85
|
-
"""
|
|
86
|
-
import io, base64, numbers
|
|
87
|
-
from IPython.display import display, HTML
|
|
88
|
-
import pandas as pd
|
|
89
|
-
import matplotlib.figure as mpfig
|
|
90
56
|
|
|
91
|
-
|
|
57
|
+
Notes
|
|
58
|
+
-----
|
|
59
|
+
* Do not print here. All rendering goes through IPython's display layer.
|
|
60
|
+
* Captions are supplied upstream by the SMX PREFACE via DataFrame.style.set_caption(...).
|
|
61
|
+
"""
|
|
62
|
+
# 1) Matplotlib figures
|
|
92
63
|
if isinstance(obj, mpfig.Figure):
|
|
93
|
-
display(obj)
|
|
94
|
-
return
|
|
95
|
-
|
|
96
|
-
|
|
64
|
+
display(obj)
|
|
65
|
+
return None
|
|
66
|
+
|
|
67
|
+
# 2) Pandas Styler (keeps caption)
|
|
68
|
+
if _Styler is not None and isinstance(obj, _Styler): # type: ignore
|
|
69
|
+
try:
|
|
70
|
+
html = obj.to_html()
|
|
71
|
+
display(HTML(_wrap_html_table(html)))
|
|
72
|
+
except Exception:
|
|
73
|
+
# Fallback: if Styler HTML fails for any reason, display raw Styler
|
|
74
|
+
display(obj)
|
|
75
|
+
return None
|
|
97
76
|
|
|
77
|
+
# 3) Series / DataFrame (no caption path)
|
|
78
|
+
if isinstance(obj, (pd.Series, pd.DataFrame)):
|
|
98
79
|
html = obj.to_html(classes="smx-table", border=0)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
".smx-table{border-collapse:collapse;font-size:0.9em;white-space:nowrap;}"
|
|
102
|
-
".smx-table th{background:#f0f2f5;text-align:left;padding:6px 8px;border:1px solid gray;}"
|
|
103
|
-
".smx-table td{border:1px solid #ddd;padding:6px 8px;}"
|
|
104
|
-
".smx-table tbody tr:nth-child(even){background-color:#f9f9f9;}"
|
|
105
|
-
"</style>"
|
|
106
|
-
"<div style='overflow-x:auto; max-width:100%; margin-bottom:1rem;'>"
|
|
107
|
-
+ html +
|
|
108
|
-
"</div>"
|
|
109
|
-
)
|
|
110
|
-
display(HTML(wrapped_html))
|
|
111
|
-
return HTML(wrapped_html)
|
|
80
|
+
display(HTML(_wrap_html_table(html)))
|
|
81
|
+
return None
|
|
112
82
|
|
|
113
|
-
#
|
|
83
|
+
# 4) Dict of scalar numbers → pretty 2-col table
|
|
114
84
|
if isinstance(obj, dict) and all(isinstance(v, numbers.Number) for v in obj.values()):
|
|
115
|
-
df_ = pd.DataFrame({"metric": list(obj.keys()),
|
|
116
|
-
|
|
117
|
-
display(
|
|
118
|
-
return
|
|
119
|
-
|
|
120
|
-
#
|
|
121
|
-
if (
|
|
122
|
-
|
|
85
|
+
df_ = pd.DataFrame({"metric": list(obj.keys()), "value": list(obj.values())})
|
|
86
|
+
html = df_.to_html(classes="smx-table", border=0, index=False)
|
|
87
|
+
display(HTML(_wrap_html_table(html)))
|
|
88
|
+
return None
|
|
89
|
+
|
|
90
|
+
# 5) Two-number tuple → labelled metric table (e.g., (mse, r2))
|
|
91
|
+
if (
|
|
92
|
+
isinstance(obj, tuple)
|
|
93
|
+
and len(obj) == 2
|
|
94
|
+
and all(isinstance(v, numbers.Number) for v in obj)
|
|
95
|
+
):
|
|
123
96
|
mse, r2 = obj
|
|
124
|
-
df_ = pd.DataFrame(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
97
|
+
df_ = pd.DataFrame(
|
|
98
|
+
{"metric": ["Mean-squared error", "R²"], "value": [mse, r2]}
|
|
99
|
+
)
|
|
100
|
+
html = df_.to_html(classes="smx-table", border=0, index=False)
|
|
101
|
+
display(HTML(_wrap_html_table(html)))
|
|
102
|
+
return None
|
|
128
103
|
|
|
129
|
-
#
|
|
104
|
+
# 6) Fallback: show as preformatted text (safe and predictable)
|
|
130
105
|
display(HTML(f"<pre>{obj}</pre>"))
|
|
131
|
-
|
|
132
|
-
return obj
|
|
106
|
+
return None
|