alpiecode 2.0.8__tar.gz → 2.0.9__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.
- {alpiecode-2.0.8 → alpiecode-2.0.9}/PKG-INFO +1 -1
- {alpiecode-2.0.8 → alpiecode-2.0.9}/pyproject.toml +1 -1
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/alpiecode.egg-info/PKG-INFO +1 -1
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/backends/openai_backend.py +39 -9
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/config.py +14 -14
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/doctor.py +4 -3
- {alpiecode-2.0.8 → alpiecode-2.0.9}/README.md +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/setup.cfg +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/alpiecode/__init__.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/alpiecode.egg-info/SOURCES.txt +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/alpiecode.egg-info/dependency_links.txt +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/alpiecode.egg-info/entry_points.txt +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/alpiecode.egg-info/requires.txt +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/alpiecode.egg-info/top_level.txt +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/__init__.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/agent.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/backends/__init__.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/backends/base.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/backends/local_backend.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/cache.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/cli.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/client.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/compaction.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/context.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/executor.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/extension/alpiecode.vsix +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/github.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/guardian.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/ipython_ext.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/local_model.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/media.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/memory.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/orchestrator.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/prompt.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/server.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/session.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/tools.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/updater.py +0 -0
- {alpiecode-2.0.8 → alpiecode-2.0.9}/src/codeagent/vscode_installer.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"""
|
|
2
|
-
OpenAI-compatible API inference backend.
|
|
2
|
+
OpenAI-compatible API inference backend with smart model resolution.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
from typing import Any, List, Optional
|
|
6
|
-
from openai import OpenAI
|
|
6
|
+
from openai import OpenAI, NotFoundError
|
|
7
7
|
|
|
8
8
|
from ..config import Config, get_shared_http_client, is_server_reachable
|
|
9
9
|
from .base import ChatResponse, ToolCall
|
|
@@ -15,6 +15,7 @@ class OpenAIBackend:
|
|
|
15
15
|
def __init__(self, cfg: Config):
|
|
16
16
|
self._cfg = cfg
|
|
17
17
|
self._client: Optional[OpenAI] = None
|
|
18
|
+
self._resolved_model: Optional[str] = None
|
|
18
19
|
|
|
19
20
|
@property
|
|
20
21
|
def name(self) -> str:
|
|
@@ -37,27 +38,57 @@ class OpenAIBackend:
|
|
|
37
38
|
)
|
|
38
39
|
return self._client
|
|
39
40
|
|
|
41
|
+
def _get_available_model(self, client: OpenAI) -> str:
|
|
42
|
+
"""Auto-discover the served model name from /v1/models."""
|
|
43
|
+
if self._resolved_model:
|
|
44
|
+
return self._resolved_model
|
|
45
|
+
try:
|
|
46
|
+
models_list = client.models.list()
|
|
47
|
+
if models_list.data:
|
|
48
|
+
for m in models_list.data:
|
|
49
|
+
if m.id == self._cfg.model or getattr(m, "root", None) == self._cfg.model:
|
|
50
|
+
self._resolved_model = m.id
|
|
51
|
+
return self._resolved_model
|
|
52
|
+
self._resolved_model = models_list.data[0].id
|
|
53
|
+
return self._resolved_model
|
|
54
|
+
except Exception:
|
|
55
|
+
pass
|
|
56
|
+
return self._cfg.model
|
|
57
|
+
|
|
40
58
|
def chat_completion(
|
|
41
59
|
self,
|
|
42
60
|
messages: List[dict],
|
|
43
61
|
tools: Optional[List[dict]] = None,
|
|
44
|
-
temperature: float =
|
|
45
|
-
max_tokens: int =
|
|
62
|
+
temperature: Optional[float] = None,
|
|
63
|
+
max_tokens: Optional[int] = None,
|
|
46
64
|
enable_thinking: bool = True,
|
|
47
65
|
) -> ChatResponse:
|
|
66
|
+
temp = temperature if temperature is not None else getattr(self._cfg, "temperature", 0.1)
|
|
67
|
+
m_tokens = max_tokens if max_tokens is not None else getattr(self._cfg, "max_tokens", 8192)
|
|
68
|
+
|
|
48
69
|
client = self._ensure_client()
|
|
70
|
+
model_name = self._get_available_model(client)
|
|
71
|
+
|
|
49
72
|
params = {
|
|
50
|
-
"model":
|
|
73
|
+
"model": model_name,
|
|
51
74
|
"messages": messages,
|
|
52
|
-
"temperature":
|
|
53
|
-
"max_tokens":
|
|
75
|
+
"temperature": temp,
|
|
76
|
+
"max_tokens": m_tokens,
|
|
54
77
|
"extra_body": {"chat_template_kwargs": {"enable_thinking": enable_thinking}},
|
|
55
78
|
}
|
|
56
79
|
if tools:
|
|
57
80
|
params["tools"] = tools
|
|
58
81
|
params["tool_choice"] = "auto"
|
|
59
82
|
|
|
60
|
-
|
|
83
|
+
try:
|
|
84
|
+
resp = client.chat.completions.create(**params)
|
|
85
|
+
except NotFoundError:
|
|
86
|
+
# Model name mismatch -> re-discover model
|
|
87
|
+
self._resolved_model = None
|
|
88
|
+
model_name = self._get_available_model(client)
|
|
89
|
+
params["model"] = model_name
|
|
90
|
+
resp = client.chat.completions.create(**params)
|
|
91
|
+
|
|
61
92
|
msg = resp.choices[0].message
|
|
62
93
|
|
|
63
94
|
tool_calls = None
|
|
@@ -69,7 +100,6 @@ class OpenAIBackend:
|
|
|
69
100
|
args = json.loads(tc.function.arguments or "{}")
|
|
70
101
|
except (json.JSONDecodeError, TypeError):
|
|
71
102
|
args = {}
|
|
72
|
-
# Defensive: ensure args is always a dict (model sometimes returns lists or strings)
|
|
73
103
|
if not isinstance(args, dict):
|
|
74
104
|
args = {}
|
|
75
105
|
tool_calls.append(
|
|
@@ -18,19 +18,19 @@ CONFIG_DIR = Path.home() / ".alpiecode"
|
|
|
18
18
|
CONFIG_PATH = CONFIG_DIR / "config.json"
|
|
19
19
|
|
|
20
20
|
# Config version — bump this when defaults change to trigger auto-migration
|
|
21
|
-
CONFIG_VERSION =
|
|
21
|
+
CONFIG_VERSION = 4 # v4: Primary 20.245.200.125, smart model auto-discovery
|
|
22
22
|
|
|
23
23
|
DEFAULTS = {
|
|
24
|
-
"base_url": "http://
|
|
25
|
-
"model": "169Pi/
|
|
24
|
+
"base_url": "http://20.245.200.125:8000/v1", # Primary endpoint
|
|
25
|
+
"model": "169Pi/grpo_phase_2_merged",
|
|
26
26
|
"model_repo": "169Pi/Alpie_learn_prototype_GGUF_NEW",
|
|
27
27
|
"api_key": "not-needed",
|
|
28
28
|
"hf_token": None,
|
|
29
29
|
"max_turns": 50,
|
|
30
|
-
"temperature": 0.
|
|
31
|
-
"max_tokens":
|
|
30
|
+
"temperature": 0.1,
|
|
31
|
+
"max_tokens": 8192,
|
|
32
32
|
"enable_thinking": True,
|
|
33
|
-
"n_ctx": 32768, # 32k context window
|
|
33
|
+
"n_ctx": 32768, # 32k context window
|
|
34
34
|
"n_gpu_layers": None, # None = auto-detect GPU
|
|
35
35
|
"config_version": CONFIG_VERSION,
|
|
36
36
|
}
|
|
@@ -84,13 +84,13 @@ def get_shared_http_client():
|
|
|
84
84
|
@dataclass
|
|
85
85
|
class Config:
|
|
86
86
|
base_url: Optional[str] = None
|
|
87
|
-
model: str = "169Pi/
|
|
87
|
+
model: str = "169Pi/grpo_phase_2_merged" # Server API model name (vLLM)
|
|
88
88
|
model_repo: str = "169Pi/Alpie_learn_prototype_GGUF_NEW" # HuggingFace repo for offline GGUF
|
|
89
89
|
api_key: str = "not-needed"
|
|
90
90
|
hf_token: Optional[str] = None
|
|
91
91
|
max_turns: int = 50
|
|
92
|
-
temperature: float = 0.
|
|
93
|
-
max_tokens: int =
|
|
92
|
+
temperature: float = 0.1
|
|
93
|
+
max_tokens: int = 8192
|
|
94
94
|
enable_thinking: bool = True
|
|
95
95
|
n_ctx: int = 32768
|
|
96
96
|
n_gpu_layers: Optional[int] = None
|
|
@@ -111,11 +111,11 @@ def load_config() -> Config:
|
|
|
111
111
|
# v1 → v2: n_ctx was 16384, upgrade to 32768
|
|
112
112
|
if saved_data.get("n_ctx") == 16384:
|
|
113
113
|
data["n_ctx"] = 32768
|
|
114
|
-
#
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
# v3 → v4: Primary 20.245.200.125, smart model auto-discovery
|
|
115
|
+
data["base_url"] = "http://20.245.200.125:8000/v1"
|
|
116
|
+
data["model"] = "169Pi/grpo_phase_2_merged"
|
|
117
|
+
data["temperature"] = 0.1
|
|
118
|
+
data["max_tokens"] = 8192
|
|
119
119
|
data["config_version"] = CONFIG_VERSION
|
|
120
120
|
needs_save = True
|
|
121
121
|
except Exception:
|
|
@@ -152,15 +152,16 @@ def run_doctor() -> int:
|
|
|
152
152
|
|
|
153
153
|
remote_ok, remote_msg = _check_remote_latency(cfg.base_url)
|
|
154
154
|
if remote_ok:
|
|
155
|
-
print(f" {_colorize('✅', 'green')}
|
|
155
|
+
print(f" {_colorize('✅', 'green')} Primary Endpoint: {cfg.base_url} — {remote_msg}")
|
|
156
156
|
print(f" {_colorize('✅', 'green')} Model Target: {cfg.model}")
|
|
157
157
|
passed_checks += 2
|
|
158
158
|
else:
|
|
159
|
-
print(f" {_colorize('⚠️ ', 'yellow')}
|
|
160
|
-
print(f" {_colorize('ℹ️ ', 'blue')}
|
|
159
|
+
print(f" {_colorize('⚠️ ', 'yellow')} Primary Endpoint: {cfg.base_url} — {remote_msg}")
|
|
160
|
+
print(f" {_colorize('ℹ️ ', 'blue')} Local fallback ready with: {cfg.model_repo}")
|
|
161
161
|
passed_checks += 1
|
|
162
162
|
total_checks += 2
|
|
163
163
|
|
|
164
|
+
|
|
164
165
|
# 4. Development Compilers & Runtimes
|
|
165
166
|
print()
|
|
166
167
|
print(_colorize(" 🧰 Development Tools & Compilers", "cyan"))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|