feat(tui): auto-correct base URL if required path suffix is missing
Providers that need /v1 (lmstudio, llamacpp, qwen) now declare a url_suffix field. The AI settings save action appends it automatically and notifies the user if they entered a URL without it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -171,6 +171,15 @@ class _AITab(VerticalScroll):
|
||||
base_url = self.query_one("#ai-base-url", Input).value.strip() or None
|
||||
api_key = self.query_one("#ai-key", Input).value.strip()
|
||||
|
||||
if base_url and provider.url_suffix and not base_url.rstrip("/").endswith(provider.url_suffix):
|
||||
base_url = base_url.rstrip("/") + provider.url_suffix
|
||||
self.query_one("#ai-base-url", Input).value = base_url
|
||||
self.app.notify(
|
||||
f"Base URL must end with '{provider.url_suffix}' for {provider.display_name} — corrected automatically.",
|
||||
severity="warning",
|
||||
timeout=6,
|
||||
)
|
||||
|
||||
cfg = load_config()
|
||||
cfg.ai.provider_id = provider_id
|
||||
cfg.ai.model = model
|
||||
|
||||
Reference in New Issue
Block a user