codegpt-ai 1.4.0 → 1.5.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 +37 -34
- package/package.json +1 -1
package/chat.py
CHANGED
|
@@ -4186,39 +4186,7 @@ def main():
|
|
|
4186
4186
|
available_models = models
|
|
4187
4187
|
break
|
|
4188
4188
|
|
|
4189
|
-
# Try 4:
|
|
4190
|
-
if not available_models:
|
|
4191
|
-
clear_screen()
|
|
4192
|
-
console.print(Panel(
|
|
4193
|
-
Text.from_markup(
|
|
4194
|
-
"[bold yellow]No AI backend found.[/]\n\n"
|
|
4195
|
-
" [bold]Options:[/]\n"
|
|
4196
|
-
" 1. Enter your PC's Ollama URL below\n"
|
|
4197
|
-
" 2. Press Enter to start offline (commands still work)\n"
|
|
4198
|
-
" 3. Install Ollama: [bright_cyan]https://ollama.com[/]\n"
|
|
4199
|
-
),
|
|
4200
|
-
title="[bold yellow]Setup[/]",
|
|
4201
|
-
border_style="yellow", padding=(1, 2),
|
|
4202
|
-
))
|
|
4203
|
-
try:
|
|
4204
|
-
remote = prompt([("class:prompt", " Ollama URL (or Enter to skip) > ")], style=input_style).strip()
|
|
4205
|
-
if remote:
|
|
4206
|
-
if not remote.startswith("http"):
|
|
4207
|
-
remote = "http://" + remote
|
|
4208
|
-
OLLAMA_URL = remote if "/api/chat" in remote else f"{remote.rstrip('/')}/api/chat"
|
|
4209
|
-
available_models = try_connect(OLLAMA_URL)
|
|
4210
|
-
if available_models:
|
|
4211
|
-
console.print(Panel(Text(f"Connected: {OLLAMA_URL}", style="green"), border_style="green"))
|
|
4212
|
-
# Save for next time
|
|
4213
|
-
config_file = Path.home() / ".codegpt" / "ollama_url"
|
|
4214
|
-
config_file.parent.mkdir(parents=True, exist_ok=True)
|
|
4215
|
-
config_file.write_text(OLLAMA_URL)
|
|
4216
|
-
else:
|
|
4217
|
-
print_sys("Cannot reach that URL. Starting offline.")
|
|
4218
|
-
except (KeyboardInterrupt, EOFError):
|
|
4219
|
-
pass
|
|
4220
|
-
|
|
4221
|
-
# Try 5: Load saved URL from last session
|
|
4189
|
+
# Try 4: Load saved URL from last session
|
|
4222
4190
|
if not available_models:
|
|
4223
4191
|
saved_url = Path.home() / ".codegpt" / "ollama_url"
|
|
4224
4192
|
if saved_url.exists():
|
|
@@ -4232,6 +4200,9 @@ def main():
|
|
|
4232
4200
|
# Always continue — offline mode if no backend
|
|
4233
4201
|
if not available_models:
|
|
4234
4202
|
available_models = [MODEL] # Use default model name as placeholder
|
|
4203
|
+
offline_mode = True
|
|
4204
|
+
else:
|
|
4205
|
+
offline_mode = False
|
|
4235
4206
|
|
|
4236
4207
|
# Load profile
|
|
4237
4208
|
profile = load_profile()
|
|
@@ -4250,10 +4221,42 @@ def main():
|
|
|
4250
4221
|
system = PERSONAS.get(persona_name, SYSTEM_PROMPT)
|
|
4251
4222
|
|
|
4252
4223
|
print_header(model)
|
|
4253
|
-
|
|
4224
|
+
|
|
4225
|
+
# Welcome popup
|
|
4226
|
+
if first_time:
|
|
4227
|
+
pass # Setup wizard already shown
|
|
4228
|
+
elif offline_mode:
|
|
4229
|
+
w = tw()
|
|
4230
|
+
compact = is_compact()
|
|
4231
|
+
name = profile.get("name", "User")
|
|
4232
|
+
|
|
4233
|
+
if compact:
|
|
4234
|
+
console.print(Panel(
|
|
4235
|
+
Text.from_markup(
|
|
4236
|
+
f"[bold]Hey {name}![/]\n\n"
|
|
4237
|
+
f" [dim]Offline mode[/]\n"
|
|
4238
|
+
f" [dim]Use /connect IP[/]\n"
|
|
4239
|
+
f" [dim]to link your PC[/]\n"
|
|
4240
|
+
),
|
|
4241
|
+
title="[bold bright_cyan]Welcome[/]",
|
|
4242
|
+
border_style="bright_cyan", padding=(0, 1), width=w,
|
|
4243
|
+
))
|
|
4244
|
+
else:
|
|
4245
|
+
console.print(Panel(
|
|
4246
|
+
Text.from_markup(
|
|
4247
|
+
f"[bold]Welcome back, {name}![/]\n\n"
|
|
4248
|
+
f" Status: [yellow]offline[/] — no Ollama found\n"
|
|
4249
|
+
f" Fix: [bright_cyan]/connect YOUR_PC_IP[/]\n\n"
|
|
4250
|
+
f" [dim]All commands work. AI responses need a connection.[/]"
|
|
4251
|
+
),
|
|
4252
|
+
title="[bold bright_cyan]Welcome[/]",
|
|
4253
|
+
border_style="bright_cyan", padding=(1, 2), width=w,
|
|
4254
|
+
))
|
|
4255
|
+
else:
|
|
4254
4256
|
name = profile.get("name", "")
|
|
4255
4257
|
if name:
|
|
4256
4258
|
console.print(Align.center(Text(f"Welcome back, {name}.\n", style="bold white")), width=tw())
|
|
4259
|
+
|
|
4257
4260
|
print_welcome(model, available_models)
|
|
4258
4261
|
|
|
4259
4262
|
while True:
|