portable-ai 1.0.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.
- portable_ai-1.0.0/LICENSE +1 -0
- portable_ai-1.0.0/PKG-INFO +18 -0
- portable_ai-1.0.0/README.md +1 -0
- portable_ai-1.0.0/portable_ai/__init__.py +26 -0
- portable_ai-1.0.0/portable_ai/cli.py +18 -0
- portable_ai-1.0.0/portable_ai/client.py +27 -0
- portable_ai-1.0.0/portable_ai.egg-info/PKG-INFO +18 -0
- portable_ai-1.0.0/portable_ai.egg-info/SOURCES.txt +12 -0
- portable_ai-1.0.0/portable_ai.egg-info/dependency_links.txt +1 -0
- portable_ai-1.0.0/portable_ai.egg-info/entry_points.txt +2 -0
- portable_ai-1.0.0/portable_ai.egg-info/requires.txt +1 -0
- portable_ai-1.0.0/portable_ai.egg-info/top_level.txt +1 -0
- portable_ai-1.0.0/setup.cfg +4 -0
- portable_ai-1.0.0/setup.py +18 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
No LICENSES.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: portable-ai
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Portable AI proxy via Cloudflare Workers + Groq
|
|
5
|
+
Author: UmairDC
|
|
6
|
+
Requires-Python: >=3.7
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: requests>=2.28
|
|
10
|
+
Dynamic: author
|
|
11
|
+
Dynamic: description
|
|
12
|
+
Dynamic: description-content-type
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
Dynamic: requires-dist
|
|
15
|
+
Dynamic: requires-python
|
|
16
|
+
Dynamic: summary
|
|
17
|
+
|
|
18
|
+
DONTREADEME.md
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
DONTREADEME.md
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import requests
|
|
3
|
+
|
|
4
|
+
# Configurable via Env Vars or Defaults
|
|
5
|
+
API_URL = os.getenv("PORTABLE_AI_URL", "https://YOUR-WORKER.workers.dev")
|
|
6
|
+
AUTH_CODE = os.getenv("P_AI_CODE", "")
|
|
7
|
+
|
|
8
|
+
def ask(prompt: str) -> str:
|
|
9
|
+
"""Send a prompt to your private AI worker."""
|
|
10
|
+
resp = requests.post(
|
|
11
|
+
API_URL,
|
|
12
|
+
json={"prompt": prompt},
|
|
13
|
+
headers={"X-Auth": AUTH_CODE},
|
|
14
|
+
timeout=30
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
if resp.status_code == 403:
|
|
18
|
+
raise PermissionError("🔒 Access Denied! Set P_AI_CODE env var.")
|
|
19
|
+
|
|
20
|
+
resp.raise_for_status()
|
|
21
|
+
return resp.text.strip()
|
|
22
|
+
|
|
23
|
+
# CLI Shortcut
|
|
24
|
+
if __name__ == "__main__":
|
|
25
|
+
import sys
|
|
26
|
+
print(ask(" ".join(sys.argv[1:])))
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from portable_ai import ask
|
|
3
|
+
|
|
4
|
+
def main():
|
|
5
|
+
if len(sys.argv) < 2:
|
|
6
|
+
print("Usage: p-ai 'your question'")
|
|
7
|
+
sys.exit(1)
|
|
8
|
+
|
|
9
|
+
prompt = " ".join(sys.argv[1:])
|
|
10
|
+
try:
|
|
11
|
+
response = ask(prompt)
|
|
12
|
+
print(response)
|
|
13
|
+
except Exception as e:
|
|
14
|
+
print(f"❌ Error: {e}", file=sys.stderr)
|
|
15
|
+
sys.exit(1)
|
|
16
|
+
|
|
17
|
+
if __name__ == "__main__":
|
|
18
|
+
main()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import requests
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
DEFAULT_API_URL = "https://YOUR_WORKER.workers.dev"
|
|
6
|
+
DEFAULT_AUTH_CODE = os.getenv("P_AI_CODE", "")
|
|
7
|
+
|
|
8
|
+
class PortableAI:
|
|
9
|
+
def __init__(self, api_url: str = DEFAULT_API_URL, auth_code: str = DEFAULT_AUTH_CODE):
|
|
10
|
+
self.api_url = api_url
|
|
11
|
+
self.auth_code = auth_code
|
|
12
|
+
|
|
13
|
+
def ask(self, prompt: str) -> str:
|
|
14
|
+
resp = requests.post(
|
|
15
|
+
self.api_url,
|
|
16
|
+
json={"prompt": prompt},
|
|
17
|
+
headers={"X-Auth": self.auth_code},
|
|
18
|
+
timeout=30
|
|
19
|
+
)
|
|
20
|
+
if resp.status_code == 403:
|
|
21
|
+
raise PermissionError("🔒 Invalid CODE-2! Set P_AI_CODE env var.")
|
|
22
|
+
resp.raise_for_status()
|
|
23
|
+
return resp.text.strip()
|
|
24
|
+
|
|
25
|
+
# Singleton for easy access
|
|
26
|
+
_default_client = PortableAI()
|
|
27
|
+
ask = _default_client.ask
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: portable-ai
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Portable AI proxy via Cloudflare Workers + Groq
|
|
5
|
+
Author: UmairDC
|
|
6
|
+
Requires-Python: >=3.7
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: requests>=2.28
|
|
10
|
+
Dynamic: author
|
|
11
|
+
Dynamic: description
|
|
12
|
+
Dynamic: description-content-type
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
Dynamic: requires-dist
|
|
15
|
+
Dynamic: requires-python
|
|
16
|
+
Dynamic: summary
|
|
17
|
+
|
|
18
|
+
DONTREADEME.md
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
setup.py
|
|
4
|
+
portable_ai/__init__.py
|
|
5
|
+
portable_ai/cli.py
|
|
6
|
+
portable_ai/client.py
|
|
7
|
+
portable_ai.egg-info/PKG-INFO
|
|
8
|
+
portable_ai.egg-info/SOURCES.txt
|
|
9
|
+
portable_ai.egg-info/dependency_links.txt
|
|
10
|
+
portable_ai.egg-info/entry_points.txt
|
|
11
|
+
portable_ai.egg-info/requires.txt
|
|
12
|
+
portable_ai.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests>=2.28
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
portable_ai
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="portable-ai",
|
|
5
|
+
version="1.0.0",
|
|
6
|
+
packages=find_packages(),
|
|
7
|
+
install_requires=["requests>=2.28"],
|
|
8
|
+
entry_points={
|
|
9
|
+
"console_scripts": [
|
|
10
|
+
"p-ai=portable_ai.cli:main",
|
|
11
|
+
],
|
|
12
|
+
},
|
|
13
|
+
author="UmairDC",
|
|
14
|
+
description="Portable AI proxy via Cloudflare Workers + Groq",
|
|
15
|
+
long_description=open("README.md").read(),
|
|
16
|
+
long_description_content_type="text/markdown",
|
|
17
|
+
python_requires=">=3.7",
|
|
18
|
+
)
|