jaadu 0.1.0__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.
- jaadu/__init__.py +4 -0
- jaadu/core.py +60 -0
- jaadu-0.1.0.dist-info/METADATA +19 -0
- jaadu-0.1.0.dist-info/RECORD +7 -0
- jaadu-0.1.0.dist-info/WHEEL +5 -0
- jaadu-0.1.0.dist-info/licenses/LICENSE +21 -0
- jaadu-0.1.0.dist-info/top_level.txt +1 -0
jaadu/__init__.py
ADDED
jaadu/core.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
import urllib.request
|
|
4
|
+
import urllib.error
|
|
5
|
+
|
|
6
|
+
# Embedded default Groq API Key
|
|
7
|
+
_DEFAULT_KEY = "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"
|
|
8
|
+
_API_URL = "https://api.groq.com/openai/v1/chat/completions"
|
|
9
|
+
_DEFAULT_MODEL = "qwen/qwen3.8-27b"
|
|
10
|
+
|
|
11
|
+
def get(prompt: str, model: str = _DEFAULT_MODEL, max_tokens: int = 800) -> None:
|
|
12
|
+
"""
|
|
13
|
+
Sends the prompt as a system prompt to Groq and displays the formatted Markdown
|
|
14
|
+
directly into the Jupyter display. Falls back to print() in terminal environments.
|
|
15
|
+
"""
|
|
16
|
+
api_key = os.environ.get("GROQ_API_KEY", _DEFAULT_KEY)
|
|
17
|
+
|
|
18
|
+
headers = {
|
|
19
|
+
"Authorization": f"Bearer {api_key}",
|
|
20
|
+
"Content-Type": "application/json",
|
|
21
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
payload = {
|
|
25
|
+
"model": model,
|
|
26
|
+
"max_tokens": max_tokens,
|
|
27
|
+
"messages": [
|
|
28
|
+
{"role": "system", "content": str(prompt)},
|
|
29
|
+
{"role": "user", "content": "Please respond to the system prompt."}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
req = urllib.request.Request(
|
|
34
|
+
_API_URL,
|
|
35
|
+
data=json.dumps(payload).encode("utf-8"),
|
|
36
|
+
headers=headers,
|
|
37
|
+
method="POST"
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
try:
|
|
41
|
+
with urllib.request.urlopen(req, timeout=45) as response:
|
|
42
|
+
result = json.loads(response.read().decode("utf-8"))
|
|
43
|
+
content = result["choices"][0]["message"]["content"]
|
|
44
|
+
except urllib.error.HTTPError as e:
|
|
45
|
+
err_body = e.read().decode("utf-8")
|
|
46
|
+
content = f"**Error {e.code}**: {err_body}"
|
|
47
|
+
except Exception as e:
|
|
48
|
+
content = f"**Request Error**: {e}"
|
|
49
|
+
|
|
50
|
+
# Display directly in Jupyter if in notebook environment; otherwise print text
|
|
51
|
+
try:
|
|
52
|
+
from IPython import get_ipython
|
|
53
|
+
from IPython.display import display, Markdown
|
|
54
|
+
|
|
55
|
+
if get_ipython() is not None:
|
|
56
|
+
display(Markdown(content))
|
|
57
|
+
else:
|
|
58
|
+
print(content)
|
|
59
|
+
except Exception:
|
|
60
|
+
print(content)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jaadu
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: One-line Groq prompt to Jupyter Markdown display
|
|
5
|
+
Author: jaadu contributor
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: groq,jupyter,markdown,llm,display,jaadu
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Framework :: IPython
|
|
11
|
+
Classifier: Framework :: Jupyter
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Provides-Extra: jupyter
|
|
16
|
+
Requires-Dist: ipython>=7.0.0; extra == "jupyter"
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
Chori Karvu paap nathi, chori karta pakdavu paap che
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
jaadu/__init__.py,sha256=ZqwYTCdNZdiCJd9xZjdRZvZ64PECzeSPXRvnpZFtrNY,63
|
|
2
|
+
jaadu/core.py,sha256=yrLiQlQ-GdH0stN-_1ldwlBYCqI6rqcUSTCkhORJ_NU,1961
|
|
3
|
+
jaadu-0.1.0.dist-info/licenses/LICENSE,sha256=KnrKB5ZaGsGOv8MUP1HYpQSEHZqIFmUQCA0Mez4APHw,1078
|
|
4
|
+
jaadu-0.1.0.dist-info/METADATA,sha256=QmUpbSuTM_pI2M-tOEMVHIFIXm7tf4_wBPyleJUP3-A,622
|
|
5
|
+
jaadu-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
6
|
+
jaadu-0.1.0.dist-info/top_level.txt,sha256=wpdcR5DD7XQi7jKdklAcytBD52bnf4eLnN29tViEqek,6
|
|
7
|
+
jaadu-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 sorrypar contributors
|
|
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 @@
|
|
|
1
|
+
jaadu
|