syntaxmatrix 1.2.0__tar.gz

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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Bob Nti
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,257 @@
1
+ Metadata-Version: 2.4
2
+ Name: syntaxmatrix
3
+ Version: 1.2.0
4
+ Summary: SyntaxMUI: A customizable UI framework for Python AI Assistant Projects.
5
+ Home-page: https://github.com/bobganti/SyntaxMatrixDemo
6
+ Author: Bob Nti
7
+ Author-email: bob.nti@syntaxmatrix.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.7
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: >=3.7
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE.txt
18
+ Requires-Dist: Flask>=2.0.0
19
+ Requires-Dist: requests>=2.0.0
20
+ Requires-Dist: markdown>=3.3.0
21
+ Requires-Dist: matplotlib>=3.5.0
22
+ Requires-Dist: plotly>=5.0.0
23
+ Requires-Dist: openai>=0.27.0
24
+ Requires-Dist: PyPDF2>=1.26.0
25
+ Requires-Dist: numpy>=1.21.0
26
+ Provides-Extra: advanced-nlp
27
+ Requires-Dist: transformers>=4.0.0; extra == "advanced-nlp"
28
+ Requires-Dist: torch>=1.9.0; extra == "advanced-nlp"
29
+ Provides-Extra: data
30
+ Requires-Dist: pandas>=1.3.0; extra == "data"
31
+ Provides-Extra: testing
32
+ Requires-Dist: pytest; extra == "testing"
33
+ Requires-Dist: pytest-flask; extra == "testing"
34
+ Dynamic: author
35
+ Dynamic: author-email
36
+ Dynamic: classifier
37
+ Dynamic: description
38
+ Dynamic: description-content-type
39
+ Dynamic: home-page
40
+ Dynamic: license-file
41
+ Dynamic: provides-extra
42
+ Dynamic: requires-dist
43
+ Dynamic: requires-python
44
+ Dynamic: summary
45
+
46
+ # syntaxmatrix UI Framework v1.2.0
47
+
48
+ **SyntaxMUI:** A customizable UI framework for Python AI assistant projects.
49
+
50
+ [![PyPI Version](https://img.shields.io/pypi/v/syntaxmatrix.svg)](https://pypi.org/project/syntaxmatrix)
51
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
52
+
53
+ ---
54
+
55
+ ## Overview
56
+
57
+ `syntaxmatrix` (lowercase) is a lightweight, Pythonic UI library that lets you build interactive chat-style front-ends for AI apps without diving into a full web framework. It provides:
58
+
59
+ - Rapid widget registration (text inputs, buttons, file uploaders)
60
+ - Dynamic theme toggling and multiple UI modes
61
+ - Built-in PDF ingestion & chunking
62
+ - Stylized feedback (success, error, warning, info)
63
+ - Admin panel, session management, and more
64
+
65
+ Ideal for Retrieval-Augmented Generation (RAG) demos, data explorers, or any AI assistant interface.
66
+
67
+ ---
68
+
69
+ ## Quick Links
70
+
71
+ - **Documentation:** https://github.com/bobganti/SyntaxMatrix
72
+ - **PyPI:** `pip install syntaxmatrix==1.2.0`
73
+ - **Source:** https://github.com/bobganti/SyntaxMatrix
74
+
75
+ ---
76
+
77
+ ## Features
78
+
79
+ - **Rapid UI Creation**: One-line calls to register `text_input`, `button`, `file_uploader`, etc.
80
+ - **Built-in Chat Loop**: Core `/process_chat` endpoint automatically wires three keys:
81
+ - `user_query` (text input),
82
+ - `submit_query` (send button),
83
+ - `user_pdfs` (PDF uploader + chunking).
84
+ - **Custom Widgets**: Register any keys you like—just provide matching handler logic.
85
+ - **PDF Ingestion**: `load_pdf_chunks(directory)` scans a folder, splits PDFs into chunks, caches in SQLite, and returns a `{filename: [chunks,…]}` map.
86
+ - **Session File Uploads**: `get_user_chunks()`, `add_user_chunks()`, `clear_user_chunks()` for per-session user files.
87
+ - **Dynamic Themes**: `enable_theme_toggle()`, `set_theme()`, plus `list_themes()`.
88
+ - **Multiple UI Modes**: `set_ui_mode()` supports `default`, `bubble`, `card`, **`smx`** (new!) and `list_ui_modes()`.
89
+ - **Rich Output**: `markdown()`, `latex()`, `plt_plot()`, `plotly_plot()`, plus `error()`, `warning()`, `success()`, `info()`.
90
+ - **Branding Helpers**: `set_user_icon()`, `set_bot_icon()`, `set_site_icon()`, `set_site_logo()`, `set_site_title()`, `set_project_title()`.
91
+ - **Session Management**: Named chat sessions with rename/delete; session IDs via `get_session_id()`.
92
+
93
+ ---
94
+
95
+ ## Installation
96
+
97
+ ```bash
98
+ pip install syntaxmatrix==1.2.0
99
+ ```
100
+
101
+ **Dependencies**
102
+
103
+ - Python >= 3.7
104
+ - Flask >= 2.0.0
105
+ - requests >= 2.0.0
106
+ - markdown >= 3.3.0
107
+ - matplotlib >= 3.5.0
108
+ - plotly >= 5.0.0
109
+ - openai >= 0.27.0
110
+ - PyPDF2 >= 1.26.0
111
+ - numpy >= 1.21.0
112
+
113
+ Optional extras:
114
+
115
+ ```bash
116
+ # Transformer models & torch
117
+ pip install syntaxmatrix[advanced_nlp]
118
+
119
+ # pandas for data APIs
120
+ pip install syntaxmatrix[data]
121
+
122
+ # Testing
123
+ pip install syntaxmatrix[testing]
124
+ ```
125
+
126
+ ---
127
+
128
+ ## Quick-Start Snippet
129
+
130
+ This minimal example uses the **built-in** chat flow (no custom keys required):
131
+
132
+ ```python
133
+ import syntaxmatrix as smx
134
+
135
+ # Handler for text-submission
136
+ def create_conversation():
137
+ q = smx.get_text_input_value("user_query").strip()
138
+ if not q:
139
+ smx.warning("Please enter a question.")
140
+ return
141
+ # …your AI call or logic here…
142
+ smx.success(f"You asked: {q}")
143
+
144
+ # UI setup
145
+ smx.set_ui_mode("smx") # new "smx" display style
146
+ smx.enable_theme_toggle() # add light/dark toggle
147
+
148
+ # Activate built-in widgets (must use these keys)
149
+ smx.text_input(
150
+ "user_query", # text box
151
+ "Ask me anything…", # label
152
+ placeholder="Type your question here…"
153
+ )
154
+ smx.button(
155
+ "submit_query", # send button key
156
+ "Send", # label
157
+ callback=create_conversation # invoked on send
158
+ )
159
+ smx.file_uploader(
160
+ "user_pdfs", # PDF uploader key
161
+ "Upload PDFs", # label
162
+ accept_multiple_files=True # chunking happens automatically
163
+ )
164
+
165
+ if __name__ == "__main__":
166
+ smx.run()
167
+ ```
168
+
169
+ > **Note:** If you register different keys, you must also adapt your handlers and/or the request-processing logic to match those names.
170
+
171
+ ---
172
+
173
+ ## Registering Custom Widgets
174
+
175
+ You’re not limited to the three defaults. Example:
176
+
177
+ ```python
178
+ # Custom keys:
179
+ smx.text_input("query_box", "Your query…")
180
+ smx.button("ask_btn", "Ask", callback=my_ask_handler)
181
+ smx.file_uploader(
182
+ "pdf_docs",
183
+ "Attach Documents",
184
+ accept_multiple_files=True,
185
+ callback=my_upload_handler
186
+ )
187
+ ```
188
+
189
+ Then your `my_ask_handler()` must read from `smx.get_text_input_value("query_box")`, and you’ll need to implement or wrap the chat loop yourself if you deviate from the built-ins.
190
+
191
+ ---
192
+
193
+ ## API Reference
194
+
195
+ ### App Lifecycle & Branding
196
+
197
+ | Function | Description |
198
+ | ----------------------------------------------------- | -------------------------------------------------------------------------------- |
199
+ | `run()` | Launches the Flask server and opens a browser window |
200
+ | `set_site_title(title: str)` | Sets the navbar site title |
201
+ | `set_project_title(title: str)` | Sets the main project heading |
202
+ | `set_user_icon(icon: str)` | Emoji/text for user messages |
203
+ | `set_bot_icon(icon: str)` | Emoji/text for bot messages |
204
+ | `set_site_icon(icon: str)` | Small icon in the browser tab |
205
+ | `set_site_logo(logo: str)` | Text/logo in the navbar |
206
+
207
+ ### Theming & Modes
208
+
209
+ | Function | Description |
210
+ | ----------------------------------------------------- | -------------------------------------------------------------------------------- |
211
+ | `enable_theme_toggle()` | Show a light/dark toggle link in the navbar |
212
+ | `disable_theme_toggle()` | Hide the theme toggle |
213
+ | `set_theme(name: str, theme_dict?: dict)` | Switch or define a custom theme |
214
+ | `list_themes() -> List[str]` | Get all available theme names |
215
+ | `set_ui_mode(mode: str)` | Choose layout: `default`, `bubble`, `card`, `smx` |
216
+ | `list_ui_modes() -> Tuple[str,…]` | Available UI modes |
217
+
218
+ ### Built-in Widgets & Flow
219
+
220
+ | Function | Description |
221
+ | ----------------------------------------------------- | -------------------------------------------------------------------------------- |
222
+ | `text_input(key, label, placeholder="")` | Register a text box. For built-in chat use key=`user_query`. |
223
+ | `button(key, label, callback=None)` | Register a button. For built-in chat use key=`submit_query`. |
224
+ | `file_uploader(key, label, accept_multiple_files=False, callback=None)` | Register a file upload. For PDF chunking use key=`user_pdfs`. |
225
+ | `get_text_input_value(key)` | Read current text in a box |
226
+ | `clear_text_input_value(key)` | Clear the text box |
227
+ | `get_file_upload_value(key)` | Access raw file objects uploaded |
228
+
229
+ ### PDF & File-Chunk APIs
230
+
231
+ | Function | Description |
232
+ | ----------------------------------------------------- | -------------------------------------------------------------------------------- |
233
+ | `load_pdf_chunks(directory: str = "uploads/sys")` | Ingest all system PDFs → split into chunks → cache → return `{file:[chunks]}` |
234
+ | `get_session_id() -> str` | Current chat session UUID |
235
+ | `add_user_chunks(sess_id: str, chunks: List[str])` | Store user-uploaded text chunks |
236
+ | `get_user_chunks(sess_id: str) -> List[str]` | Retrieve stored user chunks |
237
+ | `clear_user_chunks(sess_id: str)` | Remove all user chunks for session |
238
+
239
+ ### Rich & Stylized Output
240
+
241
+ | Function | Description |
242
+ | ----------------------------------------------------- | -------------------------------------------------------------------------------- |
243
+ | `write(content: str)` | Append raw HTML/text to system-output buffer |
244
+ | `markdown(md_text: str)` | Render Markdown via Python-Markdown |
245
+ | `latex(math_text: str)` | Render LaTeX math via MathJax |
246
+ | `error(msg: str)` | Output red-styled error message |
247
+ | `warning(msg: str)` | Output orange-styled warning |
248
+ | `success(msg: str)` | Output green-styled success |
249
+ | `info(msg: str)` | Output blue-styled info |
250
+ | `plt_plot(fig: matplotlib.figure.Figure)` | Embed a Matplotlib figure |
251
+ | `plotly_plot(fig: plotly.Figure)` | Embed a Plotly figure |
252
+
253
+ ---
254
+
255
+ ## License
256
+
257
+ MIT © Bob Nti
@@ -0,0 +1,212 @@
1
+ # syntaxmatrix UI Framework v1.2.0
2
+
3
+ **SyntaxMUI:** A customizable UI framework for Python AI assistant projects.
4
+
5
+ [![PyPI Version](https://img.shields.io/pypi/v/syntaxmatrix.svg)](https://pypi.org/project/syntaxmatrix)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
7
+
8
+ ---
9
+
10
+ ## Overview
11
+
12
+ `syntaxmatrix` (lowercase) is a lightweight, Pythonic UI library that lets you build interactive chat-style front-ends for AI apps without diving into a full web framework. It provides:
13
+
14
+ - Rapid widget registration (text inputs, buttons, file uploaders)
15
+ - Dynamic theme toggling and multiple UI modes
16
+ - Built-in PDF ingestion & chunking
17
+ - Stylized feedback (success, error, warning, info)
18
+ - Admin panel, session management, and more
19
+
20
+ Ideal for Retrieval-Augmented Generation (RAG) demos, data explorers, or any AI assistant interface.
21
+
22
+ ---
23
+
24
+ ## Quick Links
25
+
26
+ - **Documentation:** https://github.com/bobganti/SyntaxMatrix
27
+ - **PyPI:** `pip install syntaxmatrix==1.2.0`
28
+ - **Source:** https://github.com/bobganti/SyntaxMatrix
29
+
30
+ ---
31
+
32
+ ## Features
33
+
34
+ - **Rapid UI Creation**: One-line calls to register `text_input`, `button`, `file_uploader`, etc.
35
+ - **Built-in Chat Loop**: Core `/process_chat` endpoint automatically wires three keys:
36
+ - `user_query` (text input),
37
+ - `submit_query` (send button),
38
+ - `user_pdfs` (PDF uploader + chunking).
39
+ - **Custom Widgets**: Register any keys you like—just provide matching handler logic.
40
+ - **PDF Ingestion**: `load_pdf_chunks(directory)` scans a folder, splits PDFs into chunks, caches in SQLite, and returns a `{filename: [chunks,…]}` map.
41
+ - **Session File Uploads**: `get_user_chunks()`, `add_user_chunks()`, `clear_user_chunks()` for per-session user files.
42
+ - **Dynamic Themes**: `enable_theme_toggle()`, `set_theme()`, plus `list_themes()`.
43
+ - **Multiple UI Modes**: `set_ui_mode()` supports `default`, `bubble`, `card`, **`smx`** (new!) and `list_ui_modes()`.
44
+ - **Rich Output**: `markdown()`, `latex()`, `plt_plot()`, `plotly_plot()`, plus `error()`, `warning()`, `success()`, `info()`.
45
+ - **Branding Helpers**: `set_user_icon()`, `set_bot_icon()`, `set_site_icon()`, `set_site_logo()`, `set_site_title()`, `set_project_title()`.
46
+ - **Session Management**: Named chat sessions with rename/delete; session IDs via `get_session_id()`.
47
+
48
+ ---
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ pip install syntaxmatrix==1.2.0
54
+ ```
55
+
56
+ **Dependencies**
57
+
58
+ - Python >= 3.7
59
+ - Flask >= 2.0.0
60
+ - requests >= 2.0.0
61
+ - markdown >= 3.3.0
62
+ - matplotlib >= 3.5.0
63
+ - plotly >= 5.0.0
64
+ - openai >= 0.27.0
65
+ - PyPDF2 >= 1.26.0
66
+ - numpy >= 1.21.0
67
+
68
+ Optional extras:
69
+
70
+ ```bash
71
+ # Transformer models & torch
72
+ pip install syntaxmatrix[advanced_nlp]
73
+
74
+ # pandas for data APIs
75
+ pip install syntaxmatrix[data]
76
+
77
+ # Testing
78
+ pip install syntaxmatrix[testing]
79
+ ```
80
+
81
+ ---
82
+
83
+ ## Quick-Start Snippet
84
+
85
+ This minimal example uses the **built-in** chat flow (no custom keys required):
86
+
87
+ ```python
88
+ import syntaxmatrix as smx
89
+
90
+ # Handler for text-submission
91
+ def create_conversation():
92
+ q = smx.get_text_input_value("user_query").strip()
93
+ if not q:
94
+ smx.warning("Please enter a question.")
95
+ return
96
+ # …your AI call or logic here…
97
+ smx.success(f"You asked: {q}")
98
+
99
+ # UI setup
100
+ smx.set_ui_mode("smx") # new "smx" display style
101
+ smx.enable_theme_toggle() # add light/dark toggle
102
+
103
+ # Activate built-in widgets (must use these keys)
104
+ smx.text_input(
105
+ "user_query", # text box
106
+ "Ask me anything…", # label
107
+ placeholder="Type your question here…"
108
+ )
109
+ smx.button(
110
+ "submit_query", # send button key
111
+ "Send", # label
112
+ callback=create_conversation # invoked on send
113
+ )
114
+ smx.file_uploader(
115
+ "user_pdfs", # PDF uploader key
116
+ "Upload PDFs", # label
117
+ accept_multiple_files=True # chunking happens automatically
118
+ )
119
+
120
+ if __name__ == "__main__":
121
+ smx.run()
122
+ ```
123
+
124
+ > **Note:** If you register different keys, you must also adapt your handlers and/or the request-processing logic to match those names.
125
+
126
+ ---
127
+
128
+ ## Registering Custom Widgets
129
+
130
+ You’re not limited to the three defaults. Example:
131
+
132
+ ```python
133
+ # Custom keys:
134
+ smx.text_input("query_box", "Your query…")
135
+ smx.button("ask_btn", "Ask", callback=my_ask_handler)
136
+ smx.file_uploader(
137
+ "pdf_docs",
138
+ "Attach Documents",
139
+ accept_multiple_files=True,
140
+ callback=my_upload_handler
141
+ )
142
+ ```
143
+
144
+ Then your `my_ask_handler()` must read from `smx.get_text_input_value("query_box")`, and you’ll need to implement or wrap the chat loop yourself if you deviate from the built-ins.
145
+
146
+ ---
147
+
148
+ ## API Reference
149
+
150
+ ### App Lifecycle & Branding
151
+
152
+ | Function | Description |
153
+ | ----------------------------------------------------- | -------------------------------------------------------------------------------- |
154
+ | `run()` | Launches the Flask server and opens a browser window |
155
+ | `set_site_title(title: str)` | Sets the navbar site title |
156
+ | `set_project_title(title: str)` | Sets the main project heading |
157
+ | `set_user_icon(icon: str)` | Emoji/text for user messages |
158
+ | `set_bot_icon(icon: str)` | Emoji/text for bot messages |
159
+ | `set_site_icon(icon: str)` | Small icon in the browser tab |
160
+ | `set_site_logo(logo: str)` | Text/logo in the navbar |
161
+
162
+ ### Theming & Modes
163
+
164
+ | Function | Description |
165
+ | ----------------------------------------------------- | -------------------------------------------------------------------------------- |
166
+ | `enable_theme_toggle()` | Show a light/dark toggle link in the navbar |
167
+ | `disable_theme_toggle()` | Hide the theme toggle |
168
+ | `set_theme(name: str, theme_dict?: dict)` | Switch or define a custom theme |
169
+ | `list_themes() -> List[str]` | Get all available theme names |
170
+ | `set_ui_mode(mode: str)` | Choose layout: `default`, `bubble`, `card`, `smx` |
171
+ | `list_ui_modes() -> Tuple[str,…]` | Available UI modes |
172
+
173
+ ### Built-in Widgets & Flow
174
+
175
+ | Function | Description |
176
+ | ----------------------------------------------------- | -------------------------------------------------------------------------------- |
177
+ | `text_input(key, label, placeholder="")` | Register a text box. For built-in chat use key=`user_query`. |
178
+ | `button(key, label, callback=None)` | Register a button. For built-in chat use key=`submit_query`. |
179
+ | `file_uploader(key, label, accept_multiple_files=False, callback=None)` | Register a file upload. For PDF chunking use key=`user_pdfs`. |
180
+ | `get_text_input_value(key)` | Read current text in a box |
181
+ | `clear_text_input_value(key)` | Clear the text box |
182
+ | `get_file_upload_value(key)` | Access raw file objects uploaded |
183
+
184
+ ### PDF & File-Chunk APIs
185
+
186
+ | Function | Description |
187
+ | ----------------------------------------------------- | -------------------------------------------------------------------------------- |
188
+ | `load_pdf_chunks(directory: str = "uploads/sys")` | Ingest all system PDFs → split into chunks → cache → return `{file:[chunks]}` |
189
+ | `get_session_id() -> str` | Current chat session UUID |
190
+ | `add_user_chunks(sess_id: str, chunks: List[str])` | Store user-uploaded text chunks |
191
+ | `get_user_chunks(sess_id: str) -> List[str]` | Retrieve stored user chunks |
192
+ | `clear_user_chunks(sess_id: str)` | Remove all user chunks for session |
193
+
194
+ ### Rich & Stylized Output
195
+
196
+ | Function | Description |
197
+ | ----------------------------------------------------- | -------------------------------------------------------------------------------- |
198
+ | `write(content: str)` | Append raw HTML/text to system-output buffer |
199
+ | `markdown(md_text: str)` | Render Markdown via Python-Markdown |
200
+ | `latex(math_text: str)` | Render LaTeX math via MathJax |
201
+ | `error(msg: str)` | Output red-styled error message |
202
+ | `warning(msg: str)` | Output orange-styled warning |
203
+ | `success(msg: str)` | Output green-styled success |
204
+ | `info(msg: str)` | Output blue-styled info |
205
+ | `plt_plot(fig: matplotlib.figure.Figure)` | Embed a Matplotlib figure |
206
+ | `plotly_plot(fig: plotly.Figure)` | Embed a Plotly figure |
207
+
208
+ ---
209
+
210
+ ## License
211
+
212
+ MIT © Bob Nti