alpiecode 10.7.2__tar.gz → 10.7.4__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-10.7.2 → alpiecode-10.7.4}/PKG-INFO +1 -1
- {alpiecode-10.7.2 → alpiecode-10.7.4}/pyproject.toml +1 -1
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/alpiecode.egg-info/PKG-INFO +1 -1
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/__init__.py +1 -1
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/agent.py +2 -1
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/backends/local_backend.py +104 -6
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/backends/openai_backend.py +7 -3
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/cli.py +2 -2
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/config.py +24 -12
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/local_model.py +16 -5
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/orchestrator.py +1 -1
- {alpiecode-10.7.2 → alpiecode-10.7.4}/README.md +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/setup.cfg +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/alpiecode/__init__.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/alpiecode.egg-info/SOURCES.txt +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/alpiecode.egg-info/dependency_links.txt +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/alpiecode.egg-info/entry_points.txt +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/alpiecode.egg-info/requires.txt +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/alpiecode.egg-info/top_level.txt +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/assessment.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/backends/__init__.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/backends/base.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/cache.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/client.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/compaction.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/context.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/discovery.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/doctor.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/dream_rsi.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/executor.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/extension/alpiecode.vsix +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/git_ops.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/github.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/guardian.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/guardrails.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/ipython_ext.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/media.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/memory.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/metrics.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/paths.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/progress.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/prompt.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/rephraser.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/server.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/session.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/system1.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/tools.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/updater.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/verifier.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/src/codeagent/vscode_installer.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/test/test_adaptive_resilience.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/test/test_cli_ui.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/test/test_context_and_trajectory.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/test/test_dream_rsi.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/test/test_local_model_download.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/test/test_non_thinking_and_local_stream.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/test/test_task_assessment.py +0 -0
- {alpiecode-10.7.2 → alpiecode-10.7.4}/test/test_verifier.py +0 -0
|
@@ -17,7 +17,7 @@ Supports:
|
|
|
17
17
|
from pathlib import Path
|
|
18
18
|
from typing import Optional, Any, Dict
|
|
19
19
|
|
|
20
|
-
__version__ = "10.7.
|
|
20
|
+
__version__ = "10.7.4"
|
|
21
21
|
|
|
22
22
|
def run(task: str, workdir: str = ".", reasoning_level: str = "thinking", **kwargs):
|
|
23
23
|
"""Run an autonomous coding task programmatically."""
|
|
@@ -744,7 +744,8 @@ def run_chat(workdir: Path, cfg: Config, verbose: bool = True, debug: bool = Fal
|
|
|
744
744
|
|
|
745
745
|
if HAS_RICH:
|
|
746
746
|
console.print()
|
|
747
|
-
|
|
747
|
+
cur_model = getattr(cfg, "model", "alpie_seed")
|
|
748
|
+
mode_line = f"🌐 Mode: [bold green]ONLINE[/bold green]\n🤖 Model: [bold cyan]{cur_model}[/bold cyan]" if not is_offline else f"🧠 Mode: [bold yellow]OFFLINE[/bold yellow]\n🤖 Model: [bold cyan]{cur_model} (Local GGUF)[/bold cyan]"
|
|
748
749
|
console.print(
|
|
749
750
|
Panel(
|
|
750
751
|
f"[bold cyan]AlpieCode[/bold cyan] interactive mode\n"
|
|
@@ -105,17 +105,28 @@ class LocalBackend:
|
|
|
105
105
|
if isinstance(part, dict):
|
|
106
106
|
if part.get("type") == "text":
|
|
107
107
|
text_parts.append(part.get("text", ""))
|
|
108
|
+
elif part.get("type") == "image_url":
|
|
109
|
+
text_parts.append("[Attached Image]")
|
|
108
110
|
elif isinstance(part, str):
|
|
109
111
|
text_parts.append(part)
|
|
110
112
|
content = "\n".join(text_parts) if text_parts else ""
|
|
111
113
|
elif not isinstance(content, str):
|
|
112
114
|
content = str(content)
|
|
113
115
|
|
|
116
|
+
# Sanitize raw data:image URI strings (prevent 160k+ token base64 bloating)
|
|
117
|
+
if "data:image/" in content:
|
|
118
|
+
import re as _re
|
|
119
|
+
content = _re.sub(r"data:image/[^;]+;base64,[A-Za-z0-9+/=]+", "[Embedded Image Data]", content)
|
|
120
|
+
|
|
114
121
|
# For assistant messages, condense bulky write_file / edit_file payloads from content
|
|
115
122
|
if role == "assistant":
|
|
116
123
|
from ..compaction import compact_text_tool_calls
|
|
117
124
|
content = compact_text_tool_calls(content)
|
|
118
125
|
|
|
126
|
+
# Cap individual turns at 12,000 chars (~3,000 tokens) for safe local context budget
|
|
127
|
+
if len(content) > 12000:
|
|
128
|
+
content = content[:11000] + f"\n... [content truncated: {len(content)} chars total for local context headroom]"
|
|
129
|
+
|
|
119
130
|
# For assistant messages with tool_calls, embed tool call info in content text ONLY if not already marked
|
|
120
131
|
if role == "assistant" and msg.get("tool_calls"):
|
|
121
132
|
already_marked = (
|
|
@@ -158,6 +169,64 @@ class LocalBackend:
|
|
|
158
169
|
|
|
159
170
|
return sanitized
|
|
160
171
|
|
|
172
|
+
@staticmethod
|
|
173
|
+
def _enforce_context_headroom(
|
|
174
|
+
messages: List[dict],
|
|
175
|
+
max_context: int = 8192,
|
|
176
|
+
max_tokens: int = 2048,
|
|
177
|
+
) -> Tuple[List[dict], int]:
|
|
178
|
+
"""
|
|
179
|
+
Enforce strict prompt token headroom for local GGUF / llama-server endpoints.
|
|
180
|
+
Prevents HTTP 400: 'request (N tokens) exceeds the available context size' errors.
|
|
181
|
+
"""
|
|
182
|
+
if not messages:
|
|
183
|
+
return messages, min(max_tokens, max(256, max_context - 64))
|
|
184
|
+
|
|
185
|
+
def _estimate_msg_tokens(m: dict) -> int:
|
|
186
|
+
cnt = str(m.get("content") or "")
|
|
187
|
+
return max(1, len(cnt) // 4) + 6
|
|
188
|
+
|
|
189
|
+
# Allocate generation headroom
|
|
190
|
+
max_gen_budget = max(256, min(max_tokens, max_context // 2))
|
|
191
|
+
allowed_prompt_tokens = max(256, max_context - max_gen_budget - 32)
|
|
192
|
+
|
|
193
|
+
sys_msgs = [m for m in messages if m.get("role") == "system"]
|
|
194
|
+
non_sys = [m for m in messages if m.get("role") != "system"]
|
|
195
|
+
|
|
196
|
+
if not non_sys:
|
|
197
|
+
compacted = list(sys_msgs)
|
|
198
|
+
else:
|
|
199
|
+
tail_msg = dict(non_sys[-1])
|
|
200
|
+
middle_msgs = [dict(m) for m in non_sys[:-1]]
|
|
201
|
+
|
|
202
|
+
all_work = [dict(m) for m in sys_msgs] + middle_msgs + [tail_msg]
|
|
203
|
+
total_prompt_tokens = sum(_estimate_msg_tokens(m) for m in all_work)
|
|
204
|
+
|
|
205
|
+
if total_prompt_tokens > allowed_prompt_tokens:
|
|
206
|
+
# Drop older middle messages first
|
|
207
|
+
while middle_msgs and total_prompt_tokens > allowed_prompt_tokens:
|
|
208
|
+
dropped = middle_msgs.pop(0)
|
|
209
|
+
total_prompt_tokens -= _estimate_msg_tokens(dropped)
|
|
210
|
+
|
|
211
|
+
# If still over budget, truncate tail and system content
|
|
212
|
+
if total_prompt_tokens > allowed_prompt_tokens:
|
|
213
|
+
excess = total_prompt_tokens - allowed_prompt_tokens
|
|
214
|
+
chars_to_cut = (excess + 16) * 4
|
|
215
|
+
tail_content = str(tail_msg.get("content", ""))
|
|
216
|
+
if len(tail_content) > chars_to_cut + 200:
|
|
217
|
+
tail_msg["content"] = tail_content[:-chars_to_cut] + "\n... [truncated for context limit]"
|
|
218
|
+
elif sys_msgs:
|
|
219
|
+
sys_content = str(sys_msgs[0].get("content", ""))
|
|
220
|
+
if len(sys_content) > chars_to_cut + 200:
|
|
221
|
+
sys_msgs[0] = dict(sys_msgs[0])
|
|
222
|
+
sys_msgs[0]["content"] = sys_content[:-chars_to_cut] + "\n... [truncated system prompt]"
|
|
223
|
+
|
|
224
|
+
compacted = sys_msgs + middle_msgs + [tail_msg]
|
|
225
|
+
|
|
226
|
+
final_prompt_tokens = sum(_estimate_msg_tokens(m) for m in compacted)
|
|
227
|
+
safe_max_tokens = max(128, min(max_tokens, max_context - final_prompt_tokens - 8))
|
|
228
|
+
return compacted, safe_max_tokens
|
|
229
|
+
|
|
161
230
|
def chat_completion(
|
|
162
231
|
self,
|
|
163
232
|
messages: List[dict],
|
|
@@ -432,11 +501,14 @@ class LocalBackend:
|
|
|
432
501
|
u_text = str(sanitized[-1].get("content", ""))
|
|
433
502
|
if "[Direct Mode:" not in u_text:
|
|
434
503
|
sanitized[-1]["content"] = u_text + "\n\n[Direct Mode: Output code and tool calls directly without <think> tags. Do not deliberate.]"
|
|
504
|
+
|
|
505
|
+
n_ctx = getattr(self._cfg, "n_ctx", 8192) or 8192
|
|
506
|
+
sanitized, safe_max_tokens = self._enforce_context_headroom(sanitized, max_context=n_ctx, max_tokens=max_tokens)
|
|
435
507
|
payload = {
|
|
436
508
|
"model": "local",
|
|
437
509
|
"messages": sanitized,
|
|
438
510
|
"temperature": temperature,
|
|
439
|
-
"max_tokens":
|
|
511
|
+
"max_tokens": safe_max_tokens,
|
|
440
512
|
"stream": False,
|
|
441
513
|
}
|
|
442
514
|
if tools and getattr(self._cfg, "enable_native_tools", False):
|
|
@@ -489,11 +561,15 @@ class LocalBackend:
|
|
|
489
561
|
u_text = str(sanitized[-1].get("content", ""))
|
|
490
562
|
if "[Direct Mode:" not in u_text:
|
|
491
563
|
sanitized[-1]["content"] = u_text + "\n\n[Direct Mode: Output code and tool calls directly without <think> tags. Do not deliberate.]"
|
|
564
|
+
|
|
565
|
+
n_ctx = getattr(self._cfg, "n_ctx", 8192) or 8192
|
|
566
|
+
m_tokens = max_tokens if max_tokens is not None else getattr(self._cfg, "max_tokens", 2048)
|
|
567
|
+
sanitized, safe_max_tokens = self._enforce_context_headroom(sanitized, max_context=n_ctx, max_tokens=m_tokens)
|
|
492
568
|
payload = {
|
|
493
569
|
"model": "local",
|
|
494
570
|
"messages": sanitized,
|
|
495
571
|
"temperature": temperature or 0.2,
|
|
496
|
-
"max_tokens":
|
|
572
|
+
"max_tokens": safe_max_tokens,
|
|
497
573
|
"stream": True,
|
|
498
574
|
}
|
|
499
575
|
if tools and getattr(self._cfg, "enable_native_tools", False):
|
|
@@ -867,11 +943,13 @@ class iOSBackend(BasePlatformBackend):
|
|
|
867
943
|
import json
|
|
868
944
|
bridge_url = self._get_bridge_url()
|
|
869
945
|
sanitized = self._sanitize_messages_for_gguf(messages)
|
|
946
|
+
n_ctx = getattr(self._cfg, "n_ctx", 4096) or 4096
|
|
947
|
+
sanitized, safe_max_tokens = self._enforce_context_headroom(sanitized, max_context=n_ctx, max_tokens=max_tokens)
|
|
870
948
|
payload = {
|
|
871
949
|
"model": "local",
|
|
872
950
|
"messages": sanitized,
|
|
873
951
|
"temperature": temperature,
|
|
874
|
-
"max_tokens":
|
|
952
|
+
"max_tokens": safe_max_tokens,
|
|
875
953
|
"stream": False,
|
|
876
954
|
}
|
|
877
955
|
if tools and getattr(self._cfg, "enable_native_tools", False):
|
|
@@ -946,11 +1024,14 @@ class iOSBackend(BasePlatformBackend):
|
|
|
946
1024
|
import json
|
|
947
1025
|
bridge_url = self._get_bridge_url()
|
|
948
1026
|
sanitized = self._sanitize_messages_for_gguf(messages)
|
|
1027
|
+
n_ctx = getattr(self._cfg, "n_ctx", 4096) or 4096
|
|
1028
|
+
m_tokens = max_tokens if max_tokens is not None else getattr(self._cfg, "max_tokens", 2048)
|
|
1029
|
+
sanitized, safe_max_tokens = self._enforce_context_headroom(sanitized, max_context=n_ctx, max_tokens=m_tokens)
|
|
949
1030
|
payload = {
|
|
950
1031
|
"model": "local",
|
|
951
1032
|
"messages": sanitized,
|
|
952
1033
|
"temperature": temperature or 0.2,
|
|
953
|
-
"max_tokens":
|
|
1034
|
+
"max_tokens": safe_max_tokens,
|
|
954
1035
|
"stream": True,
|
|
955
1036
|
}
|
|
956
1037
|
if tools and getattr(self._cfg, "enable_native_tools", False):
|
|
@@ -1038,9 +1119,26 @@ class AndroidBackend(BasePlatformBackend):
|
|
|
1038
1119
|
for d in candidate_dirs:
|
|
1039
1120
|
if d.exists():
|
|
1040
1121
|
ggufs = list(d.glob("*.gguf"))
|
|
1041
|
-
mains = [
|
|
1122
|
+
mains = [
|
|
1123
|
+
g for g in ggufs
|
|
1124
|
+
if "mmproj" not in g.name.lower()
|
|
1125
|
+
and not g.name.endswith(".defective")
|
|
1126
|
+
and not g.name.endswith(".bak")
|
|
1127
|
+
and not g.name.endswith(".tmp")
|
|
1128
|
+
]
|
|
1042
1129
|
if mains:
|
|
1043
|
-
|
|
1130
|
+
def _model_priority(p: Path) -> int:
|
|
1131
|
+
n = p.name.lower()
|
|
1132
|
+
if "grpo_phase_4_merged" in n and "q3_k_s" in n:
|
|
1133
|
+
return 0
|
|
1134
|
+
if "q3_k_m" in n:
|
|
1135
|
+
return 1
|
|
1136
|
+
if "q4_k_m" in n:
|
|
1137
|
+
return 2
|
|
1138
|
+
if "q2_k" in n:
|
|
1139
|
+
return 3
|
|
1140
|
+
return 4
|
|
1141
|
+
mains.sort(key=lambda p: (_model_priority(p), p.stat().st_size))
|
|
1044
1142
|
return mains[0]
|
|
1045
1143
|
return None
|
|
1046
1144
|
|
|
@@ -39,12 +39,16 @@ def _dict_to_obj(d: Any) -> Any:
|
|
|
39
39
|
return d
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
PRIMARY_DOMAIN = "
|
|
43
|
-
PRIMARY_IP = "
|
|
42
|
+
PRIMARY_DOMAIN = "ec2-18-222-121-38.us-east-2.compute.amazonaws.com"
|
|
43
|
+
PRIMARY_IP = "18.222.121.38"
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
def _make_fallback_ip_url(url: str) -> str:
|
|
47
|
-
|
|
47
|
+
if PRIMARY_DOMAIN in url:
|
|
48
|
+
return url.replace(PRIMARY_DOMAIN, PRIMARY_IP)
|
|
49
|
+
if "test.169pi.ai" in url:
|
|
50
|
+
return url.replace("https://test.169pi.ai", "https://20.245.200.125")
|
|
51
|
+
return url
|
|
48
52
|
|
|
49
53
|
|
|
50
54
|
class _HTTPXChatCompletions:
|
|
@@ -98,9 +98,9 @@ def main():
|
|
|
98
98
|
common.add_argument("--github", default=None, help="GitHub repository (e.g. owner/repo or URL) for open-source analysis")
|
|
99
99
|
common.add_argument("--max-turns", type=int, default=None, help="Override max turns")
|
|
100
100
|
common.add_argument("--endpoint", "--base-url", dest="endpoint", default=None, help="VLM API endpoint base URL")
|
|
101
|
-
common.add_argument("--model", dest="model", default=None, help="Model name (e.g. alpie_9b)")
|
|
101
|
+
common.add_argument("--model", dest="model", default=None, help="Model name (e.g. alpie_seed, alpie_9b)")
|
|
102
102
|
common.add_argument("--api-key", dest="api_key", default=None, help="API key for endpoint authentication")
|
|
103
|
-
common.add_argument("--preset", dest="preset", choices=["default", "alpie_9b"], default=None, help="Endpoint preset profile")
|
|
103
|
+
common.add_argument("--preset", dest="preset", choices=["default", "alpie_seed", "alpie_9b"], default=None, help="Endpoint preset profile")
|
|
104
104
|
common.add_argument("--thinking", "--reasoning", dest="thinking", action="store_true", help="Enable VLM reasoning mode")
|
|
105
105
|
common.add_argument("--no-thinking", "--non-thinking", dest="no_thinking", action="store_true", help="Disable VLM reasoning mode")
|
|
106
106
|
common.add_argument("--force-thinking", dest="force_thinking", action="store_true", help="Force VLM reasoning on all turns, disabling dynamic gating")
|
|
@@ -43,7 +43,7 @@ CONFIG_DIR = get_alpiecode_dir()
|
|
|
43
43
|
CONFIG_PATH = get_config_path()
|
|
44
44
|
|
|
45
45
|
# Config version — bump this when defaults change to trigger auto-migration
|
|
46
|
-
CONFIG_VERSION =
|
|
46
|
+
CONFIG_VERSION = 12 # v12: Switched primary cloud endpoint to AWS EC2 alpie_seed
|
|
47
47
|
|
|
48
48
|
# Embedded Hugging Face token: provides 100% out-of-the-box functionality for end users
|
|
49
49
|
# Can be overridden via .env or HF_TOKEN / HUGGING_FACE_HUB_TOKEN environment variables
|
|
@@ -52,8 +52,8 @@ DEFAULT_HF_TOKEN = os.environ.get("HF_TOKEN") or os.environ.get("HUGGING_FACE_HU
|
|
|
52
52
|
DEFAULT_MODEL_REPO = "169Pi/alpie_learn_gguf"
|
|
53
53
|
|
|
54
54
|
DEFAULTS = {
|
|
55
|
-
"base_url": "
|
|
56
|
-
"model": "
|
|
55
|
+
"base_url": "http://ec2-18-222-121-38.us-east-2.compute.amazonaws.com:8000/v1", # Primary endpoint
|
|
56
|
+
"model": "alpie_seed",
|
|
57
57
|
"model_repo": DEFAULT_MODEL_REPO,
|
|
58
58
|
"api_key": "not-needed",
|
|
59
59
|
"hf_token": DEFAULT_HF_TOKEN,
|
|
@@ -63,6 +63,7 @@ DEFAULTS = {
|
|
|
63
63
|
"enable_thinking": False, # Reasoning OFF by default
|
|
64
64
|
"adaptive_thinking": True, # Adaptive turn-level reasoning dynamics
|
|
65
65
|
"force_thinking": False, # Force reasoning on every single turn
|
|
66
|
+
"force_no_thinking": False, # Fast execution mode
|
|
66
67
|
"n_ctx": 32768, # 32k context window
|
|
67
68
|
"n_gpu_layers": None, # None = auto-detect GPU
|
|
68
69
|
"config_version": CONFIG_VERSION,
|
|
@@ -70,8 +71,13 @@ DEFAULTS = {
|
|
|
70
71
|
|
|
71
72
|
KNOWN_PRESETS = {
|
|
72
73
|
"default": {
|
|
73
|
-
"base_url": "
|
|
74
|
-
"model": "
|
|
74
|
+
"base_url": "http://ec2-18-222-121-38.us-east-2.compute.amazonaws.com:8000/v1",
|
|
75
|
+
"model": "alpie_seed",
|
|
76
|
+
"api_key": "not-needed",
|
|
77
|
+
},
|
|
78
|
+
"alpie_seed": {
|
|
79
|
+
"base_url": "http://ec2-18-222-121-38.us-east-2.compute.amazonaws.com:8000/v1",
|
|
80
|
+
"model": "alpie_seed",
|
|
75
81
|
"api_key": "not-needed",
|
|
76
82
|
},
|
|
77
83
|
"alpie_9b": {
|
|
@@ -97,8 +103,14 @@ def is_server_reachable(base_url: Optional[str], timeout: float = 0.5) -> bool:
|
|
|
97
103
|
with socket.create_connection((host, port), timeout=timeout):
|
|
98
104
|
return True
|
|
99
105
|
except (socket.gaierror, OSError):
|
|
100
|
-
# Resilient IP fallback for test.169pi.ai on mobile/iOS where DNS might fail ([Errno 8])
|
|
101
|
-
if host
|
|
106
|
+
# Resilient IP fallback for AWS EC2 / test.169pi.ai on mobile/iOS where DNS might fail ([Errno 8])
|
|
107
|
+
if host and "ec2-18-222-121-38" in host:
|
|
108
|
+
try:
|
|
109
|
+
with socket.create_connection(("18.222.121.38", port), timeout=timeout):
|
|
110
|
+
return True
|
|
111
|
+
except Exception:
|
|
112
|
+
pass
|
|
113
|
+
elif host == "test.169pi.ai":
|
|
102
114
|
try:
|
|
103
115
|
with socket.create_connection(("20.245.200.125", port), timeout=timeout):
|
|
104
116
|
return True
|
|
@@ -150,7 +162,7 @@ def get_shared_http_client():
|
|
|
150
162
|
@dataclass
|
|
151
163
|
class Config:
|
|
152
164
|
base_url: Optional[str] = None
|
|
153
|
-
model: str = "
|
|
165
|
+
model: str = "alpie_seed" # Server API model name (vLLM)
|
|
154
166
|
model_repo: str = DEFAULT_MODEL_REPO # HuggingFace repo for offline GGUF
|
|
155
167
|
api_key: str = "not-needed"
|
|
156
168
|
hf_token: Optional[str] = DEFAULT_HF_TOKEN
|
|
@@ -177,11 +189,11 @@ def load_config() -> Config:
|
|
|
177
189
|
|
|
178
190
|
# ── Auto-migrate stale configs ────────────────────────────
|
|
179
191
|
saved_version = saved_data.get("config_version", 1)
|
|
180
|
-
if saved_version < CONFIG_VERSION or "20.245.200.125" in str(saved_data.get("base_url", "")):
|
|
192
|
+
if saved_version < CONFIG_VERSION or "test.169pi.ai" in str(saved_data.get("base_url", "")) or "20.245.200.125" in str(saved_data.get("base_url", "")):
|
|
181
193
|
if saved_data.get("n_ctx") == 16384:
|
|
182
194
|
data["n_ctx"] = 32768
|
|
183
|
-
data["base_url"] = "
|
|
184
|
-
data["model"] = "
|
|
195
|
+
data["base_url"] = "http://ec2-18-222-121-38.us-east-2.compute.amazonaws.com:8000/v1"
|
|
196
|
+
data["model"] = "alpie_seed"
|
|
185
197
|
data["model_repo"] = DEFAULT_MODEL_REPO
|
|
186
198
|
data["hf_token"] = DEFAULT_HF_TOKEN
|
|
187
199
|
data["enable_thinking"] = False
|
|
@@ -309,7 +321,7 @@ def interactive_init() -> Config:
|
|
|
309
321
|
if b.is_available:
|
|
310
322
|
print("✅ iOS local engine ready (in-app llama.cpp or local bridge active).")
|
|
311
323
|
else:
|
|
312
|
-
print("ℹ️ iOS Inference: Online model endpoint (
|
|
324
|
+
print(f"ℹ️ iOS Inference: Online model endpoint ({cfg.base_url}) is configured.")
|
|
313
325
|
print(" For offline inference on iOS, launch an in-app bridge (http://127.0.0.1:8080).")
|
|
314
326
|
elif is_android():
|
|
315
327
|
print("\n⚙️ Configuring inference engine for Android...")
|
|
@@ -19,6 +19,12 @@ load_dotenv_if_present()
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
def get_model_cache_dir() -> Path:
|
|
22
|
+
custom = os.environ.get("ALPIECODE_MODELS_DIR")
|
|
23
|
+
if custom:
|
|
24
|
+
return Path(custom)
|
|
25
|
+
home_models = Path.home() / ".alpiecode" / "models"
|
|
26
|
+
if home_models.exists():
|
|
27
|
+
return home_models
|
|
22
28
|
return get_alpiecode_dir() / "models"
|
|
23
29
|
|
|
24
30
|
|
|
@@ -134,19 +140,24 @@ def download_model(repo_id: str = DEFAULT_REPO, token: Optional[str] = None) ->
|
|
|
134
140
|
hf_token = raw_token.strip() if (isinstance(raw_token, str) and raw_token.strip()) else None
|
|
135
141
|
|
|
136
142
|
# ── STEP 1: Check local cache FIRST (zero network) ───────────────
|
|
137
|
-
local_ggufs =
|
|
143
|
+
local_ggufs = [g for g in cache_dir.glob("*.gguf") if not g.name.endswith(".defective.bak")]
|
|
138
144
|
local_main_candidates = [f for f in local_ggufs if "mmproj" not in f.name.lower()]
|
|
139
145
|
local_mmproj_candidates = [f for f in local_ggufs if "mmproj" in f.name.lower()]
|
|
140
146
|
|
|
141
|
-
# Prefer
|
|
142
|
-
|
|
143
|
-
|
|
147
|
+
# Prefer Q3_K_S (fixed GRPO) or Q3_K_M if multiple local models exist
|
|
148
|
+
local_q3_ks = [f for f in local_main_candidates if "q3_k_s" in f.name.lower()]
|
|
149
|
+
local_q3_m = [f for f in local_main_candidates if "q3_k_m" in f.name.lower() or "q3" in f.name.lower()]
|
|
150
|
+
active_local_main = local_q3_ks[0] if local_q3_ks else (local_q3_m[0] if local_q3_m else (local_main_candidates[0] if local_main_candidates else None))
|
|
144
151
|
active_local_mmproj = local_mmproj_candidates[0] if local_mmproj_candidates else None
|
|
145
152
|
|
|
146
|
-
# If BOTH text model and vision projector are
|
|
153
|
+
# If BOTH text model and vision projector are present, return immediately
|
|
147
154
|
if active_local_main and active_local_mmproj:
|
|
148
155
|
return active_local_main
|
|
149
156
|
|
|
157
|
+
# If text model is present and does not require a vision projector (pure text model), return immediately
|
|
158
|
+
if active_local_main and "mmproj" not in repo_id.lower() and not ("vl" in active_local_main.name.lower() or "vl" in repo_id.lower()):
|
|
159
|
+
return active_local_main
|
|
160
|
+
|
|
150
161
|
# ── STEP 2: One or both models missing — download from HuggingFace ────
|
|
151
162
|
try:
|
|
152
163
|
from huggingface_hub import hf_hub_download, list_repo_files
|
|
@@ -550,7 +550,7 @@ class AgentOrchestrator:
|
|
|
550
550
|
yield AgentEvent("error", {
|
|
551
551
|
"error": (
|
|
552
552
|
"Network connection unavailable.\n"
|
|
553
|
-
"On iOS, AlpieCode connects to the cloud server (
|
|
553
|
+
f"On iOS, AlpieCode connects to the cloud server ({cfg.base_url}) by default.\n"
|
|
554
554
|
"To use offline mode on iOS, run an in-app bridge server (http://127.0.0.1:8080)."
|
|
555
555
|
)
|
|
556
556
|
})
|
|
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
|
|
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
|