crystalwindow 4.3__tar.gz → 4.4__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.
- {crystalwindow-4.3/crystalwindow.egg-info → crystalwindow-4.4}/PKG-INFO +1 -1
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/ai.py +89 -52
- {crystalwindow-4.3 → crystalwindow-4.4/crystalwindow.egg-info}/PKG-INFO +1 -1
- {crystalwindow-4.3 → crystalwindow-4.4}/setup.py +1 -1
- {crystalwindow-4.3 → crystalwindow-4.4}/LICENSE +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/MANIFEST.in +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/README.md +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/FileHelper.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/Icons/default_icon.png +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/__init__.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/animation.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/assets.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/camera.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/clock.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/collision.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/color_handler.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/crystal3d.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/docs/getting_started.md +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/docs/index.md +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/draw_helpers.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/draw_rects.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/draw_text_helper.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/draw_tool.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/fun_helpers.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/gametests/3dsquare.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/gametests/__init__.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/gametests/__main__.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/gametests/gravitytest.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/gametests/guitesting.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/gametests/sandbox.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/gametests/squaremove.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/gametests/windowtesting.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/gravity.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/gui.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/gui_ext.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/math.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/player.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/sprites.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/tilemap.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/ver_warner.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow/window.py +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow.egg-info/SOURCES.txt +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow.egg-info/dependency_links.txt +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/crystalwindow.egg-info/top_level.txt +0 -0
- {crystalwindow-4.3 → crystalwindow-4.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: crystalwindow
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.4
|
|
4
4
|
Summary: A Tkinter powered window + GUI toolkit made by Crystal (MEEEEEE)! Easier apps, smoother UI and all-in-one helpers!
|
|
5
5
|
Home-page: https://pypi.org/project/crystalwindow/
|
|
6
6
|
Author: CrystalBallyHereXD
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
# ==========================================================
|
|
2
|
-
# CrystalAI v0.
|
|
2
|
+
# CrystalAI v0.8 — Hybrid Engine (Groq + Symbolic Fallback)
|
|
3
3
|
# ----------------------------------------------------------
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
# -
|
|
7
|
-
# -
|
|
8
|
-
# - Added context/intent matching for 'thinking'
|
|
9
|
-
# - Removed Groq/External API integration
|
|
4
|
+
# Combines:
|
|
5
|
+
# - Groq API for general knowledge (Primary)
|
|
6
|
+
# - Pure Python Symbolic Engine for Code Analysis (Fallback)
|
|
7
|
+
# - Memory, File Reading, AST Parsing, and Diff Utilities
|
|
10
8
|
# ==========================================================
|
|
11
9
|
|
|
12
10
|
import os
|
|
13
11
|
import ast
|
|
14
12
|
import difflib
|
|
13
|
+
import requests # Re-added for API communication
|
|
15
14
|
from typing import Optional, Dict, Any, List
|
|
16
|
-
# Removed
|
|
17
|
-
# Removed import groq (if it was present)
|
|
15
|
+
# Removed groq import, using requests for simplicity
|
|
18
16
|
|
|
19
17
|
# ==========================================================
|
|
20
18
|
# Response Wrapper
|
|
@@ -32,41 +30,53 @@ class CrystalAIResponse:
|
|
|
32
30
|
# MAIN ENGINE
|
|
33
31
|
# ==========================================================
|
|
34
32
|
class AI:
|
|
35
|
-
DEFAULT_MODEL = "
|
|
33
|
+
DEFAULT_MODEL = "llama-3.1-8b"
|
|
36
34
|
DEFAULT_PERSONALITY = (
|
|
37
|
-
"You are
|
|
38
|
-
"
|
|
39
|
-
"
|
|
35
|
+
"You are CrystalWindow AI. You help users with Python code, "
|
|
36
|
+
"debugging, errors, docs, and file analysis. You are currently running in "
|
|
37
|
+
"Hybrid Mode. Be friendly, technical, clear, and precise."
|
|
40
38
|
)
|
|
41
|
-
# Key
|
|
42
|
-
PLACEHOLDER_KEY = "
|
|
39
|
+
# Placeholder Key for testing or when user key is invalid
|
|
40
|
+
PLACEHOLDER_KEY = "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"
|
|
43
41
|
|
|
44
42
|
# ------------------------------------------------------
|
|
45
43
|
def __init__(self, key=None, model=None):
|
|
46
|
-
# --- KEY
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
# --- KEY VALIDATION ---
|
|
45
|
+
if not key or len(key) < 20 or " " in key:
|
|
46
|
+
print("[CrystalAI] Warning: Invalid or missing key → using placeholder. To get a Fixed Key go to 'console.groq.com/keys'")
|
|
47
|
+
self.key = self.PLACEHOLDER_KEY
|
|
48
|
+
else:
|
|
49
|
+
self.key = key
|
|
50
|
+
|
|
51
|
+
# --- MODEL VALIDATION ---
|
|
52
|
+
if not model or not isinstance(model, str) or len(model) < 3:
|
|
53
|
+
print(f"[CrystalAI] Unknown model → using default: {self.DEFAULT_MODEL}.")
|
|
54
|
+
self.model = self.DEFAULT_MODEL
|
|
55
|
+
else:
|
|
56
|
+
self.model = model
|
|
57
|
+
|
|
58
|
+
# Persona
|
|
49
59
|
self.personality = self.DEFAULT_PERSONALITY
|
|
50
60
|
|
|
51
|
-
#
|
|
61
|
+
# Pure AI knowledge (used in symbolic fallback)
|
|
52
62
|
self.knowledge_graph: Dict[str, Any] = self._build_knowledge_graph()
|
|
53
63
|
|
|
54
|
-
#
|
|
64
|
+
# Library knowledge (loaded .py files)
|
|
65
|
+
self.library_context = ""
|
|
66
|
+
|
|
67
|
+
# Memory system
|
|
55
68
|
self.memory: List[Dict[str, str]] = []
|
|
56
69
|
self.use_memory = True
|
|
57
70
|
|
|
58
|
-
#
|
|
59
|
-
self.force_local =
|
|
60
|
-
|
|
61
|
-
# Library knowledge (loaded .py files)
|
|
62
|
-
self.library_context = ""
|
|
71
|
+
# Force local toggle (currently not used as logic is based on Groq success)
|
|
72
|
+
self.force_local = False
|
|
63
73
|
|
|
64
74
|
# ==========================================================
|
|
65
75
|
# PERSONALITY
|
|
66
76
|
# ==========================================================
|
|
67
77
|
def set_personality(self, txt):
|
|
68
78
|
if not isinstance(txt, str) or len(txt.strip()) < 10:
|
|
69
|
-
print("Oops!
|
|
79
|
+
print("Oops! that's not how to use it—reverting to default.")
|
|
70
80
|
self.personality = self.DEFAULT_PERSONALITY
|
|
71
81
|
return
|
|
72
82
|
|
|
@@ -83,7 +93,6 @@ class AI:
|
|
|
83
93
|
def index_library(self, folder):
|
|
84
94
|
"""
|
|
85
95
|
Load all Python files as context for smarter answers.
|
|
86
|
-
(Context is used in prompt but processed by local engine's rules)
|
|
87
96
|
"""
|
|
88
97
|
out = []
|
|
89
98
|
if not os.path.exists(folder):
|
|
@@ -97,7 +106,7 @@ class AI:
|
|
|
97
106
|
path = os.path.join(root, f)
|
|
98
107
|
with open(path, "r", encoding="utf8") as fp:
|
|
99
108
|
out.append(f"# FILE: {path}\n" + fp.read() + "\n\n")
|
|
100
|
-
except:
|
|
109
|
+
except Exception:
|
|
101
110
|
pass
|
|
102
111
|
|
|
103
112
|
self.library_context = "\n".join(out)
|
|
@@ -113,8 +122,8 @@ class AI:
|
|
|
113
122
|
try:
|
|
114
123
|
with open(path, "r", encoding="utf8") as f:
|
|
115
124
|
return f.read()
|
|
116
|
-
except:
|
|
117
|
-
return "[CrystalAI]
|
|
125
|
+
except Exception:
|
|
126
|
+
return "[CrystalAI] couldn't read file."
|
|
118
127
|
|
|
119
128
|
# ==========================================================
|
|
120
129
|
# PROMPT BUILDER (Unified)
|
|
@@ -145,11 +154,11 @@ class AI:
|
|
|
145
154
|
self.memory.pop(0)
|
|
146
155
|
|
|
147
156
|
# ==========================================================
|
|
148
|
-
# PURE AI KNOWLEDGE BASE (
|
|
157
|
+
# PURE AI KNOWLEDGE BASE (Symbolic Core)
|
|
149
158
|
# ==========================================================
|
|
150
159
|
def _build_knowledge_graph(self) -> Dict[str, Any]:
|
|
151
160
|
"""
|
|
152
|
-
Defines the internal knowledge the
|
|
161
|
+
Defines the internal knowledge the symbolic AI can reason with.
|
|
153
162
|
"""
|
|
154
163
|
return {
|
|
155
164
|
"python": {
|
|
@@ -169,15 +178,15 @@ class AI:
|
|
|
169
178
|
"keywords": ["fix", "error", "bug", "syntax"]
|
|
170
179
|
}
|
|
171
180
|
}
|
|
172
|
-
|
|
181
|
+
|
|
173
182
|
# ==========================================================
|
|
174
|
-
# PURE AI 'THINKING' ENGINE (
|
|
183
|
+
# PURE AI 'THINKING' ENGINE (Symbolic Fallback)
|
|
175
184
|
# ==========================================================
|
|
176
185
|
def _symbolic_engine(self, prompt: str, file_data: Optional[str]) -> str:
|
|
177
186
|
"""
|
|
178
|
-
Simulates 'thinking' using only internal rules and
|
|
187
|
+
Fallback logic: Simulates 'thinking' using only internal rules and AST.
|
|
179
188
|
"""
|
|
180
|
-
output = ["[SymbolicEngine] Processing request..."]
|
|
189
|
+
output = ["[Local/SymbolicEngine] Processing request..."]
|
|
181
190
|
lower_prompt = prompt.lower()
|
|
182
191
|
|
|
183
192
|
# --- Stage 1: File Analysis (Real Python AST) ---
|
|
@@ -189,15 +198,12 @@ class AI:
|
|
|
189
198
|
output.append("The code is structurally sound. Ask for refactoring or explanation.")
|
|
190
199
|
return "\n".join(output)
|
|
191
200
|
except SyntaxError as se:
|
|
192
|
-
# Use the built-in fix rule from the knowledge graph
|
|
193
201
|
fix_rule = self.knowledge_graph["fix_code"]["rule"]
|
|
194
202
|
lineno = se.lineno or 0
|
|
195
|
-
offset = se.offset or 0
|
|
196
203
|
msg = (
|
|
197
204
|
f"❌ **SyntaxError Detected** (via AST):\n"
|
|
198
205
|
f"• Message: {se.msg}\n"
|
|
199
206
|
f"• Line: {lineno}\n"
|
|
200
|
-
f"• Column: {offset}\n"
|
|
201
207
|
f"• Rule suggestion: {fix_rule}"
|
|
202
208
|
)
|
|
203
209
|
output.append(msg)
|
|
@@ -207,16 +213,14 @@ class AI:
|
|
|
207
213
|
# --- Stage 2: Knowledge Graph Lookup (Rule-Based Reasoning) ---
|
|
208
214
|
output.append("\n[Stage 2: Symbolic Lookup]")
|
|
209
215
|
|
|
210
|
-
# Check for concepts the AI 'knows'
|
|
211
216
|
found_concept = False
|
|
212
217
|
for key, knowledge in self.knowledge_graph.items():
|
|
213
218
|
if key in lower_prompt or any(k in lower_prompt for k in knowledge.get("keywords", [])):
|
|
214
|
-
if key == "fix_code": continue
|
|
219
|
+
if key == "fix_code": continue
|
|
215
220
|
|
|
216
221
|
output.append(f"🧠 Found Concept: **{key.upper()}**")
|
|
217
222
|
output.append(f"Description: {knowledge.get('desc', 'No detailed description.')}")
|
|
218
223
|
|
|
219
|
-
# Simple reasoning about related syntax
|
|
220
224
|
if 'syntax' in knowledge:
|
|
221
225
|
output.append("Related Syntax:")
|
|
222
226
|
for syn, code in knowledge['syntax'].items():
|
|
@@ -226,21 +230,55 @@ class AI:
|
|
|
226
230
|
break
|
|
227
231
|
|
|
228
232
|
if not found_concept:
|
|
229
|
-
output.append("❓ Concept Unknown: I am limited to my internal knowledge base (Python, AST, Fix Code).")
|
|
230
|
-
output.append("Please
|
|
231
|
-
|
|
233
|
+
output.append("❓ Concept Unknown: I am currently offline and limited to my internal knowledge base (Python, AST, Fix Code).")
|
|
234
|
+
output.append("Please provide a file for AST analysis or try again later for a full Groq response.")
|
|
232
235
|
|
|
233
236
|
return "\n".join(output)
|
|
234
237
|
|
|
238
|
+
|
|
235
239
|
# ==========================================================
|
|
236
|
-
# ASK (
|
|
240
|
+
# ASK (Groq → Symbolic Fallback)
|
|
237
241
|
# ==========================================================
|
|
238
242
|
def ask(self, text, file=None):
|
|
239
243
|
file_data = self._read_file(file)
|
|
240
244
|
prompt = self._build_prompt(text, file_data)
|
|
241
245
|
|
|
242
|
-
|
|
243
|
-
|
|
246
|
+
resp = None
|
|
247
|
+
|
|
248
|
+
# --- Attempt 1: Call External API (Groq) ---
|
|
249
|
+
try:
|
|
250
|
+
url = "https://api.groq.com/openai/v1/chat/completions"
|
|
251
|
+
headers = {
|
|
252
|
+
"Authorization": f"Bearer {self.key}",
|
|
253
|
+
"Content-Type": "application/json"
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
payload = {
|
|
257
|
+
"model": self.model,
|
|
258
|
+
"messages": [
|
|
259
|
+
{"role": "system", "content": self.personality},
|
|
260
|
+
{"role": "user", "content": prompt}
|
|
261
|
+
],
|
|
262
|
+
"temperature": 0.3
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
r = requests.post(url, json=payload, headers=headers, timeout=10)
|
|
266
|
+
data = r.json()
|
|
267
|
+
|
|
268
|
+
if "error" in data:
|
|
269
|
+
# If the API returns an error (e.g., bad key), we force the fallback
|
|
270
|
+
raise RuntimeError(f"API Error: {data['error'].get('message', 'Unknown API Error')}")
|
|
271
|
+
|
|
272
|
+
resp = data["choices"][0]["message"]["content"]
|
|
273
|
+
|
|
274
|
+
except Exception as e:
|
|
275
|
+
# This block handles API connection failures (timeout) or API-side errors (bad key)
|
|
276
|
+
print(f"[CrystalAI] Groq connection failed or returned error: {e.__class__.__name__}")
|
|
277
|
+
print("[CrystalAI] Falling back to self-contained Symbolic Engine...")
|
|
278
|
+
|
|
279
|
+
# --- Attempt 2: Fallback to Symbolic Engine ---
|
|
280
|
+
resp = self._symbolic_engine(prompt, file_data)
|
|
281
|
+
|
|
244
282
|
|
|
245
283
|
self._save_memory(text, resp)
|
|
246
284
|
return CrystalAIResponse(resp)
|
|
@@ -278,7 +316,7 @@ class AI:
|
|
|
278
316
|
msg = getattr(syntax_error, "msg", "")
|
|
279
317
|
lineno = syntax_error.lineno or 0
|
|
280
318
|
|
|
281
|
-
# missing colon
|
|
319
|
+
# missing colon fix
|
|
282
320
|
if "expected" in msg and ":" in msg:
|
|
283
321
|
if 1 <= lineno <= len(lines):
|
|
284
322
|
line = lines[lineno - 1].rstrip()
|
|
@@ -289,7 +327,7 @@ class AI:
|
|
|
289
327
|
try:
|
|
290
328
|
ast.parse(candidate)
|
|
291
329
|
return candidate, notes
|
|
292
|
-
except:
|
|
330
|
+
except Exception:
|
|
293
331
|
pass
|
|
294
332
|
|
|
295
333
|
# fallback
|
|
@@ -320,10 +358,9 @@ class AI:
|
|
|
320
358
|
out = []
|
|
321
359
|
for i in range(start, end):
|
|
322
360
|
mark = "->" if (i + 1) == lineno else " "
|
|
323
|
-
# Adjusted line formatting for clarity
|
|
324
361
|
out.append(f"{mark} {i+1:<4}: {lines[i]}")
|
|
325
362
|
return "\n".join(out)
|
|
326
363
|
|
|
327
364
|
# ==========================================================
|
|
328
|
-
# END OF
|
|
365
|
+
# END OF HYBRID ENGINE
|
|
329
366
|
# ==========================================================
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: crystalwindow
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.4
|
|
4
4
|
Summary: A Tkinter powered window + GUI toolkit made by Crystal (MEEEEEE)! Easier apps, smoother UI and all-in-one helpers!
|
|
5
5
|
Home-page: https://pypi.org/project/crystalwindow/
|
|
6
6
|
Author: CrystalBallyHereXD
|
|
@@ -7,7 +7,7 @@ with open("README.md", encoding="utf-8") as f:
|
|
|
7
7
|
|
|
8
8
|
setup(
|
|
9
9
|
name="crystalwindow",
|
|
10
|
-
version="4.
|
|
10
|
+
version="4.4", # Force metadata refresh
|
|
11
11
|
packages=find_packages(include=["crystalwindow", "crystalwindow.*"]),
|
|
12
12
|
|
|
13
13
|
include_package_data=True, # include package_data files
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|