llm-proxy-cli 0.5.3__tar.gz → 0.5.5__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.
- {llm_proxy_cli-0.5.3 → llm_proxy_cli-0.5.5}/PKG-INFO +118 -117
- {llm_proxy_cli-0.5.3 → llm_proxy_cli-0.5.5}/README.md +101 -101
- {llm_proxy_cli-0.5.3 → llm_proxy_cli-0.5.5}/llm_proxy_cli.egg-info/PKG-INFO +118 -117
- {llm_proxy_cli-0.5.3 → llm_proxy_cli-0.5.5}/llm_proxy_cli.egg-info/requires.txt +1 -0
- {llm_proxy_cli-0.5.3 → llm_proxy_cli-0.5.5}/llm_proxy_cli.py +530 -526
- {llm_proxy_cli-0.5.3 → llm_proxy_cli-0.5.5}/pyproject.toml +29 -28
- {llm_proxy_cli-0.5.3 → llm_proxy_cli-0.5.5}/setup.cfg +4 -4
- {llm_proxy_cli-0.5.3 → llm_proxy_cli-0.5.5}/tests/test_circuit.py +91 -91
- {llm_proxy_cli-0.5.3 → llm_proxy_cli-0.5.5}/tests/test_discovery.py +61 -61
- {llm_proxy_cli-0.5.3 → llm_proxy_cli-0.5.5}/tests/test_query_ai.py +234 -234
- {llm_proxy_cli-0.5.3 → llm_proxy_cli-0.5.5}/LICENSE +0 -0
- {llm_proxy_cli-0.5.3 → llm_proxy_cli-0.5.5}/llm_proxy_cli.egg-info/SOURCES.txt +0 -0
- {llm_proxy_cli-0.5.3 → llm_proxy_cli-0.5.5}/llm_proxy_cli.egg-info/dependency_links.txt +0 -0
- {llm_proxy_cli-0.5.3 → llm_proxy_cli-0.5.5}/llm_proxy_cli.egg-info/entry_points.txt +0 -0
- {llm_proxy_cli-0.5.3 → llm_proxy_cli-0.5.5}/llm_proxy_cli.egg-info/top_level.txt +0 -0
|
@@ -1,117 +1,118 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: llm-proxy-cli
|
|
3
|
-
Version: 0.5.
|
|
4
|
-
Summary: A lightweight CLI tool for delegating LLM tasks to expert models across multiple providers.
|
|
5
|
-
Author-email: Kerem Barbaros Karnabat <kbarbaros@hotmail.com>
|
|
6
|
-
Classifier: Programming Language :: Python :: 3
|
|
7
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
-
Classifier: Operating System :: OS Independent
|
|
9
|
-
Requires-Python: >=3.8
|
|
10
|
-
Description-Content-Type: text/markdown
|
|
11
|
-
License-File: LICENSE
|
|
12
|
-
Requires-Dist:
|
|
13
|
-
Requires-Dist:
|
|
14
|
-
Requires-Dist:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-

|
|
21
|
+

|
|
22
|
+

|
|
23
|
+
|
|
24
|
+
> A lightweight, fault-tolerant CLI tool for delegating LLM tasks to expert models across multiple providers (Nvidia NIM, Groq, OpenAI, Anthropic Claude, Gemini).
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## ⚡ Features
|
|
28
|
+
- **Multi-Provider Support**: Seamlessly route requests to `nvidia`, `groq`, `openai`, `anthropic`, or `gemini`.
|
|
29
|
+
- **Dynamic Model Discovery**: Never hardcode a model name again. Use `auto-smart` or `auto-fast` and the router will auto-select the best model.
|
|
30
|
+
- **Active Liveness Verification**: Pings candidates with a minimal chat request to drop fake/gated models before they crash your task.
|
|
31
|
+
- **Automatic Fallbacks**: Provide a comma-separated list of models. If one fails, it instantly falls back to the next.
|
|
32
|
+
- **Circuit Breaker**: Built-in health tracking and cooldowns to prevent spamming dead endpoints.
|
|
33
|
+
- **Reasoning Extraction**: Automatically extracts `reasoning_content` from natively supported models (e.g., DeepSeek-R1 or Nemotron) and outputs them to stderr.
|
|
34
|
+
- **Streaming Native**: Built on the official OpenAI SDK for fast and reliable streaming chunks.
|
|
35
|
+
|
|
36
|
+
## 🏗️ Architecture & Under the Hood
|
|
37
|
+
- **Language**: Python 3
|
|
38
|
+
- **Libraries**: openai, filelock, anthropic
|
|
39
|
+
- **Design Pattern**: Circuit Breaker, Chain of Responsibility (Fallback Routing), and Dynamic Caching.
|
|
40
|
+
|
|
41
|
+
The router uses a `FileLock`-backed JSON state (`circuit_breaker.json`) to track failures across concurrent runs.
|
|
42
|
+
If an endpoint times out or returns a 5xx error more than `MAX_FAILURES` times, the circuit trips and forces the router to skip that endpoint for the next 120 seconds, immediately trying the next fallback model.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## 📦 Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Install via pip
|
|
49
|
+
pip install llm-proxy-cli
|
|
50
|
+
|
|
51
|
+
# Or for local development:
|
|
52
|
+
# git clone https://github.com/cadakerem/llm-proxy-cli.git
|
|
53
|
+
# cd llm-proxy-cli
|
|
54
|
+
# pip install -e .
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 🔑 Configuration & API Keys
|
|
58
|
+
|
|
59
|
+
The router looks for API keys in your environment variables or in ~/.config/llm-proxy-cli/keys.json.
|
|
60
|
+
|
|
61
|
+
Supported environment variables:
|
|
62
|
+
- NVIDIA_API_KEY
|
|
63
|
+
- GROQ_API_KEY
|
|
64
|
+
- OPENAI_API_KEY
|
|
65
|
+
- ANTHROPIC_API_KEY
|
|
66
|
+
- GEMINI_API_KEY
|
|
67
|
+
|
|
68
|
+
## 💻 Usage
|
|
69
|
+
|
|
70
|
+
The tool is designed to **automatically** discover and use the best model without you having to memorize model names (using `auto-smart` and `auto-fast`).
|
|
71
|
+
|
|
72
|
+
### 1. Automatic Model Selection (Recommended)
|
|
73
|
+
Instead of guessing which model is currently the best or active on the API, simply use `auto-smart` (for complex coding/reasoning tasks) or `auto-fast` (for quick tasks).
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Auto-select the smartest model on Nvidia (e.g., Nemotron or Llama 3.1 405B)
|
|
77
|
+
llm-proxy-cli -m "nvidia:auto-smart" -p "Write a React button."
|
|
78
|
+
|
|
79
|
+
# Auto-select the fastest model on Groq
|
|
80
|
+
llm-proxy-cli -m "groq:auto-fast" -p "Summarize this text."
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 2. Chained Automatic Fallback
|
|
84
|
+
If Nvidia goes down or hits a rate limit, you can instantly fall back to Groq's best model by separating them with a comma:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
llm-proxy-cli -m "nvidia:auto-smart,groq:auto-smart" -p "Refactor this python script."
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 3. Specific / Manual Model Selection
|
|
91
|
+
If you have a specific model you want to use, you can still hardcode it directly:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Use Laguna, and fallback to a specific Groq model if it fails
|
|
95
|
+
llm-proxy-cli -m "nvidia:poolside/laguna-xs-2.1,groq:groq/compound" -p "Explain quantum entanglement."
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### ⚠️ Troubleshooting & Known Quirks: Nvidia EULA (404 Not Found)
|
|
99
|
+
Nvidia NIM requires users to manually accept the **End User License Agreement (EULA)** for certain models on their website before using them via API. If you haven't accepted the EULA for a dynamically discovered model, Nvidia returns a cryptic `404 Not Found` error.
|
|
100
|
+
The Smart Router intercepts this behavior automatically and will print a clear warning.
|
|
101
|
+
|
|
102
|
+
**How to Fix:**
|
|
103
|
+
1. Log into the [Nvidia Build Portal](https://build.nvidia.com).
|
|
104
|
+
2. Search for the exact model name shown in the warning and click to run a quick test prompt to accept the terms.
|
|
105
|
+
3. Or bypass auto-discovery completely by explicitly hardcoding a model:
|
|
106
|
+
```bash
|
|
107
|
+
llm-proxy-cli -m "nvidia:meta/llama-3.2-11b-vision-instruct" -p "Hello"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## 🧑💻 Developer & Contributions
|
|
111
|
+
Developed by Kerem Barbaros Karnabat ([@cadakerem](https://github.com/cadakerem)).
|
|
112
|
+
|
|
113
|
+
> **Note on Repository Structure:** The core routing logic, dynamic model discovery, and circuit breaker patterns are entirely contained within `llm_proxy_cli.py` to ensure maximum portability. Unit tests are located in the `tests/` directory, and `SKILL.md` provides instructions for integrating this tool as a native AI agent skill.
|
|
114
|
+
|
|
115
|
+
Contributions, issues, and feature requests are welcome! Feel free to check the [Issues page](../../issues).
|
|
116
|
+
|
|
117
|
+
## 📜 License
|
|
118
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
# LLM Proxy CLI
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-

|
|
6
|
-
|
|
7
|
-
> A lightweight, fault-tolerant CLI tool for delegating LLM tasks to expert models across multiple providers (Nvidia NIM, Groq, OpenAI, Anthropic Claude, Gemini).
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
## ⚡ Features
|
|
11
|
-
- **Multi-Provider Support**: Seamlessly route requests to `nvidia`, `groq`, `openai`, `anthropic`, or `gemini`.
|
|
12
|
-
- **Dynamic Model Discovery**: Never hardcode a model name again. Use `auto-smart` or `auto-fast` and the router will auto-select the best model.
|
|
13
|
-
- **Active Liveness Verification**: Pings candidates with a minimal chat request to drop fake/gated models before they crash your task.
|
|
14
|
-
- **Automatic Fallbacks**: Provide a comma-separated list of models. If one fails, it instantly falls back to the next.
|
|
15
|
-
- **Circuit Breaker**: Built-in health tracking and cooldowns to prevent spamming dead endpoints.
|
|
16
|
-
- **Reasoning Extraction**: Automatically extracts `reasoning_content` from natively supported models (e.g., DeepSeek-R1 or Nemotron) and outputs them to stderr.
|
|
17
|
-
- **Streaming Native**: Built on the official OpenAI SDK for fast and reliable streaming chunks.
|
|
18
|
-
|
|
19
|
-
## 🏗️ Architecture & Under the Hood
|
|
20
|
-
- **Language**: Python 3
|
|
21
|
-
- **Libraries**: openai, filelock, anthropic
|
|
22
|
-
- **Design Pattern**: Circuit Breaker, Chain of Responsibility (Fallback Routing), and Dynamic Caching.
|
|
23
|
-
|
|
24
|
-
The router uses a `FileLock`-backed JSON state (`circuit_breaker.json`) to track failures across concurrent runs.
|
|
25
|
-
If an endpoint times out or returns a 5xx error more than `MAX_FAILURES` times, the circuit trips and forces the router to skip that endpoint for the next 120 seconds, immediately trying the next fallback model.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
## 📦 Installation
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
# Install via pip
|
|
32
|
-
pip install llm-proxy-cli
|
|
33
|
-
|
|
34
|
-
# Or for local development:
|
|
35
|
-
# git clone https://github.com/cadakerem/llm-proxy-cli.git
|
|
36
|
-
# cd llm-proxy-cli
|
|
37
|
-
# pip install -e .
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## 🔑 Configuration & API Keys
|
|
41
|
-
|
|
42
|
-
The router looks for API keys in your environment variables or in ~/.config/llm-proxy-cli/keys.json.
|
|
43
|
-
|
|
44
|
-
Supported environment variables:
|
|
45
|
-
- NVIDIA_API_KEY
|
|
46
|
-
- GROQ_API_KEY
|
|
47
|
-
- OPENAI_API_KEY
|
|
48
|
-
- ANTHROPIC_API_KEY
|
|
49
|
-
- GEMINI_API_KEY
|
|
50
|
-
|
|
51
|
-
## 💻 Usage
|
|
52
|
-
|
|
53
|
-
The tool is designed to **automatically** discover and use the best model without you having to memorize model names (using `auto-smart` and `auto-fast`).
|
|
54
|
-
|
|
55
|
-
### 1. Automatic Model Selection (Recommended)
|
|
56
|
-
Instead of guessing which model is currently the best or active on the API, simply use `auto-smart` (for complex coding/reasoning tasks) or `auto-fast` (for quick tasks).
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
# Auto-select the smartest model on Nvidia (e.g., Nemotron or Llama 3.1 405B)
|
|
60
|
-
llm-proxy-cli -m "nvidia:auto-smart" -p "Write a React button."
|
|
61
|
-
|
|
62
|
-
# Auto-select the fastest model on Groq
|
|
63
|
-
llm-proxy-cli -m "groq:auto-fast" -p "Summarize this text."
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### 2. Chained Automatic Fallback
|
|
67
|
-
If Nvidia goes down or hits a rate limit, you can instantly fall back to Groq's best model by separating them with a comma:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
llm-proxy-cli -m "nvidia:auto-smart,groq:auto-smart" -p "Refactor this python script."
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### 3. Specific / Manual Model Selection
|
|
74
|
-
If you have a specific model you want to use, you can still hardcode it directly:
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
# Use Laguna, and fallback to a specific Groq model if it fails
|
|
78
|
-
llm-proxy-cli -m "nvidia:poolside/laguna-xs-2.1,groq:groq/compound" -p "Explain quantum entanglement."
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### ⚠️ Troubleshooting & Known Quirks: Nvidia EULA (404 Not Found)
|
|
82
|
-
Nvidia NIM requires users to manually accept the **End User License Agreement (EULA)** for certain models on their website before using them via API. If you haven't accepted the EULA for a dynamically discovered model, Nvidia returns a cryptic `404 Not Found` error.
|
|
83
|
-
The Smart Router intercepts this behavior automatically and will print a clear warning.
|
|
84
|
-
|
|
85
|
-
**How to Fix:**
|
|
86
|
-
1. Log into the [Nvidia Build Portal](https://build.nvidia.com).
|
|
87
|
-
2. Search for the exact model name shown in the warning and click to run a quick test prompt to accept the terms.
|
|
88
|
-
3. Or bypass auto-discovery completely by explicitly hardcoding a model:
|
|
89
|
-
```bash
|
|
90
|
-
llm-proxy-cli -m "nvidia:meta/llama-3.2-11b-vision-instruct" -p "Hello"
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## 🧑💻 Developer & Contributions
|
|
94
|
-
Developed by Kerem Barbaros Karnabat ([@cadakerem](https://github.com/cadakerem)).
|
|
95
|
-
|
|
96
|
-
> **Note on Repository Structure:** The core routing logic, dynamic model discovery, and circuit breaker patterns are entirely contained within `llm_proxy_cli.py` to ensure maximum portability. Unit tests are located in the `tests/` directory, and `SKILL.md` provides instructions for integrating this tool as a native AI agent skill.
|
|
97
|
-
|
|
98
|
-
Contributions, issues, and feature requests are welcome! Feel free to check the [Issues page](../../issues).
|
|
99
|
-
|
|
100
|
-
## 📜 License
|
|
101
|
-
This project is licensed under the [MIT License](LICENSE).
|
|
1
|
+
# LLM Proxy CLI
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
> A lightweight, fault-tolerant CLI tool for delegating LLM tasks to expert models across multiple providers (Nvidia NIM, Groq, OpenAI, Anthropic Claude, Gemini).
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## ⚡ Features
|
|
11
|
+
- **Multi-Provider Support**: Seamlessly route requests to `nvidia`, `groq`, `openai`, `anthropic`, or `gemini`.
|
|
12
|
+
- **Dynamic Model Discovery**: Never hardcode a model name again. Use `auto-smart` or `auto-fast` and the router will auto-select the best model.
|
|
13
|
+
- **Active Liveness Verification**: Pings candidates with a minimal chat request to drop fake/gated models before they crash your task.
|
|
14
|
+
- **Automatic Fallbacks**: Provide a comma-separated list of models. If one fails, it instantly falls back to the next.
|
|
15
|
+
- **Circuit Breaker**: Built-in health tracking and cooldowns to prevent spamming dead endpoints.
|
|
16
|
+
- **Reasoning Extraction**: Automatically extracts `reasoning_content` from natively supported models (e.g., DeepSeek-R1 or Nemotron) and outputs them to stderr.
|
|
17
|
+
- **Streaming Native**: Built on the official OpenAI SDK for fast and reliable streaming chunks.
|
|
18
|
+
|
|
19
|
+
## 🏗️ Architecture & Under the Hood
|
|
20
|
+
- **Language**: Python 3
|
|
21
|
+
- **Libraries**: openai, filelock, anthropic
|
|
22
|
+
- **Design Pattern**: Circuit Breaker, Chain of Responsibility (Fallback Routing), and Dynamic Caching.
|
|
23
|
+
|
|
24
|
+
The router uses a `FileLock`-backed JSON state (`circuit_breaker.json`) to track failures across concurrent runs.
|
|
25
|
+
If an endpoint times out or returns a 5xx error more than `MAX_FAILURES` times, the circuit trips and forces the router to skip that endpoint for the next 120 seconds, immediately trying the next fallback model.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## 📦 Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Install via pip
|
|
32
|
+
pip install llm-proxy-cli
|
|
33
|
+
|
|
34
|
+
# Or for local development:
|
|
35
|
+
# git clone https://github.com/cadakerem/llm-proxy-cli.git
|
|
36
|
+
# cd llm-proxy-cli
|
|
37
|
+
# pip install -e .
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 🔑 Configuration & API Keys
|
|
41
|
+
|
|
42
|
+
The router looks for API keys in your environment variables or in ~/.config/llm-proxy-cli/keys.json.
|
|
43
|
+
|
|
44
|
+
Supported environment variables:
|
|
45
|
+
- NVIDIA_API_KEY
|
|
46
|
+
- GROQ_API_KEY
|
|
47
|
+
- OPENAI_API_KEY
|
|
48
|
+
- ANTHROPIC_API_KEY
|
|
49
|
+
- GEMINI_API_KEY
|
|
50
|
+
|
|
51
|
+
## 💻 Usage
|
|
52
|
+
|
|
53
|
+
The tool is designed to **automatically** discover and use the best model without you having to memorize model names (using `auto-smart` and `auto-fast`).
|
|
54
|
+
|
|
55
|
+
### 1. Automatic Model Selection (Recommended)
|
|
56
|
+
Instead of guessing which model is currently the best or active on the API, simply use `auto-smart` (for complex coding/reasoning tasks) or `auto-fast` (for quick tasks).
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Auto-select the smartest model on Nvidia (e.g., Nemotron or Llama 3.1 405B)
|
|
60
|
+
llm-proxy-cli -m "nvidia:auto-smart" -p "Write a React button."
|
|
61
|
+
|
|
62
|
+
# Auto-select the fastest model on Groq
|
|
63
|
+
llm-proxy-cli -m "groq:auto-fast" -p "Summarize this text."
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 2. Chained Automatic Fallback
|
|
67
|
+
If Nvidia goes down or hits a rate limit, you can instantly fall back to Groq's best model by separating them with a comma:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
llm-proxy-cli -m "nvidia:auto-smart,groq:auto-smart" -p "Refactor this python script."
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 3. Specific / Manual Model Selection
|
|
74
|
+
If you have a specific model you want to use, you can still hardcode it directly:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Use Laguna, and fallback to a specific Groq model if it fails
|
|
78
|
+
llm-proxy-cli -m "nvidia:poolside/laguna-xs-2.1,groq:groq/compound" -p "Explain quantum entanglement."
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### ⚠️ Troubleshooting & Known Quirks: Nvidia EULA (404 Not Found)
|
|
82
|
+
Nvidia NIM requires users to manually accept the **End User License Agreement (EULA)** for certain models on their website before using them via API. If you haven't accepted the EULA for a dynamically discovered model, Nvidia returns a cryptic `404 Not Found` error.
|
|
83
|
+
The Smart Router intercepts this behavior automatically and will print a clear warning.
|
|
84
|
+
|
|
85
|
+
**How to Fix:**
|
|
86
|
+
1. Log into the [Nvidia Build Portal](https://build.nvidia.com).
|
|
87
|
+
2. Search for the exact model name shown in the warning and click to run a quick test prompt to accept the terms.
|
|
88
|
+
3. Or bypass auto-discovery completely by explicitly hardcoding a model:
|
|
89
|
+
```bash
|
|
90
|
+
llm-proxy-cli -m "nvidia:meta/llama-3.2-11b-vision-instruct" -p "Hello"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## 🧑💻 Developer & Contributions
|
|
94
|
+
Developed by Kerem Barbaros Karnabat ([@cadakerem](https://github.com/cadakerem)).
|
|
95
|
+
|
|
96
|
+
> **Note on Repository Structure:** The core routing logic, dynamic model discovery, and circuit breaker patterns are entirely contained within `llm_proxy_cli.py` to ensure maximum portability. Unit tests are located in the `tests/` directory, and `SKILL.md` provides instructions for integrating this tool as a native AI agent skill.
|
|
97
|
+
|
|
98
|
+
Contributions, issues, and feature requests are welcome! Feel free to check the [Issues page](../../issues).
|
|
99
|
+
|
|
100
|
+
## 📜 License
|
|
101
|
+
This project is licensed under the [MIT License](LICENSE).
|