routewise 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,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: routewise
3
+ Version: 0.1.0
4
+ Summary: Client SDK for the routewise cost-aware LLM router
5
+ Requires-Python: >=3.8
6
+ Requires-Dist: requests
7
+ Dynamic: requires-dist
8
+ Dynamic: requires-python
9
+ Dynamic: summary
@@ -0,0 +1,40 @@
1
+ # routewise (Python SDK)
2
+
3
+ Thin client for the routewise cost-aware LLM router. No routing logic lives
4
+ here -- it's a convenience wrapper around HTTP calls to the real API.
5
+
6
+ ## Install
7
+
8
+ Locally, for development:
9
+ ```bash
10
+ pip install -e ./sdk
11
+ ```
12
+
13
+ Or directly from GitHub (once pushed):
14
+ ```bash
15
+ pip install git+https://github.com/Ishan-5/llm-router.git#subdirectory=sdk
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```python
21
+ from routewise import RouteWiseClient
22
+
23
+ client = RouteWiseClient(api_key="rw_your_key_here")
24
+
25
+ result = client.ask("What is the capital of France?")
26
+ print(result["response"])
27
+ print(result["routed_to"], result["cost_usd"])
28
+
29
+ # Force a specific tier instead of letting the difficulty model decide
30
+ result = client.ask("Explain quantum computing", override_tier="frontier")
31
+
32
+ # Get aggregate usage stats
33
+ stats = client.stats()
34
+ print(stats["total_requests"], stats["cache_hit_rate"])
35
+ ```
36
+
37
+ ## Errors
38
+
39
+ All non-2xx responses raise `RouteWiseError` with the API's error detail
40
+ message, e.g. invalid key, rate limit exceeded, empty query.
@@ -0,0 +1,57 @@
1
+ """
2
+ routewise -- a thin Python client for the routewise cost-aware LLM router.
3
+
4
+ This does NOT contain any routing logic. It just wraps HTTP calls to the
5
+ real API so callers don't have to write requests.post()/headers/error
6
+ handling by hand every time.
7
+ """
8
+ import requests
9
+
10
+ DEFAULT_BASE_URL = "https://llm-router-d2b2.onrender.com"
11
+
12
+
13
+ class RouteWiseError(Exception):
14
+ """Raised when the API returns an error response."""
15
+ pass
16
+
17
+
18
+ class RouteWiseClient:
19
+ def __init__(self, api_key: str, base_url: str = DEFAULT_BASE_URL, timeout: int = 30):
20
+ self.api_key = api_key
21
+ self.base_url = base_url.rstrip("/")
22
+ self.timeout = timeout
23
+
24
+ def _headers(self) -> dict:
25
+ return {"Authorization": f"Bearer {self.api_key}"}
26
+
27
+ def ask(self, query: str, override_tier: str | None = None) -> dict:
28
+ """
29
+ Send a query through the router. Returns the full response dict
30
+ (response text, tier used, cost, latency, cache_hit, etc.)
31
+
32
+ override_tier: optionally force "cheap", "mid", or "frontier"
33
+ instead of letting the difficulty model decide.
34
+ """
35
+ payload = {"query": query}
36
+ if override_tier:
37
+ payload["override_tier"] = override_tier
38
+
39
+ response = requests.post(
40
+ f"{self.base_url}/route",
41
+ headers=self._headers(),
42
+ json=payload,
43
+ timeout=self.timeout,
44
+ )
45
+
46
+ if not response.ok:
47
+ detail = response.json().get("detail", response.text) if response.content else response.text
48
+ raise RouteWiseError(f"[{response.status_code}] {detail}")
49
+
50
+ return response.json()
51
+
52
+ def stats(self) -> dict:
53
+ """Fetch aggregate usage stats (total requests, cost saved, tier distribution, etc.)"""
54
+ response = requests.get(f"{self.base_url}/stats", timeout=self.timeout)
55
+ if not response.ok:
56
+ raise RouteWiseError(f"[{response.status_code}] {response.text}")
57
+ return response.json()
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: routewise
3
+ Version: 0.1.0
4
+ Summary: Client SDK for the routewise cost-aware LLM router
5
+ Requires-Python: >=3.8
6
+ Requires-Dist: requests
7
+ Dynamic: requires-dist
8
+ Dynamic: requires-python
9
+ Dynamic: summary
@@ -0,0 +1,8 @@
1
+ README.md
2
+ setup.py
3
+ routewise/__init__.py
4
+ routewise.egg-info/PKG-INFO
5
+ routewise.egg-info/SOURCES.txt
6
+ routewise.egg-info/dependency_links.txt
7
+ routewise.egg-info/requires.txt
8
+ routewise.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests
@@ -0,0 +1 @@
1
+ routewise
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,10 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="routewise",
5
+ version="0.1.0",
6
+ description="Client SDK for the routewise cost-aware LLM router",
7
+ packages=find_packages(),
8
+ install_requires=["requests"],
9
+ python_requires=">=3.8",
10
+ )