codegpt-ai 2.18.0 → 2.26.0
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.
- package/chat.py +50 -5
- package/desktop.py +642 -177
- package/package.json +2 -1
- package/tui.py +436 -0
package/chat.py
CHANGED
|
@@ -5009,14 +5009,35 @@ def main():
|
|
|
5009
5009
|
except Exception:
|
|
5010
5010
|
pass
|
|
5011
5011
|
|
|
5012
|
-
# Try 3: Check common remote addresses
|
|
5012
|
+
# Try 3: Check common remote addresses + subnet scan
|
|
5013
5013
|
if not available_models:
|
|
5014
|
-
|
|
5015
|
-
|
|
5014
|
+
scan_ips = ["192.168.1.237", "10.0.2.2", "192.168.1.1", "192.168.0.1",
|
|
5015
|
+
"192.168.1.100", "192.168.1.50", "192.168.0.100"]
|
|
5016
|
+
# Add subnet scan
|
|
5017
|
+
try:
|
|
5018
|
+
import socket as _sock
|
|
5019
|
+
_s = _sock.socket(_sock.AF_INET, _sock.SOCK_DGRAM)
|
|
5020
|
+
_s.connect(("8.8.8.8", 80))
|
|
5021
|
+
_my_ip = _s.getsockname()[0]
|
|
5022
|
+
_s.close()
|
|
5023
|
+
_subnet = ".".join(_my_ip.split(".")[:3])
|
|
5024
|
+
for _last in range(1, 20):
|
|
5025
|
+
_ip = f"{_subnet}.{_last}"
|
|
5026
|
+
if _ip not in scan_ips:
|
|
5027
|
+
scan_ips.append(_ip)
|
|
5028
|
+
except Exception:
|
|
5029
|
+
pass
|
|
5030
|
+
|
|
5031
|
+
for ip in scan_ips:
|
|
5032
|
+
remote = f"http://{ip}:11434/api/chat"
|
|
5016
5033
|
models = try_connect(remote)
|
|
5017
5034
|
if models:
|
|
5018
5035
|
OLLAMA_URL = remote
|
|
5019
5036
|
available_models = models
|
|
5037
|
+
# Save for next time
|
|
5038
|
+
config_file = Path.home() / ".codegpt" / "ollama_url"
|
|
5039
|
+
config_file.parent.mkdir(parents=True, exist_ok=True)
|
|
5040
|
+
config_file.write_text(OLLAMA_URL)
|
|
5020
5041
|
break
|
|
5021
5042
|
|
|
5022
5043
|
# Try 4: Load saved URL from last session
|
|
@@ -7171,6 +7192,30 @@ def main():
|
|
|
7171
7192
|
continue
|
|
7172
7193
|
|
|
7173
7194
|
elif cmd == "/desktop":
|
|
7195
|
+
# Termux — launch TUI version instead of GUI
|
|
7196
|
+
if os.path.exists("/data/data/com.termux"):
|
|
7197
|
+
print_sys("Launching TUI mode (terminal desktop)...")
|
|
7198
|
+
tui_paths = [
|
|
7199
|
+
os.path.join(str(Path(__file__).parent), "tui.py"),
|
|
7200
|
+
os.path.join(str(Path.home()), "codegpt", "tui.py"),
|
|
7201
|
+
]
|
|
7202
|
+
tui_py = None
|
|
7203
|
+
for tp in tui_paths:
|
|
7204
|
+
if os.path.isfile(tp):
|
|
7205
|
+
tui_py = tp
|
|
7206
|
+
break
|
|
7207
|
+
if not tui_py:
|
|
7208
|
+
try:
|
|
7209
|
+
tui_py = os.path.join(str(Path.home()), ".codegpt", "tui.py")
|
|
7210
|
+
r = requests.get("https://raw.githubusercontent.com/CCguvycu/codegpt/master/tui.py", timeout=15)
|
|
7211
|
+
Path(tui_py).parent.mkdir(parents=True, exist_ok=True)
|
|
7212
|
+
Path(tui_py).write_text(r.text, encoding="utf-8")
|
|
7213
|
+
except Exception:
|
|
7214
|
+
print_err("Cannot download TUI. Use the CLI instead.")
|
|
7215
|
+
continue
|
|
7216
|
+
subprocess.run([sys.executable, tui_py])
|
|
7217
|
+
print_header(model)
|
|
7218
|
+
continue
|
|
7174
7219
|
# Find desktop.py — check multiple locations
|
|
7175
7220
|
desktop_paths = [
|
|
7176
7221
|
os.path.join(str(Path(__file__).parent), "desktop.py"),
|
|
@@ -7198,8 +7243,8 @@ def main():
|
|
|
7198
7243
|
|
|
7199
7244
|
# Install pywebview if needed
|
|
7200
7245
|
try:
|
|
7201
|
-
import webview
|
|
7202
|
-
except ImportError:
|
|
7246
|
+
import webview # noqa
|
|
7247
|
+
except (ImportError, Exception):
|
|
7203
7248
|
print_sys("Installing pywebview...")
|
|
7204
7249
|
subprocess.run(
|
|
7205
7250
|
[sys.executable, "-m", "pip", "install", "pywebview"],
|