supermegaexplosion 0.2.0__tar.gz → 0.3.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.
Files changed (20) hide show
  1. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/PKG-INFO +1 -1
  2. supermegaexplosion-0.3.0/libbs/ai_helper.py +74 -0
  3. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/pyproject.toml +1 -1
  4. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/supermegaexplosion.egg-info/PKG-INFO +1 -1
  5. supermegaexplosion-0.2.0/libbs/ai_helper.py +0 -46
  6. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/README.md +0 -0
  7. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/libbs/__init__.py +0 -0
  8. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/libbs/arrays.py +0 -0
  9. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/libbs/catalog.py +0 -0
  10. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/libbs/ds.py +0 -0
  11. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/libbs/input_utils.py +0 -0
  12. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/libbs/math_utils.py +0 -0
  13. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/libbs/strings.py +0 -0
  14. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/libbs/tools/__init__.py +0 -0
  15. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/libbs/tools/add_func.py +0 -0
  16. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/setup.cfg +0 -0
  17. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/supermegaexplosion.egg-info/SOURCES.txt +0 -0
  18. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/supermegaexplosion.egg-info/dependency_links.txt +0 -0
  19. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/supermegaexplosion.egg-info/requires.txt +0 -0
  20. {supermegaexplosion-0.2.0 → supermegaexplosion-0.3.0}/supermegaexplosion.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: supermegaexplosion
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: DSA utility library — input helpers, algorithms, data structures, and AI assistant
5
5
  Author-email: "Hadoopnb.ai" <hadoopnb@example.com>
6
6
  License-Expression: MIT
@@ -0,0 +1,74 @@
1
+ import os
2
+ import json
3
+ import base64
4
+
5
+ _CONFIG_DIR = os.path.expanduser("~/.config/supermegaexplosion")
6
+ _CONFIG_FILE = os.path.join(_CONFIG_DIR, "config.json")
7
+
8
+ _EMBEDDED_KEY = base64.b64decode(
9
+ "QVEuQWI4Uk42TEFaTm14Tmh3UnJ0T0p1TWhFQjh3UzI2bDkzRWRfR2RPOWdGalJMbFdNY1E="
10
+ ).decode()
11
+
12
+
13
+ def _load_config():
14
+ try:
15
+ with open(_CONFIG_FILE) as f:
16
+ return json.load(f)
17
+ except (FileNotFoundError, json.JSONDecodeError):
18
+ return {}
19
+
20
+
21
+ def _save_config(data):
22
+ os.makedirs(_CONFIG_DIR, exist_ok=True)
23
+ with open(_CONFIG_FILE, "w") as f:
24
+ json.dump(data, f)
25
+
26
+
27
+ def respond_help(query=None, api_key=None, model="gemini-2.0-flash-lite"):
28
+ if query is None:
29
+ query = input("Ask a DSA/Python question: ").strip()
30
+ if not query:
31
+ return
32
+
33
+ try:
34
+ from google import genai
35
+ except ImportError:
36
+ print(
37
+ "Missing dependency. Install with:\n"
38
+ " pip install supermegaexplosion[ai]"
39
+ )
40
+ return
41
+
42
+ key = api_key or os.environ.get("GEMINI_API_KEY") or _load_config().get("api_key")
43
+
44
+ if not key:
45
+ print(
46
+ "No API key found. Using a shared demo key (rate-limited).\n"
47
+ "Set your own free key at https://aistudio.google.com/ for better quota.\n"
48
+ )
49
+ key = _EMBEDDED_KEY
50
+ _save_config({"api_key": ""})
51
+
52
+ if key == _EMBEDDED_KEY and not _load_config().get("api_key"):
53
+ ans = input("Enter your Gemini API key (or press Enter to use the demo key): ").strip()
54
+ if ans:
55
+ key = ans
56
+ _save_config({"api_key": ans})
57
+
58
+ try:
59
+ client = genai.Client(api_key=key)
60
+ resp = client.models.generate_content(
61
+ model=model,
62
+ contents=(
63
+ "You are a DSA and Python coding assistant. "
64
+ "Answer concisely with code examples.\n\n"
65
+ f"Question: {query}"
66
+ ),
67
+ config={
68
+ "max_output_tokens": 512,
69
+ "temperature": 0.3,
70
+ },
71
+ )
72
+ print(resp.text)
73
+ except Exception as e:
74
+ print(f"Error: {e}")
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "supermegaexplosion"
7
- version = "0.2.0"
7
+ version = "0.3.0"
8
8
  description = "DSA utility library — input helpers, algorithms, data structures, and AI assistant"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Hadoopnb.ai", email = "hadoopnb@example.com" }]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: supermegaexplosion
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: DSA utility library — input helpers, algorithms, data structures, and AI assistant
5
5
  Author-email: "Hadoopnb.ai" <hadoopnb@example.com>
6
6
  License-Expression: MIT
@@ -1,46 +0,0 @@
1
- import os
2
-
3
-
4
- def respond_help(query=None, api_key=None, model="gemini-2.0-flash-lite"):
5
- if query is None:
6
- query = input("Ask a DSA/Python question: ").strip()
7
- if not query:
8
- return
9
-
10
- if api_key is None:
11
- api_key = os.environ.get("GEMINI_API_KEY")
12
- if not api_key:
13
- print(
14
- "Gemini API key not found.\n"
15
- "Set the GEMINI_API_KEY environment variable:\n"
16
- " set GEMINI_API_KEY=your_key_here\n"
17
- "Or pass api_key='your_key' to respond_help()."
18
- )
19
- return
20
-
21
- try:
22
- from google import genai
23
- except ImportError:
24
- print(
25
- "Missing dependency. Install with:\n"
26
- " pip install supermegaexplosion[ai]"
27
- )
28
- return
29
-
30
- try:
31
- client = genai.Client(api_key=api_key)
32
- resp = client.models.generate_content(
33
- model=model,
34
- contents=(
35
- "You are a DSA and Python coding assistant. "
36
- "Answer concisely with code examples.\n\n"
37
- f"Question: {query}"
38
- ),
39
- config={
40
- "max_output_tokens": 512,
41
- "temperature": 0.3,
42
- },
43
- )
44
- print(resp.text)
45
- except Exception as e:
46
- print(f"Error: {e}")