fix(ai): persistence and command-output fixes
- Persist per-provider default model in [ai] prefs (set/get/remove helpers, load on init, clear with provider removal). Previously /ai set default-model only updated runtime state. - Stop re-seeding openai/perplexity into [ai] every time the configured provider list is empty. The defaults are now seeded once, guarded by a "defaults_initialized" sentinel, so removing every provider does not silently restore them. - /ai providers (no arg) now lists the configured providers with key status, instead of the hardcoded openai/perplexity blurb. - /ai models <provider> (fresh fetch) prints the model names it cached, not just a count. Previously the user had to follow up with --cached to actually see them. - /ai remove provider now also clears the persisted default model, token, and cached model list, leaving no orphan keys in [ai]. - Drop dead ai_models_find declaration from ai_client.h (no implementation in this tree).
This commit is contained in:
@@ -11174,30 +11174,24 @@ cmd_ai_clear(ProfWin* window, const char* const command, gchar** args)
|
||||
gboolean
|
||||
cmd_ai_providers(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
if (args[1] == NULL || g_strcmp0(args[1], "list") != 0) {
|
||||
// List all available providers
|
||||
cons_show("Available AI providers:");
|
||||
cons_show("");
|
||||
cons_show(" openai - OpenAI API (https://api.openai.com)");
|
||||
cons_show(" perplexity - Perplexity API (https://api.perplexity.ai)");
|
||||
cons_show("");
|
||||
cons_show("Add custom providers with: /ai set provider <name> <url>");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// List configured providers with key status
|
||||
cons_show("Configured providers:");
|
||||
cons_show("");
|
||||
|
||||
GList* providers = ai_list_providers();
|
||||
if (!providers) {
|
||||
cons_show(" (none configured)");
|
||||
cons_show("");
|
||||
cons_show("Add a provider with: /ai set provider <name> <url>");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for (GList* curr = providers; curr; curr = g_list_next(curr)) {
|
||||
AIProvider* provider = curr->data;
|
||||
gchar* key = ai_get_provider_key(provider->name);
|
||||
auto_gchar gchar* key = ai_get_provider_key(provider->name);
|
||||
cons_show(" %s", provider->name);
|
||||
cons_show(" URL: %s", provider->api_url);
|
||||
cons_show(" Key: %s", key ? "configured" : "NOT configured");
|
||||
cons_show("");
|
||||
g_free(key);
|
||||
}
|
||||
g_list_free(providers);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user