entroplain 0.1.0 → 0.2.0
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.
- package/26.0.1 +0 -0
- package/CONTRIBUTING.md +103 -103
- package/README.md +209 -122
- package/dist/entroplain-0.2.0-py3-none-any.whl +0 -0
- package/dist/entroplain-0.2.0.tar.gz +0 -0
- package/docs/AGENT_USAGE.md +178 -0
- package/entroplain/__init__.py +30 -30
- package/entroplain/cost_tracker.py +231 -0
- package/entroplain/dashboard.py +368 -0
- package/entroplain/monitor.py +178 -60
- package/entroplain/proxy.py +349 -0
- package/entroplain-proxy +0 -0
- package/package.json +4 -2
- package/paper.md +299 -0
- package/pip +0 -0
- package/pyproject.toml +96 -85
- package/test_nvidia.py +56 -0
- package/test_proxy.py +16 -0
- package/dist/entroplain-0.1.0-py3-none-any.whl +0 -0
- package/dist/entroplain-0.1.0.tar.gz +0 -0
package/pyproject.toml
CHANGED
|
@@ -1,85 +1,96 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "entroplain"
|
|
7
|
-
version = "0.
|
|
8
|
-
description = "Entropy-based early exit for efficient agent reasoning"
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
license = "MIT"
|
|
11
|
-
authors = [
|
|
12
|
-
{name = "Entroplain Contributors"}
|
|
13
|
-
]
|
|
14
|
-
keywords = ["llm", "agent", "entropy", "early-exit", "efficiency", "reasoning"]
|
|
15
|
-
classifiers = [
|
|
16
|
-
"Development Status :: 3 - Alpha",
|
|
17
|
-
"Intended Audience :: Developers",
|
|
18
|
-
"Intended Audience :: Science/Research",
|
|
19
|
-
"Programming Language :: Python :: 3",
|
|
20
|
-
"Programming Language :: Python :: 3.8",
|
|
21
|
-
"Programming Language :: Python :: 3.9",
|
|
22
|
-
"Programming Language :: Python :: 3.10",
|
|
23
|
-
"Programming Language :: Python :: 3.11",
|
|
24
|
-
"Programming Language :: Python :: 3.12",
|
|
25
|
-
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
26
|
-
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
27
|
-
]
|
|
28
|
-
requires-python = ">=3.8"
|
|
29
|
-
dependencies = [
|
|
30
|
-
"typing-extensions>=4.0.0;python_version<'3.10'",
|
|
31
|
-
]
|
|
32
|
-
|
|
33
|
-
[project.optional-dependencies]
|
|
34
|
-
openai = ["openai>=1.0.0"]
|
|
35
|
-
anthropic = ["anthropic>=0.25.0"]
|
|
36
|
-
google = ["google-generativeai>=0.3.0"]
|
|
37
|
-
nvidia = ["requests>=2.28.0", "aiohttp>=3.8.0"]
|
|
38
|
-
ollama = ["requests>=2.28.0", "aiohttp>=3.8.0"]
|
|
39
|
-
llama-cpp = ["llama-cpp-python>=0.2.0"]
|
|
40
|
-
all = [
|
|
41
|
-
"openai>=1.0.0",
|
|
42
|
-
"anthropic>=0.25.0",
|
|
43
|
-
"google-generativeai>=0.3.0",
|
|
44
|
-
"requests>=2.28.0",
|
|
45
|
-
"aiohttp>=3.8.0",
|
|
46
|
-
"llama-cpp-python>=0.2.0",
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
[
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
[
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "entroplain"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Entropy-based early exit for efficient agent reasoning"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "Entroplain Contributors"}
|
|
13
|
+
]
|
|
14
|
+
keywords = ["llm", "agent", "entropy", "early-exit", "efficiency", "reasoning"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Intended Audience :: Science/Research",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.8",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
26
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
27
|
+
]
|
|
28
|
+
requires-python = ">=3.8"
|
|
29
|
+
dependencies = [
|
|
30
|
+
"typing-extensions>=4.0.0;python_version<'3.10'",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
openai = ["openai>=1.0.0"]
|
|
35
|
+
anthropic = ["anthropic>=0.25.0"]
|
|
36
|
+
google = ["google-generativeai>=0.3.0"]
|
|
37
|
+
nvidia = ["requests>=2.28.0", "aiohttp>=3.8.0"]
|
|
38
|
+
ollama = ["requests>=2.28.0", "aiohttp>=3.8.0"]
|
|
39
|
+
llama-cpp = ["llama-cpp-python>=0.2.0"]
|
|
40
|
+
all = [
|
|
41
|
+
"openai>=1.0.0",
|
|
42
|
+
"anthropic>=0.25.0",
|
|
43
|
+
"google-generativeai>=0.3.0",
|
|
44
|
+
"requests>=2.28.0",
|
|
45
|
+
"aiohttp>=3.8.0",
|
|
46
|
+
"llama-cpp-python>=0.2.0",
|
|
47
|
+
"fastapi>=0.100.0",
|
|
48
|
+
"uvicorn>=0.23.0",
|
|
49
|
+
"httpx>=0.24.0",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
proxy = [
|
|
53
|
+
"fastapi>=0.100.0",
|
|
54
|
+
"uvicorn>=0.23.0",
|
|
55
|
+
"httpx>=0.24.0",
|
|
56
|
+
]
|
|
57
|
+
dev = [
|
|
58
|
+
"pytest>=7.0.0",
|
|
59
|
+
"pytest-asyncio>=0.21.0",
|
|
60
|
+
"black>=23.0.0",
|
|
61
|
+
"isort>=5.0.0",
|
|
62
|
+
"mypy>=1.0.0",
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
[project.urls]
|
|
66
|
+
Homepage = "https://github.com/entroplain/entroplain"
|
|
67
|
+
Documentation = "https://github.com/entroplain/entroplain#readme"
|
|
68
|
+
Repository = "https://github.com/entroplain/entroplain.git"
|
|
69
|
+
Issues = "https://github.com/entroplain/entroplain/issues"
|
|
70
|
+
|
|
71
|
+
[project.scripts]
|
|
72
|
+
entroplain = "entroplain.cli:main"
|
|
73
|
+
entroplain-proxy = "entroplain.proxy:main"
|
|
74
|
+
entroplain-dashboard = "entroplain.dashboard:main"
|
|
75
|
+
|
|
76
|
+
[tool.setuptools.packages.find]
|
|
77
|
+
where = ["."]
|
|
78
|
+
include = ["entroplain*"]
|
|
79
|
+
|
|
80
|
+
[tool.black]
|
|
81
|
+
line-length = 100
|
|
82
|
+
target-version = ["py38", "py39", "py310", "py311", "py312"]
|
|
83
|
+
|
|
84
|
+
[tool.isort]
|
|
85
|
+
profile = "black"
|
|
86
|
+
line_length = 100
|
|
87
|
+
|
|
88
|
+
[tool.mypy]
|
|
89
|
+
python_version = "3.8"
|
|
90
|
+
warn_return_any = true
|
|
91
|
+
warn_unused_configs = true
|
|
92
|
+
disallow_untyped_defs = true
|
|
93
|
+
|
|
94
|
+
[tool.pytest.ini_options]
|
|
95
|
+
asyncio_mode = "auto"
|
|
96
|
+
testpaths = ["tests"]
|
package/test_nvidia.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""Test the proxy with NVIDIA API."""
|
|
2
|
+
|
|
3
|
+
import requests
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
# Get API key from environment
|
|
8
|
+
api_key = os.environ.get("NVIDIA_API_KEY", "")
|
|
9
|
+
|
|
10
|
+
if not api_key:
|
|
11
|
+
print("ERROR: NVIDIA_API_KEY not set")
|
|
12
|
+
exit(1)
|
|
13
|
+
|
|
14
|
+
# Make request through proxy
|
|
15
|
+
response = requests.post(
|
|
16
|
+
"http://localhost:8767/v1/chat/completions",
|
|
17
|
+
headers={
|
|
18
|
+
"Content-Type": "application/json",
|
|
19
|
+
"Authorization": f"Bearer {api_key}"
|
|
20
|
+
},
|
|
21
|
+
json={
|
|
22
|
+
"model": "meta/llama-3.1-70b-instruct",
|
|
23
|
+
"messages": [{"role": "user", "content": "What is 2+2? Just answer the number."}],
|
|
24
|
+
"max_tokens": 50,
|
|
25
|
+
"temperature": 0.1,
|
|
26
|
+
"stream": True
|
|
27
|
+
},
|
|
28
|
+
stream=True
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
print(f"Status: {response.status_code}")
|
|
32
|
+
print("Streaming response:")
|
|
33
|
+
print("-" * 40)
|
|
34
|
+
|
|
35
|
+
for line in response.iter_lines():
|
|
36
|
+
if line:
|
|
37
|
+
line = line.decode('utf-8')
|
|
38
|
+
if line.startswith("data: "):
|
|
39
|
+
data = line[6:]
|
|
40
|
+
if data == "[DONE]":
|
|
41
|
+
print("\n[DONE]")
|
|
42
|
+
break
|
|
43
|
+
try:
|
|
44
|
+
chunk = json.loads(data)
|
|
45
|
+
if chunk.get("choices"):
|
|
46
|
+
delta = chunk["choices"][0].get("delta", {})
|
|
47
|
+
if delta.get("content"):
|
|
48
|
+
print(delta["content"], end="", flush=True)
|
|
49
|
+
except json.JSONDecodeError:
|
|
50
|
+
pass
|
|
51
|
+
|
|
52
|
+
print("\n" + "-" * 40)
|
|
53
|
+
|
|
54
|
+
# Check proxy health
|
|
55
|
+
health = requests.get("http://localhost:8767/health")
|
|
56
|
+
print(f"\nProxy stats: {health.json()}")
|
package/test_proxy.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Test the proxy with a real API call."""
|
|
2
|
+
|
|
3
|
+
import requests
|
|
4
|
+
import json
|
|
5
|
+
|
|
6
|
+
# Test health endpoint
|
|
7
|
+
try:
|
|
8
|
+
response = requests.get("http://localhost:8765/health")
|
|
9
|
+
print(f"Health check: {response.status_code}")
|
|
10
|
+
print(response.json())
|
|
11
|
+
except Exception as e:
|
|
12
|
+
print(f"Proxy not running: {e}")
|
|
13
|
+
print("\nTo test the proxy, run:")
|
|
14
|
+
print(" entroplain-proxy --port 8765")
|
|
15
|
+
print("\nThen in another terminal:")
|
|
16
|
+
print(" python test_proxy.py")
|
|
Binary file
|
|
Binary file
|