code-puppy 0.0.157__py3-none-any.whl → 0.0.158__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/command_line/command_handler.py +7 -8
- code_puppy/config.py +2 -0
- code_puppy/model_factory.py +29 -0
- code_puppy/models.json +0 -6
- {code_puppy-0.0.157.data → code_puppy-0.0.158.data}/data/code_puppy/models.json +0 -6
- {code_puppy-0.0.157.dist-info → code_puppy-0.0.158.dist-info}/METADATA +1 -1
- {code_puppy-0.0.157.dist-info → code_puppy-0.0.158.dist-info}/RECORD +10 -10
- {code_puppy-0.0.157.dist-info → code_puppy-0.0.158.dist-info}/WHEEL +0 -0
- {code_puppy-0.0.157.dist-info → code_puppy-0.0.158.dist-info}/entry_points.txt +0 -0
- {code_puppy-0.0.157.dist-info → code_puppy-0.0.158.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import os
|
|
2
2
|
|
|
3
|
-
from code_puppy.command_line.model_picker_completion import
|
|
4
|
-
load_model_names,
|
|
5
|
-
update_model_in_input,
|
|
6
|
-
)
|
|
3
|
+
from code_puppy.command_line.model_picker_completion import update_model_in_input
|
|
7
4
|
from code_puppy.command_line.motd import print_motd
|
|
8
5
|
from code_puppy.command_line.utils import make_directory_table
|
|
9
6
|
from code_puppy.config import get_config_keys
|
|
@@ -60,7 +57,7 @@ def get_commands_help():
|
|
|
60
57
|
)
|
|
61
58
|
help_lines.append(
|
|
62
59
|
Text("/compact", style="cyan")
|
|
63
|
-
+ Text(" Summarize and compact current chat history")
|
|
60
|
+
+ Text(" Summarize and compact current chat history (uses compaction_strategy config)")
|
|
64
61
|
)
|
|
65
62
|
help_lines.append(
|
|
66
63
|
Text("/dump_context", style="cyan")
|
|
@@ -137,18 +134,18 @@ def handle_command(command: str):
|
|
|
137
134
|
|
|
138
135
|
before_tokens = sum(estimate_tokens_for_message(m) for m in history)
|
|
139
136
|
compaction_strategy = get_compaction_strategy()
|
|
137
|
+
protected_tokens = get_protected_token_count()
|
|
140
138
|
emit_info(
|
|
141
139
|
f"🤔 Compacting {len(history)} messages using {compaction_strategy} strategy... (~{before_tokens} tokens)"
|
|
142
140
|
)
|
|
143
141
|
|
|
144
142
|
if compaction_strategy == "truncation":
|
|
145
|
-
protected_tokens = get_protected_token_count()
|
|
146
143
|
compacted = truncation(history, protected_tokens)
|
|
147
144
|
summarized_messages = [] # No summarization in truncation mode
|
|
148
145
|
else:
|
|
149
146
|
# Default to summarization
|
|
150
147
|
compacted, summarized_messages = summarize_messages(
|
|
151
|
-
history, with_protection=
|
|
148
|
+
history, with_protection=True
|
|
152
149
|
)
|
|
153
150
|
|
|
154
151
|
if not compacted:
|
|
@@ -372,6 +369,9 @@ def handle_command(command: str):
|
|
|
372
369
|
# Convert /model to /m for internal processing
|
|
373
370
|
model_command = command.replace("/model", "/m", 1)
|
|
374
371
|
|
|
372
|
+
# If no model matched, show available models
|
|
373
|
+
from code_puppy.command_line.model_picker_completion import load_model_names
|
|
374
|
+
|
|
375
375
|
new_input = update_model_in_input(model_command)
|
|
376
376
|
if new_input is not None:
|
|
377
377
|
from code_puppy.agents.runtime_manager import get_runtime_agent_manager
|
|
@@ -383,7 +383,6 @@ def handle_command(command: str):
|
|
|
383
383
|
manager.reload_agent()
|
|
384
384
|
emit_success(f"Active model set and loaded: {model}")
|
|
385
385
|
return True
|
|
386
|
-
# If no model matched, show available models
|
|
387
386
|
model_names = load_model_names()
|
|
388
387
|
emit_warning("Usage: /model <model-name> or /m <model-name>")
|
|
389
388
|
emit_warning(f"Available models: {', '.join(model_names)}")
|
code_puppy/config.py
CHANGED
code_puppy/model_factory.py
CHANGED
|
@@ -14,6 +14,7 @@ from pydantic_ai.providers.anthropic import AnthropicProvider
|
|
|
14
14
|
from pydantic_ai.providers.google_gla import GoogleGLAProvider
|
|
15
15
|
from pydantic_ai.providers.openai import OpenAIProvider
|
|
16
16
|
from pydantic_ai.providers.cerebras import CerebrasProvider
|
|
17
|
+
from pydantic_ai.providers.openrouter import OpenRouterProvider
|
|
17
18
|
|
|
18
19
|
from . import callbacks
|
|
19
20
|
from .config import EXTRA_MODELS_FILE
|
|
@@ -248,6 +249,34 @@ class ModelFactory:
|
|
|
248
249
|
setattr(model, "provider", provider)
|
|
249
250
|
return model
|
|
250
251
|
|
|
252
|
+
elif model_type == "openrouter":
|
|
253
|
+
# Get API key from config, which can be an environment variable reference or raw value
|
|
254
|
+
api_key_config = model_config.get("api_key")
|
|
255
|
+
api_key = None
|
|
256
|
+
|
|
257
|
+
if api_key_config:
|
|
258
|
+
if api_key_config.startswith("$"):
|
|
259
|
+
# It's an environment variable reference
|
|
260
|
+
env_var_name = api_key_config[1:] # Remove the $ prefix
|
|
261
|
+
api_key = os.environ.get(env_var_name)
|
|
262
|
+
if api_key is None:
|
|
263
|
+
raise ValueError(
|
|
264
|
+
f"OpenRouter API key environment variable '{env_var_name}' not found or is empty. "
|
|
265
|
+
f"Please set the environment variable: export {env_var_name}=your_value"
|
|
266
|
+
)
|
|
267
|
+
else:
|
|
268
|
+
# It's a raw API key value
|
|
269
|
+
api_key = api_key_config
|
|
270
|
+
else:
|
|
271
|
+
# No API key in config, try to get it from the default environment variable
|
|
272
|
+
api_key = os.environ.get("OPENROUTER_API_KEY")
|
|
273
|
+
|
|
274
|
+
provider = OpenRouterProvider(api_key=api_key)
|
|
275
|
+
|
|
276
|
+
model = OpenAIChatModel(model_name=model_config["name"], provider=provider)
|
|
277
|
+
setattr(model, "provider", provider)
|
|
278
|
+
return model
|
|
279
|
+
|
|
251
280
|
elif model_type == "round_robin":
|
|
252
281
|
# Get the list of model names to use in the round-robin
|
|
253
282
|
model_names = model_config.get("models")
|
code_puppy/models.json
CHANGED
|
@@ -87,12 +87,6 @@
|
|
|
87
87
|
},
|
|
88
88
|
"context_length": 64000
|
|
89
89
|
},
|
|
90
|
-
"openrouter": {
|
|
91
|
-
"type": "openrouter",
|
|
92
|
-
"name": "meta-llama/llama-4-maverick:free",
|
|
93
|
-
"api_key": "$OPENROUTER_API_KEY",
|
|
94
|
-
"context_length": 131072
|
|
95
|
-
},
|
|
96
90
|
"azure-gpt-4.1": {
|
|
97
91
|
"type": "azure_openai",
|
|
98
92
|
"name": "gpt-4.1",
|
|
@@ -87,12 +87,6 @@
|
|
|
87
87
|
},
|
|
88
88
|
"context_length": 64000
|
|
89
89
|
},
|
|
90
|
-
"openrouter": {
|
|
91
|
-
"type": "openrouter",
|
|
92
|
-
"name": "meta-llama/llama-4-maverick:free",
|
|
93
|
-
"api_key": "$OPENROUTER_API_KEY",
|
|
94
|
-
"context_length": 131072
|
|
95
|
-
},
|
|
96
90
|
"azure-gpt-4.1": {
|
|
97
91
|
"type": "azure_openai",
|
|
98
92
|
"name": "gpt-4.1",
|
|
@@ -2,12 +2,12 @@ code_puppy/__init__.py,sha256=ehbM1-wMjNmOXk_DBhhJECFyBv2dRHwwo7ucjHeM68E,107
|
|
|
2
2
|
code_puppy/__main__.py,sha256=pDVssJOWP8A83iFkxMLY9YteHYat0EyWDQqMkKHpWp4,203
|
|
3
3
|
code_puppy/agent.py,sha256=hZOrJJJDwtLtb82b6Zyt5CZb8RbzDtvHMIBUPVYsgOM,8133
|
|
4
4
|
code_puppy/callbacks.py,sha256=6wYB6K_fGSCkKKEFaYOYkJT45WaV5W_NhUIzcvVH_nU,5060
|
|
5
|
-
code_puppy/config.py,sha256=
|
|
5
|
+
code_puppy/config.py,sha256=k6sqdGH-RsssBYMXdRkhaXN3iYI347XTeMw9ibu3mIs,16272
|
|
6
6
|
code_puppy/http_utils.py,sha256=BAvt4hed7fVMXglA7eS9gOb08h2YTuOyai6VmQq09fg,3432
|
|
7
7
|
code_puppy/main.py,sha256=tYLfhUjPTJ-4S1r-pr-jSbn6kIU1iYvt2Z8lxI7zDFY,22220
|
|
8
8
|
code_puppy/message_history_processor.py,sha256=aV-vcRcOQJPZPlrokB4CaLMxEU3Y4nDiabb9Ov_sJeU,15933
|
|
9
|
-
code_puppy/model_factory.py,sha256=
|
|
10
|
-
code_puppy/models.json,sha256=
|
|
9
|
+
code_puppy/model_factory.py,sha256=_drvOUKx2ivLY_TfE-D6gdZDJzIMyPqf2IWU83KEIE4,13158
|
|
10
|
+
code_puppy/models.json,sha256=iXmLZGflnQcu2DRh4WUlgAhoXdvoxUc7KBhB8YxawXM,3088
|
|
11
11
|
code_puppy/reopenable_async_client.py,sha256=4UJRaMp5np8cbef9F0zKQ7TPKOfyf5U-Kv-0zYUWDho,8274
|
|
12
12
|
code_puppy/round_robin_model.py,sha256=SEN3VSwTgC5wHjx2sZsHQLPWOycf4jGwzB-EydgqkdY,5643
|
|
13
13
|
code_puppy/state_management.py,sha256=o4mNBCPblRyVrNBH-992-1YqffgH6AKHU7iZRqgP1LI,5925
|
|
@@ -23,7 +23,7 @@ code_puppy/agents/base_agent.py,sha256=XYSff6IQX9Z6C7hPVbN_YXC2xfjwd268e2jtG3ZGn
|
|
|
23
23
|
code_puppy/agents/json_agent.py,sha256=y6AYE3Fx9LhmemcPzt46d7359MNnkGIjU83YBGNer2g,4533
|
|
24
24
|
code_puppy/agents/runtime_manager.py,sha256=fUOBpmETo3wTyLc5wWBfGKSX1HFRQWSpuwxYAOyA-_8,10059
|
|
25
25
|
code_puppy/command_line/__init__.py,sha256=y7WeRemfYppk8KVbCGeAIiTuiOszIURCDjOMZv_YRmU,45
|
|
26
|
-
code_puppy/command_line/command_handler.py,sha256=
|
|
26
|
+
code_puppy/command_line/command_handler.py,sha256=w0sE_oGRe6oV05a8-9vJmz0gZWRq_whE8a2mk8Tx7M8,24612
|
|
27
27
|
code_puppy/command_line/file_path_completion.py,sha256=gw8NpIxa6GOpczUJRyh7VNZwoXKKn-yvCqit7h2y6Gg,2931
|
|
28
28
|
code_puppy/command_line/load_context_completion.py,sha256=6eZxV6Bs-EFwZjN93V8ZDZUC-6RaWxvtZk-04Wtikyw,2240
|
|
29
29
|
code_puppy/command_line/meta_command_handler.py,sha256=80aK5JQOaqjt149qBmSsM02uy2Cikkee8zaQnu5u2KQ,5712
|
|
@@ -104,9 +104,9 @@ code_puppy/tui/screens/help.py,sha256=eJuPaOOCp7ZSUlecearqsuX6caxWv7NQszUh0tZJjB
|
|
|
104
104
|
code_puppy/tui/screens/mcp_install_wizard.py,sha256=xqwN5omltMkfxWZwXj3D2PbXbtrxUi1dT0XT77oxOKk,27685
|
|
105
105
|
code_puppy/tui/screens/settings.py,sha256=GMpv-qa08rorAE9mj3AjmqjZFPhmeJ_GWd-DBHG6iAA,10671
|
|
106
106
|
code_puppy/tui/screens/tools.py,sha256=3pr2Xkpa9Js6Yhf1A3_wQVRzFOui-KDB82LwrsdBtyk,1715
|
|
107
|
-
code_puppy-0.0.
|
|
108
|
-
code_puppy-0.0.
|
|
109
|
-
code_puppy-0.0.
|
|
110
|
-
code_puppy-0.0.
|
|
111
|
-
code_puppy-0.0.
|
|
112
|
-
code_puppy-0.0.
|
|
107
|
+
code_puppy-0.0.158.data/data/code_puppy/models.json,sha256=iXmLZGflnQcu2DRh4WUlgAhoXdvoxUc7KBhB8YxawXM,3088
|
|
108
|
+
code_puppy-0.0.158.dist-info/METADATA,sha256=YQw9I4coF7mBOkVxKtBYOC04PSk3HbghzjwgHKRurhc,19567
|
|
109
|
+
code_puppy-0.0.158.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
110
|
+
code_puppy-0.0.158.dist-info/entry_points.txt,sha256=d8YkBvIUxF-dHNJAj-x4fPEqizbY5d_TwvYpc01U5kw,58
|
|
111
|
+
code_puppy-0.0.158.dist-info/licenses/LICENSE,sha256=31u8x0SPgdOq3izJX41kgFazWsM43zPEF9eskzqbJMY,1075
|
|
112
|
+
code_puppy-0.0.158.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|