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
@@ -0,0 +1,19 @@
1
+ # syntaxmatrix/session.py
2
+ import uuid
3
+ from flask import request, g
4
+
5
+ COOKIE_NAME = "smx_session"
6
+
7
+ def ensure_session_cookie():
8
+ """
9
+ If the visitor has no smx_session cookie, generate a UUID4 and remember
10
+ it for the response phase. Store the final ID in flask.g so the rest
11
+ of the request can reuse it.
12
+ """
13
+ sid = request.cookies.get(COOKIE_NAME)
14
+ if not sid:
15
+ sid = str(uuid.uuid4())
16
+ g._smx_new_sid = sid # flag for after_request
17
+ else:
18
+ sid = str(sid)
19
+ g.smx_session_id = sid # always available downstream
@@ -0,0 +1,40 @@
1
+ import logging
2
+ import sys
3
+ from logging.handlers import RotatingFileHandler
4
+ from syntaxmatrix.project_root import detect_project_root
5
+
6
+
7
+ def configure_logging():
8
+ """Set up robust error logging to file"""
9
+ # Create logger
10
+ logger = logging.getLogger()
11
+ logger.setLevel(logging.ERROR) # Capture only errors and above
12
+
13
+ # File handler with rotation (5MB per file, keep 3 backups)
14
+ file_handler = RotatingFileHandler(
15
+ filename=f'{detect_project_root()}/smx_logs.log',
16
+ maxBytes=5*1024*1024, # 5 MB
17
+ backupCount=3,
18
+ encoding='utf-8'
19
+ )
20
+
21
+ # Error formatting with tracebacks
22
+ formatter = logging.Formatter(
23
+ fmt='%(asctime)s | %(levelname)-8s | %(module)s:%(funcName)s:%(lineno)d - %(message)s',
24
+ datefmt='%Y-%m-%d %H:%M:%S'
25
+ )
26
+ file_handler.setFormatter(formatter)
27
+
28
+ logger.addHandler(file_handler)
29
+
30
+ # Capture unhandled exceptions
31
+ def handle_exception(exc_type, exc_value, exc_traceback):
32
+ if issubclass(exc_type, KeyboardInterrupt):
33
+ sys.__excepthook__(exc_type, exc_value, exc_traceback)
34
+ return
35
+ logger.critical("Unhandled exception", exc_info=(exc_type, exc_value, exc_traceback))
36
+
37
+ sys.excepthook = handle_exception
38
+
39
+ # Initialize logging when module loads
40
+ configure_logging()
@@ -1,46 +1,313 @@
1
+ import json
2
+ import os
3
+
4
+
1
5
  PROVIDERS_MODELS = {
2
- "openai": [
3
- "gpt-4o-mini",
4
- "gpt-4o-mini-search-preview",
5
- "gpt-4o",
6
- "gpt-4o-search-preview",
7
- "gpt-4.1-nano",
8
- "gpt-4.1-mini",
9
- "gpt-4.1",
10
- "text-embedding-3-small",
11
- "text-embedding-3-large",
6
+ #1
7
+ "openai": [
8
+ "gpt-5.1",
9
+ "gpt-5.1-chat-latest",
10
+ "gpt-5.1-codex-mini",
11
+ "gpt-5.1-codex",
12
+ "gpt-5",
13
+ "gpt-5-nano",
14
+ "gpt-5-mini",
15
+ "gpt-4.1",
16
+ "gpt-4.1-nano",
17
+ "gpt-4.1-mini",
18
+ "gpt-4o-mini",
19
+ "gpt-4o",
20
+ ],
21
+ #2
22
+ "google": [
23
+ "gemini-3-pro-preview",
24
+ "gemini-2.5-flash-lite",
25
+ "gemini-2.5-flash",
26
+ "gemini-2.5-pro",
27
+ "gemini-2.0-flash-lite",
28
+ "gemini-2.0-flash",
12
29
  ],
13
- "google": [
14
- "gemini-2.0-flash-lite",
15
- "gemini-2.0-flash",
16
- "gemini-2.5-flash-lite-preview-06-17",
17
- "gemini-2.5-flash-preview-04-17",
18
- "gemini-2.5-flash","gemini-2.5-pro"
30
+ #3
31
+ "xai": [
32
+ "grok-4",
33
+ "grok-3-mini-fast",
34
+ "grok-3-mini",
35
+ "grok-3",
36
+
19
37
  ],
20
- "xai": [
21
- "grok-3-mini",
22
- "grok-3-mini-fast",
23
- "grok-3"
38
+ #4
39
+ "deepseek": [
40
+ "deepseek-chat",
24
41
  ],
25
- "deepseek": [
26
- "deepseek-chat",
27
- "deepseek-reasoner"
42
+ #5
43
+ "moonshot": [
44
+ "kimi-k2-0905-preview",
28
45
  ],
29
- "moonshotai": [
30
- "kimi-k2-0711-preview",
46
+ #6
47
+ "alibaba": [
48
+ "qwen-flash",
49
+ "qwen-plus",
50
+ "qwen3-coder-plus",
51
+ "qwen-max",
31
52
  ],
53
+ #7
54
+ "anthropic": [
55
+ "claude-opus-4-5",
56
+ "claude-opus-4-1",
57
+ "claude-sonnet-4-5",
58
+ "claude-sonnet-4-0",
59
+ "claude-3-5-haiku-latest",
60
+ "claude-3-haiku-20240307",
61
+ ]
32
62
  }
33
63
 
34
- EMBEDDING_MODELS = {
35
- "openai": [
36
- "text-embedding-3-small",
37
- "text-embedding-3-large",
38
- ]
64
+
65
+ # Read-only model descriptions for LLM-profile builder
66
+ # -----------------------------------------------------------------------------
67
+ MODEL_DESCRIPTIONS = {
68
+ #1. OpenAI
69
+ "gpt-4o-mini":"Cost-efficient multimodal; $0.15/1M input, $0.60/1M output. Ideal for prototyping vision+text apps on a budget.",
70
+
71
+ "gpt-4o":"Multimodal powerhouse; $5.00/1M input, $15.00/1M output. Best for high-fidelity chat, complex reasoning & image tasks.",
72
+
73
+ "gpt-4.1-nano":"Ultra-fast low-cost (1M-token); $0.10/1M in, $0.40/1M out. Perfect for high-throughput, low-latency tasks.",
74
+
75
+ "gpt-4.1-mini":"Balanced speed/intel (1M-token context); $0.40/1M in, $1.60/1M out. Great for apps needing wide context at moderate cost.",
76
+
77
+ "gpt-4.1":"Top general-purpose (1M-token context); $2.00/1M in, $8.00/1M out. Excels at large-doc comprehension, coding, reasoning.",
78
+
79
+ "gpt-5-chat-latest":"""gpt-5-main. """,
80
+
81
+ "gpt-5-nano":"""gpt-5-thinking-nano. In/Out €0.043/€0.344 (cached in €0.004).
82
+ Fastest/lowest cost; ideal for short prompts, tagging, and rewrite flows; tools supported.
83
+ Best for:
84
+ 1. High-volume classification/moderation
85
+ 2. Copy clean-up and templated rewrites
86
+ 3. Lightweight summarisation and routing
87
+
88
+ Use cases:
89
+ a. Real-time content moderation and policy tagging.
90
+ b. Bulk product description normalisation with style rules.
91
+ c. News/article triage to decide which items warrant a deeper pass.
92
+ """,
93
+
94
+ "gpt-5-mini":"""gpt-5-thinking-mini. In/Out $0.25/$2 (cached in $0.025).
95
+ Cheaper, faster variant with broad task coverage; still supports tools and long context.
96
+ Best for:
97
+ 1. Production chatbots at scale
98
+ 2. Mid-complexity RAG/extraction pipelines
99
+ 3. Batch summarisation with occasional tool calls
100
+ Use cases:
101
+ a. Customer support copilot that classifies intent, drafts replies, and calls ticketing APIs.
102
+ b. Meeting-notes pipeline: diarised summary, actions, CRM updates.
103
+ c. ETL enrichment: pull facts from documents into structured JSON.
104
+ """,
105
+
106
+ "gpt-5":"""gpt-5-thinking. In/Out $1.25/$10.00 (cached in $0.125).
107
+ Advanced reasoning and tool use; strong code generation/repair; robust long-context handling (400k).
108
+ Best for:
109
+ 1. Complex agentic workflows and planning
110
+ 2. Long-context RAG and analytics
111
+ 3. High-stakes coding assistance (multi-file changes & tests)
112
+ Use cases:
113
+ a. An autonomous “data room” analyst reading hundreds of PDFs and producing audit-ready briefs.
114
+ b. A coding copilot that opens tickets, edits PRs, and runs tests via tools.</li>
115
+ c. An enterprise chat assistant that reasons over policies and produces compliant outputs.
116
+ """,
117
+
118
+ # "gpt-o3":"High-accuracy reasoning (200K-token); $2.00/1M in, $8.00/1M out. Best for math, code gen, structured data outputs.",
119
+ # "gpt-o4-mini":"Fast lean reasoning (200K-token); $1.10/1M in, $4.40/1M out. Ideal for vision+code when o3 is overkill.",
120
+ # "gpt-o4-mini-high":"Enhanced mini-engine; $2.50/1M in (est.), $10.00/1M out (est.). Suited for interactive assistants with visual reasoning.",
121
+
122
+ # Google
123
+ "gemma-3n-e4b-it":"""Gemma is free.
124
+ Best for: Use case:
125
+ - Low latency | - Visual and text processing
126
+ - Multilingual | - Text translation
127
+ - Summarization | - Summarizing text research content
128
+ """,
129
+
130
+ #2 Google
131
+ "gemma-3n-e4b-it": """
132
+ Open source for local hosting
133
+ """,
134
+
135
+ "gemini-2.0-flash-lite":"""$0.075 In, $0.30 Out. CoD: Aug 2024"
136
+ Best for: Use case:
137
+ - Long Context | - rocess 10,000 lines of code
138
+ - Realtime streaming | - Call tools natively
139
+ - Native tool use | - Stream images and video in realtime
140
+ """,
141
+
142
+ "gemini-2.0-flash": """$0.10 In, $0.40 Out. CoD: Aug 2024
143
+ Best for: Use case:
144
+ - Multimodal understanding | - Process 10,000 lines of code
145
+ - Realtime streaming | - Call tools natively, like Search
146
+ - Native tool use | - Stream images & vids in R time
147
+ """,
148
+
149
+ "gemini-2.5-flash-lite": "($0.10 In, $0.40 Out)/1M (est.) CoD: Jan 2025."
150
+ " Best for: Use case:"
151
+ " - Large scale processing - Data transformation"
152
+ " - Low latency, high volume - Translation"
153
+ " tasks with thinking - Summarizationt",
154
+
155
+ "gemini-2.5-flash": """$0.30. $2.50 Out CoD: Jan 2024.
156
+ Best for: Use case:
157
+ - Large scale processing - Reason over complex problems
158
+ - Low latency, high volume tasks - Show thinking process
159
+ - Agentic use cases - Call tools natively
160
+ """,
161
+
162
+ "gemini-2.5-pro": """$3.00 In /1M (est.). Advanced analytics, detailed reports & multi-step reasoning.
163
+ Best for:
164
+ - Coding
165
+ - Reasoning
166
+ - Multimodal understanding
167
+
168
+ Use case:
169
+ - Reason over complex problems
170
+ - Tackle difficult code, math and STEM problems
171
+ - Use the long context for analyzing large datasets, codebases or documents
172
+ """,
173
+
174
+ #3 XAI
175
+ "grok-3-mini-fast": "$0.20/1M (est.). "
176
+ "Ultra-low latency chat, real-time monitoring & streaming apps.",
177
+
178
+ "grok-3-mini": "$0.40/1M (est.). Budget-friendly chat & assistant tasks with good accuracy.",
179
+
180
+ "grok-3": "$1.00/1M (est.). General-purpose chat & content gen with balanced speed/quality.",
181
+
182
+ #4 DeepSeek
183
+ "deepseek-chat": "DeepSeek Chat; $1.20/1M (est.). Optimized for private-data Q&A, enterprise search & document ingestion.",
184
+
185
+ #5 MoonShot
186
+ "kimi-k2-0905-preview": """Mixture-of-Experts (MoE). Context length of 256k.
187
+ Enhanced Agentic Coding abilities, improved frontend code aesthetics and practicality, and better context understanding.
188
+
189
+ Pricing (per 1M tokens):
190
+ Input: $0.15
191
+ Cache: $0.60
192
+ Output: $2.50
193
+ """,
194
+
195
+ #6 Alibaba
196
+ #i
197
+ "qwen-flash": """ Qwen-Flash is a lightweight, high-speed large language model from Alibaba Cloud, optimized for efficiency and cost-effectiveness.
198
+
199
+ Pricing (per 1M tokens):
200
+ Input: $0.05
201
+ Output: $0.40
202
+
203
+ Best for:
204
+ > Simple, high-speed tasks requiring low latency.
205
+ > Cost-sensitive applications where budget is a priority.
206
+ > Scenarios demanding large context windows (supports up to 1M tokens).
207
+
208
+ Use cases:
209
+ > Real-time chat and dialogue systems needing quick responses.
210
+ > Large-scale text processing (e.g., summarization, polishing).
211
+ > Prototyping and development where rapid iteration is key.
212
+
213
+ Note: Lacks advanced reasoning features like "deep thinking" mode found in higher-tier Qwen models (e.g., Qwen-Plus).
214
+ """,
215
+
216
+ #ii
217
+ "qwen-plus": """LLM offering a balance of performance, speed, and cost. It features a 131,072 token context window and supports both thinking and non-thinking modes for enhanced reasoning.
218
+
219
+ Pricing (per 1M tokens):
220
+ Input: $0.40
221
+ Output: $1.20
222
+
223
+ Best for:
224
+ > Moderately complex reasoning tasks due to its enhanced reasoning capabilities and thinking mode support 16.
225
+ > Multilingual applications, with support for over 100 languages, including strong Chinese and English performance 12.
226
+ > Cost-sensitive deployments requiring a balance of capability and affordability 13.
227
+
228
+ Use cases:
229
+ > Customer service automation (e.g., chatbots, virtual assistants) 26.
230
+ > Content generation and summarization (e.g., marketing copy, document summarization) 236.
231
+ > Code generation and tool-assisted tasks due to its agent capabilities and tool-calling support
232
+ """,
233
+
234
+ #iii
235
+ "qwen3-Coder-Plus": """A commercial, high-performance coding model optimized for agentic tasks like tool use, browser interaction, and long-context code generation.
236
+
237
+ Pricing (per 1M tokens):
238
+ Input $1 (0-32K tokens), $1.8 (32K-128K), $3 (128K-256K), $6 (256K-1M).
239
+ Output $5 (0-32K), $9 (32K-128K), $15 (128K-256K), $60 (256K-1M)
240
+
241
+ Best for:
242
+ > Repository-scale coding (handles large codebases with long context).
243
+ > Agentic workflows (tool calling, multi-step environment interactions).
244
+ > Real-world software engineering (debugging, refactoring, SWE-bench tasks).
245
+
246
+ Use cases:
247
+ > Automating complex coding tasks (e.g., full-stack app generation, data storytelling).
248
+ > Debugging and refactoring (identifying bugs, improving code quality).
249
+ > Multi-turn coding with feedback (iterative problem-solving with execution).
250
+ > Consider this model if you need long-context, agentic coding capabilities comparable to Claude Sonnet 17. Avoid if budget constraints outweigh performance needs.
251
+ """,
252
+
253
+ #iv
254
+ "qwen-max": """Alibaba Cloud's flagship large-scale Mixture-of-Experts (MoE) model, pretrained on 20+ trillion tokens and refined with SFT/RLHF. Competes with top models like GPT-4o and Claude-3.5-Sonnet in benchmarks.
255
+
256
+ Pricing (per 1M tokens):
257
+ Input: $1.60 - Output: $6.40
258
+
259
+ Best for:
260
+ > Complex, multi-step reasoning tasks 113
261
+ > Multilingual applications (supports 100+ languages)
262
+ > Coding and tool-calling precision 111
263
+
264
+ Use cases:
265
+ > Advanced coding assistance and debugging 310
266
+ > High-quality content creation (e.g., documents, scripts)
267
+ > Large-context analysis (32K token window) for documents or data
268
+
269
+ """,
270
+
271
+ "claude-opus-4-1":""" $15 / MTok $18.75 / MTok $30 / MTok $1.50 / MTok $75 / MTok
272
+ """,
273
+
274
+ "claude-sonnet-4-0":""" $3 / MTok $3.75 / MTok $6 / MTok $0.30 / MTok $15 / MTok
275
+ """,
276
+
277
+ "claude-haiku-3-5-latest":""" $0.80 / MTok $1 / MTok $1.6 / MTok $0.08 / MTok $4 / MTok
278
+ """,
279
+
280
+ "claude-3-haiku-20240307":""" $0.25 / MTok $0.30 / MTok $0.50 / MTok $0.03 / MTok $1.25 / MTok
281
+ """,
282
+
39
283
  }
40
284
 
285
+
286
+ # -----------------------------------------------------------------------------
41
287
  PURPOSE_TAGS = [
288
+ "admin",
42
289
  "chat",
43
- "coder",
44
- "labeller",
45
- "classifier"
290
+ "coding",
291
+ "vision2text",
292
+ "classification",
293
+ "summarization",
294
+ ]
295
+
296
+ # -----------------------------------------------------------------------------
297
+ EMBEDDING_MODELS = {
298
+ "openai": [
299
+ "text-embedding-3-small",
300
+ "text-embedding-3-large",
301
+ ],
302
+ }
303
+
304
+
305
+ GPT_MODELS_LATEST = [
306
+ "gpt-5.1",
307
+ "gpt-5.1-chat-latest",
308
+ "gpt-5.1-codex-mini",
309
+ "gpt-5.1-codex",
310
+ "gpt-5",
311
+ "gpt-5-nano",
312
+ "gpt-5-mini",
46
313
  ]