feat(setup,chat): detect actually-loaded local model via provider-specific API

For Ollama, /api/tags returns all installed models, not running ones.
Add fetch_loaded_models() using /api/ps for Ollama (and /v1/models for
LM Studio/llama.cpp, which already return only loaded models).

_show_local_model_status() now calls fetch_loaded_models() so the
setup wizard correctly shows only in-memory models for Ollama.

At chat session startup, local providers warn when the configured model
is not currently loaded, or when nothing is loaded at all.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
curo1305
2026-05-19 14:46:54 +02:00
parent cb390ad6af
commit 833d1445f0
3 changed files with 77 additions and 4 deletions
+11
View File
@@ -25,6 +25,7 @@ from pyra.plugins.executor import ToolExecutor
from pyra.plugins.registry import PluginRegistry
from pyra.security.injection import scan_response
from pyra.setup.providers import get_provider
from pyra.setup.wizard import fetch_loaded_models
from pyra.utils.paths import pyra_home
_HISTORY_FILE = pyra_home() / ".chat_history"
@@ -176,6 +177,16 @@ def start_chat() -> None:
"[dim]Type /help for commands, /quit to exit.[/dim]"
)
if provider.group == "Local":
loaded = fetch_loaded_models(provider)
if not loaded:
render_info(f"No model currently loaded in {provider.display_name}.")
elif cfg.ai.model not in loaded:
render_info(
f"Model '{cfg.ai.model}' not loaded in {provider.display_name}. "
f"Loaded: {', '.join(loaded)}"
)
_flags: dict = {"use_tools": True}
while True: