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.
Files changed (45) hide show
  1. syntaxmatrix/__init__.py +13 -8
  2. syntaxmatrix/agentic/__init__.py +0 -0
  3. syntaxmatrix/agentic/agent_tools.py +24 -0
  4. syntaxmatrix/agentic/agents.py +810 -0
  5. syntaxmatrix/agentic/code_tools_registry.py +37 -0
  6. syntaxmatrix/agentic/model_templates.py +1790 -0
  7. syntaxmatrix/auth.py +308 -14
  8. syntaxmatrix/commentary.py +328 -0
  9. syntaxmatrix/core.py +993 -375
  10. syntaxmatrix/dataset_preprocessing.py +218 -0
  11. syntaxmatrix/db.py +92 -95
  12. syntaxmatrix/display.py +95 -121
  13. syntaxmatrix/generate_page.py +634 -0
  14. syntaxmatrix/gpt_models_latest.py +46 -0
  15. syntaxmatrix/history_store.py +26 -29
  16. syntaxmatrix/kernel_manager.py +96 -17
  17. syntaxmatrix/llm_store.py +1 -1
  18. syntaxmatrix/plottings.py +6 -0
  19. syntaxmatrix/profiles.py +64 -8
  20. syntaxmatrix/project_root.py +55 -43
  21. syntaxmatrix/routes.py +5072 -1398
  22. syntaxmatrix/session.py +19 -0
  23. syntaxmatrix/settings/logging.py +40 -0
  24. syntaxmatrix/settings/model_map.py +300 -33
  25. syntaxmatrix/settings/prompts.py +273 -62
  26. syntaxmatrix/settings/string_navbar.py +3 -3
  27. syntaxmatrix/static/docs.md +272 -0
  28. syntaxmatrix/static/icons/favicon.png +0 -0
  29. syntaxmatrix/static/icons/hero_bg.jpg +0 -0
  30. syntaxmatrix/templates/dashboard.html +608 -147
  31. syntaxmatrix/templates/docs.html +71 -0
  32. syntaxmatrix/templates/error.html +2 -3
  33. syntaxmatrix/templates/login.html +1 -0
  34. syntaxmatrix/templates/register.html +1 -0
  35. syntaxmatrix/ui_modes.py +14 -0
  36. syntaxmatrix/utils.py +2482 -159
  37. syntaxmatrix/vectorizer.py +16 -12
  38. {syntaxmatrix-1.4.6.dist-info → syntaxmatrix-2.5.5.4.dist-info}/METADATA +20 -17
  39. syntaxmatrix-2.5.5.4.dist-info/RECORD +68 -0
  40. syntaxmatrix/model_templates.py +0 -30
  41. syntaxmatrix/static/icons/favicon.ico +0 -0
  42. syntaxmatrix-1.4.6.dist-info/RECORD +0 -54
  43. {syntaxmatrix-1.4.6.dist-info → syntaxmatrix-2.5.5.4.dist-info}/WHEEL +0 -0
  44. {syntaxmatrix-1.4.6.dist-info → syntaxmatrix-2.5.5.4.dist-info}/licenses/LICENSE.txt +0 -0
  45. {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
- # syntaxmatrix/display.py
2
- # import pandas as pd
3
- # from IPython.display import HTML, display
4
- # from syntaxmatrix.plottings import datatable_box
5
-
6
- # def show(obj, *, name=None):
7
- # """
8
- # Smart display for the SyntaxMatrix auto-code kernel.
9
- # * Scalars / simple tuples pretty print
10
- # * pandas Series / DataFrame display()
11
- # * matplotlib / seaborn figs already auto-render
12
- # * dicts → key-value table
13
- # * sklearn estimators with .score_ / feature_importances_ → summary
14
- # """
15
- # try:
16
- # import matplotlib.pyplot as plt
17
- # except Exception:
18
- # plt = None
19
-
20
- # if isinstance(obj, (float, int)) and (0 <= obj <= 1):
21
- # print(f"accuracy = {obj:.3f}")
22
- # return
23
-
24
- # 1️⃣ pandas objects
25
- # if isinstance(obj, (pd.Series, pd.DataFrame)):
26
-
27
- # html = obj.to_html(classes="smx-table", border=0)
28
- # wrapped_html = (
29
- # "<style>"
30
- # ".smx-table{border-collapse:collapse;font-size:0.9em;white-space:nowrap;}"
31
- # ".smx-table th{background:#f0f2f5;text-align:left;padding:6px 8px;border:1px solid gray;}"
32
- # ".smx-table td{border:1px solid #ddd;padding:6px 8px;}"
33
- # ".smx-table tbody tr:nth-child(even){background-color:#f9f9f9;}"
34
- # "</style>"
35
- # "<div style='overflow-x:auto; max-width:100%; margin-bottom:1rem;'>"
36
- # + html +
37
- # "</div>"
38
- # )
39
- # display(HTML(wrapped_html))
40
- # return
41
-
42
- # # matplotlib figs (let Jupyter handle them)
43
- # if plt and isinstance(obj, plt.Figure):
44
- # return
45
-
46
- # # tuples of stats results (length 2 or 4 are common)
47
- # if isinstance(obj, tuple):
48
- # if len(obj) == 2 and all(isinstance(v, (int, float)) for v in obj):
49
- # mse, r2 = obj
50
- # if len(obj) == 2:
51
- # stat, p = obj
52
- # print(f"statistic = {stat:.4g} p-value = {p:.4g}")
53
- # print("Result: " + ("significant ✅" if p < 0.05 else "not significant ❌"))
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
- # ── matplotlib Figure ─────────────────────────────────────────
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 obj
95
-
96
- if isinstance(obj, (pd.Series, pd.DataFrame)):
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
- wrapped_html = (
100
- "<style>"
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
- # ── dict of scalars → pretty 2-col table ─────────────────────
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
- "value": list(obj.values())})
117
- display(df_)
118
- return df_
119
-
120
- # ── 2-tuple of numbers (mse, ) ─────────────────────────────
121
- if (isinstance(obj, tuple) and len(obj) == 2 and
122
- all(isinstance(v, numbers.Number) for v in obj)):
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({"metric": ["Mean-squared error", "R²"],
125
- "value": [mse, r2]})
126
- display(df_)
127
- return df_
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
- # ── fallback ─────────────────────────────────────────────────
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