llm-inspect 0.1.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.
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: llm-inspect
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Zero-config LLM API inspector — intercepts calls, shows token breakdown and cost estimates in a local dashboard
|
|
5
|
+
Project-URL: Homepage, https://github.com/kasidkhan/llm-inspect
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: anthropic,cost,debugging,inspector,llm,openai,tokens
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# llm-inspect
|
|
16
|
+
|
|
17
|
+
Zero-config LLM API inspector. One import, one line — intercepts all Anthropic and OpenAI calls and shows a real-time dashboard with token breakdown and cost estimates.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install llm-inspect
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
import llm_inspect
|
|
29
|
+
llm_inspect.init() # add at your app entry point, before other imports
|
|
30
|
+
|
|
31
|
+
# All LLM calls now route through the inspector
|
|
32
|
+
import anthropic
|
|
33
|
+
client = anthropic.Anthropic()
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Dashboard opens automatically at **http://localhost:8788**
|
|
37
|
+
|
|
38
|
+
## How it works
|
|
39
|
+
|
|
40
|
+
`init()` starts a lightweight local proxy on `:8787` (if not already running) and sets `ANTHROPIC_BASE_URL` / `OPENAI_BASE_URL` so all SDK calls route through it. No config files, no CA certificates, no accounts.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# llm-inspect
|
|
2
|
+
|
|
3
|
+
Zero-config LLM API inspector. One import, one line — intercepts all Anthropic and OpenAI calls and shows a real-time dashboard with token breakdown and cost estimates.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install llm-inspect
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
import llm_inspect
|
|
15
|
+
llm_inspect.init() # add at your app entry point, before other imports
|
|
16
|
+
|
|
17
|
+
# All LLM calls now route through the inspector
|
|
18
|
+
import anthropic
|
|
19
|
+
client = anthropic.Anthropic()
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Dashboard opens automatically at **http://localhost:8788**
|
|
23
|
+
|
|
24
|
+
## How it works
|
|
25
|
+
|
|
26
|
+
`init()` starts a lightweight local proxy on `:8787` (if not already running) and sets `ANTHROPIC_BASE_URL` / `OPENAI_BASE_URL` so all SDK calls route through it. No config files, no CA certificates, no accounts.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import subprocess
|
|
3
|
+
import sys
|
|
4
|
+
import time
|
|
5
|
+
import urllib.request
|
|
6
|
+
import urllib.error
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
PROXY_PORT = 8787
|
|
10
|
+
_PROXY_JS = Path(__file__).parent.parent.parent.parent / "proxy" / "proxy.js"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _is_proxy_running() -> bool:
|
|
14
|
+
try:
|
|
15
|
+
with urllib.request.urlopen(f"http://localhost:{PROXY_PORT}/health", timeout=0.5):
|
|
16
|
+
return True
|
|
17
|
+
except Exception:
|
|
18
|
+
return False
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def init() -> None:
|
|
22
|
+
if not _is_proxy_running():
|
|
23
|
+
node = _find_node()
|
|
24
|
+
subprocess.Popen(
|
|
25
|
+
[node, str(_PROXY_JS)],
|
|
26
|
+
stdout=subprocess.DEVNULL,
|
|
27
|
+
stderr=subprocess.DEVNULL,
|
|
28
|
+
start_new_session=True,
|
|
29
|
+
)
|
|
30
|
+
time.sleep(0.5)
|
|
31
|
+
|
|
32
|
+
os.environ["ANTHROPIC_BASE_URL"] = f"http://localhost:{PROXY_PORT}"
|
|
33
|
+
os.environ["OPENAI_BASE_URL"] = f"http://localhost:{PROXY_PORT}/openai"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _find_node() -> str:
|
|
37
|
+
import shutil
|
|
38
|
+
node = shutil.which("node")
|
|
39
|
+
if node is None:
|
|
40
|
+
raise RuntimeError("Node.js not found. Install it from https://nodejs.org")
|
|
41
|
+
return node
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "llm-inspect"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Zero-config LLM API inspector — intercepts calls, shows token breakdown and cost estimates in a local dashboard"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.8"
|
|
12
|
+
keywords = ["llm", "openai", "anthropic", "debugging", "tokens", "cost", "inspector"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Homepage = "https://github.com/kasidkhan/llm-inspect"
|