Added a home page prompt for missing API keys of enterprise providers (#1056)

Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
Dominic NeuburgandThorsten Sommer authored and GitHub committed 2026-10-19 09:12:12 +02:00
1 parent 1f8d72aa45
commit 7d35536c87
29 files changed
+920 -31

No files matched your search

@@ -18,6 +18,7 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
private List<DataMandatoryInfo> mandatoryInfos = [];
private List<DataIntroduction> introductions = [];
private List<DataMailboxProvider> mailboxProviders = [];
private List<DataUserAPIKeyPrompt> userAPIKeyPrompts = [];
/// <summary>
/// The list of configuration objects. Configuration objects are, e.g., providers or chat templates.
@@ -42,6 +43,12 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
/// </summary>
public IReadOnlyList<DataMailboxProvider> MailboxProviders => this.mailboxProviders;
/// <summary>
/// What this configuration plugin tells the user while AI Studio asks for the API key of its providers;
/// at most one entry. The prompt is live plugin content and is not persisted to ConfigurationData.
/// </summary>
public IReadOnlyList<DataUserAPIKeyPrompt> UserAPIKeyPrompts => this.userAPIKeyPrompts;
/// <summary>
/// True/false when explicitly configured in the plugin, otherwise null.
/// </summary>
@@ -204,6 +211,7 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
this.mandatoryInfos.Clear();
this.introductions.Clear();
this.mailboxProviders.Clear();
this.userAPIKeyPrompts.Clear();
// Ensure that the main CONFIG table exists and is a valid Lua table:
if (!this.State.Environment["CONFIG"].TryRead<LuaTable>(out var mainTable))
@@ -400,6 +408,9 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
// Handle configured mail servers:
this.TryReadMailboxProviders(mainTable);
// Handle the configured prompt for the API key of the user:
this.TryReadUserAPIKeyPrompt(mainTable);
// Config: preselected provider?
ManagedConfiguration.TryProcessConfiguration(x => x.App, x => x.PreselectedProvider, Guid.Empty, this.Id, settingsTable, dryRun);
@@ -872,4 +883,13 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
LOG.LogWarning("The table 'MAILBOX_PROVIDERS' entry at index {Index} does not contain a valid mail server (config plugin id: {ConfigPluginId}).", i, this.Id);
}
}
private void TryReadUserAPIKeyPrompt(LuaTable mainTable)
{
if (!mainTable.TryGetValue("USER_API_KEY_PROMPT", out var promptValue) || !promptValue.TryRead<LuaTable>(out var promptTable))
return;
if (DataUserAPIKeyPrompt.TryParseConfiguration(promptTable, this.Id, out var prompt))
this.userAPIKeyPrompts.Add(prompt);
}
}