code-puppy 0.0.143__py3-none-any.whl → 0.0.144__py3-none-any.whl
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.
- code_puppy/round_robin_model.py +14 -1
- {code_puppy-0.0.143.dist-info → code_puppy-0.0.144.dist-info}/METADATA +63 -1
- {code_puppy-0.0.143.dist-info → code_puppy-0.0.144.dist-info}/RECORD +7 -7
- {code_puppy-0.0.143.data → code_puppy-0.0.144.data}/data/code_puppy/models.json +0 -0
- {code_puppy-0.0.143.dist-info → code_puppy-0.0.144.dist-info}/WHEEL +0 -0
- {code_puppy-0.0.143.dist-info → code_puppy-0.0.144.dist-info}/entry_points.txt +0 -0
- {code_puppy-0.0.143.dist-info → code_puppy-0.0.144.dist-info}/licenses/LICENSE +0 -0
code_puppy/round_robin_model.py
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
+
from contextlib import asynccontextmanager, suppress
|
|
1
2
|
from dataclasses import dataclass, field
|
|
2
3
|
from typing import Any, Callable, AsyncIterator, List
|
|
3
|
-
|
|
4
|
+
|
|
4
5
|
from pydantic_ai.models import Model, ModelMessage, ModelSettings, ModelRequestParameters, ModelResponse, StreamedResponse
|
|
5
6
|
from pydantic_ai.models.fallback import KnownModelName, infer_model, merge_model_settings
|
|
6
7
|
from pydantic_ai.result import RunContext
|
|
7
8
|
|
|
9
|
+
try:
|
|
10
|
+
from opentelemetry.context import get_current_span
|
|
11
|
+
except ImportError:
|
|
12
|
+
# If opentelemetry is not installed, provide a dummy implementation
|
|
13
|
+
def get_current_span():
|
|
14
|
+
class DummySpan:
|
|
15
|
+
def is_recording(self):
|
|
16
|
+
return False
|
|
17
|
+
def set_attributes(self, attributes):
|
|
18
|
+
pass
|
|
19
|
+
return DummySpan()
|
|
20
|
+
|
|
8
21
|
@dataclass(init=False)
|
|
9
22
|
class RoundRobinModel(Model):
|
|
10
23
|
"""A model that cycles through multiple models in a round-robin fashion.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: code-puppy
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.144
|
|
4
4
|
Summary: Code generation agent
|
|
5
5
|
Project-URL: repository, https://github.com/mpfaffenberger/code_puppy
|
|
6
6
|
Project-URL: HomePage, https://github.com/mpfaffenberger/code_puppy
|
|
@@ -189,6 +189,68 @@ If you need to run more exotic setups or connect to remote MCPs, just update you
|
|
|
189
189
|
|
|
190
190
|
---
|
|
191
191
|
|
|
192
|
+
## Round Robin Model Distribution
|
|
193
|
+
|
|
194
|
+
Code Puppy supports **Round Robin model distribution** to help you overcome rate limits and distribute load across multiple AI models. This feature automatically cycles through configured models with each request, maximizing your API usage while staying within rate limits.
|
|
195
|
+
|
|
196
|
+
### Configuration
|
|
197
|
+
Add a round-robin model configuration to your `extra_models.json` file:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
export CEREBRAS_API_KEY1=csk-...
|
|
201
|
+
export CEREBRAS_API_KEY2=csk-...
|
|
202
|
+
export CEREBRAS_API_KEY3=csk-...
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
```json
|
|
207
|
+
{
|
|
208
|
+
"qwen1": {
|
|
209
|
+
"type": "cerebras",
|
|
210
|
+
"name": "qwen-3-coder-480b",
|
|
211
|
+
"custom_endpoint": {
|
|
212
|
+
"url": "https://api.cerebras.ai/v1",
|
|
213
|
+
"api_key": "$CEREBRAS_API_KEY1"
|
|
214
|
+
},
|
|
215
|
+
"context_length": 131072
|
|
216
|
+
},
|
|
217
|
+
"qwen2": {
|
|
218
|
+
"type": "cerebras",
|
|
219
|
+
"name": "qwen-3-coder-480b",
|
|
220
|
+
"custom_endpoint": {
|
|
221
|
+
"url": "https://api.cerebras.ai/v1",
|
|
222
|
+
"api_key": "$CEREBRAS_API_KEY2"
|
|
223
|
+
},
|
|
224
|
+
"context_length": 131072
|
|
225
|
+
},
|
|
226
|
+
"qwen3": {
|
|
227
|
+
"type": "cerebras",
|
|
228
|
+
"name": "qwen-3-coder-480b",
|
|
229
|
+
"custom_endpoint": {
|
|
230
|
+
"url": "https://api.cerebras.ai/v1",
|
|
231
|
+
"api_key": "$CEREBRAS_API_KEY3"
|
|
232
|
+
},
|
|
233
|
+
"context_length": 131072
|
|
234
|
+
},
|
|
235
|
+
"cerebras_round_robin": {
|
|
236
|
+
"type": "round_robin",
|
|
237
|
+
"models": ["qwen1", "qwen2", "qwen3"]
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Then just use /model and tab to select your round-robin model!
|
|
243
|
+
|
|
244
|
+
### Benefits
|
|
245
|
+
- **Rate Limit Protection**: Automatically distribute requests across multiple models
|
|
246
|
+
- **Load Balancing**: Share workload between different model providers
|
|
247
|
+
- **Fallback Resilience**: Continue working even if one model has temporary issues
|
|
248
|
+
- **Cost Optimization**: Use different models for different types of tasks
|
|
249
|
+
|
|
250
|
+
**NOTE:** Unlike fallback models, round-robin models distribute load but don't automatically retry with another model on failure. If a request fails, it will raise the exception directly.
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
192
254
|
## Create your own Agent!!!
|
|
193
255
|
|
|
194
256
|
Code Puppy features a flexible agent system that allows you to work with specialized AI assistants tailored for different coding tasks. The system supports both built-in Python agents and custom JSON agents that you can create yourself.
|
|
@@ -9,7 +9,7 @@ code_puppy/message_history_processor.py,sha256=O2rKp7W6YeIg93W8b0XySTUEQgIZm0f_0
|
|
|
9
9
|
code_puppy/model_factory.py,sha256=kTVaHNm6S1cLw6vHE6kH0WS6JZLRoZ8qFGKCp_fdDM4,11756
|
|
10
10
|
code_puppy/models.json,sha256=dAfpMMI2EEeOMv0ynHSmMuJAYDLcZrs5gCLX3voC4-A,3252
|
|
11
11
|
code_puppy/reopenable_async_client.py,sha256=4UJRaMp5np8cbef9F0zKQ7TPKOfyf5U-Kv-0zYUWDho,8274
|
|
12
|
-
code_puppy/round_robin_model.py,sha256=
|
|
12
|
+
code_puppy/round_robin_model.py,sha256=DmbO1_SIWevdhb9nN1eNVh0dNIF-XzLYX-9gra5xVsY,4670
|
|
13
13
|
code_puppy/state_management.py,sha256=o4mNBCPblRyVrNBH-992-1YqffgH6AKHU7iZRqgP1LI,5925
|
|
14
14
|
code_puppy/status_display.py,sha256=F6eEAkGePDp4StM2BWj-uLLQTDGtJrf0IufzCeP1rRg,8336
|
|
15
15
|
code_puppy/summarization_agent.py,sha256=-e6yUGZ22ahSaF0y7QhgVcQBfx5ktNUkPxBIWQfPaA4,3275
|
|
@@ -126,9 +126,9 @@ code_puppy/tui/tests/test_sidebar_history_navigation.py,sha256=JGiyua8A2B8dLfwiE
|
|
|
126
126
|
code_puppy/tui/tests/test_status_bar.py,sha256=nYT_FZGdmqnnbn6o0ZuOkLtNUtJzLSmtX8P72liQ5Vo,1797
|
|
127
127
|
code_puppy/tui/tests/test_timestamped_history.py,sha256=nVXt9hExZZ_8MFP-AZj4L4bB_1Eo_mc-ZhVICzTuw3I,1799
|
|
128
128
|
code_puppy/tui/tests/test_tools.py,sha256=kgzzAkK4r0DPzQwHHD4cePpVNgrHor6cFr05Pg6DBWg,2687
|
|
129
|
-
code_puppy-0.0.
|
|
130
|
-
code_puppy-0.0.
|
|
131
|
-
code_puppy-0.0.
|
|
132
|
-
code_puppy-0.0.
|
|
133
|
-
code_puppy-0.0.
|
|
134
|
-
code_puppy-0.0.
|
|
129
|
+
code_puppy-0.0.144.data/data/code_puppy/models.json,sha256=dAfpMMI2EEeOMv0ynHSmMuJAYDLcZrs5gCLX3voC4-A,3252
|
|
130
|
+
code_puppy-0.0.144.dist-info/METADATA,sha256=86kIwQ2Vf9hFT7PL6NBbHaMZGBzJ6L-CtXVn3IXULk0,21743
|
|
131
|
+
code_puppy-0.0.144.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
132
|
+
code_puppy-0.0.144.dist-info/entry_points.txt,sha256=d8YkBvIUxF-dHNJAj-x4fPEqizbY5d_TwvYpc01U5kw,58
|
|
133
|
+
code_puppy-0.0.144.dist-info/licenses/LICENSE,sha256=31u8x0SPgdOq3izJX41kgFazWsM43zPEF9eskzqbJMY,1075
|
|
134
|
+
code_puppy-0.0.144.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|