mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-08-24 20:52:11 +00:00
Added an interface for user-provided API keys of managed objects
This commit is contained in:
parent
0461222fae
commit
bd20e2729f
@ -36,7 +36,7 @@ public sealed record Provider(
|
|||||||
HFInferenceProvider HFInferenceProvider = HFInferenceProvider.NONE,
|
HFInferenceProvider HFInferenceProvider = HFInferenceProvider.NONE,
|
||||||
string AdditionalJsonApiParameters = "",
|
string AdditionalJsonApiParameters = "",
|
||||||
ProviderCapabilityOverrides? CapabilityOverrides = null,
|
ProviderCapabilityOverrides? CapabilityOverrides = null,
|
||||||
bool AllowUserProvidedAPIKey = false) : ConfigurationBaseObject, ISecretId
|
bool AllowUserProvidedAPIKey = false) : ConfigurationBaseObject, ISecretId, IUserProvidedAPIKey
|
||||||
{
|
{
|
||||||
private static readonly ILogger<Provider> LOGGER = Program.LOGGER_FACTORY.CreateLogger<Provider>();
|
private static readonly ILogger<Provider> LOGGER = Program.LOGGER_FACTORY.CreateLogger<Provider>();
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,15 @@
|
|||||||
|
namespace AIStudio.Tools.PluginSystem;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a configuration object whose API key is managed by the user, although the object
|
||||||
|
/// itself is managed by a configuration plugin. Implemented by all provider kinds which support
|
||||||
|
/// the "AllowUserProvidedAPIKey" option, i.e., LLM, embedding, and transcription providers.
|
||||||
|
/// </summary>
|
||||||
|
public interface IUserProvidedAPIKey
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// When set by a configuration plugin, the user may set their own API key for this otherwise
|
||||||
|
/// locked, enterprise-managed object.
|
||||||
|
/// </summary>
|
||||||
|
public bool AllowUserProvidedAPIKey { get; }
|
||||||
|
}
|
||||||
@ -407,7 +407,7 @@ public sealed record PluginConfigurationObject
|
|||||||
else
|
else
|
||||||
LOG.LogWarning($"Failed to delete secret for removed enterprise object '{item.Name}' from the OS keyring: {deleteResult.Issue}");
|
LOG.LogWarning($"Failed to delete secret for removed enterprise object '{item.Name}' from the OS keyring: {deleteResult.Issue}");
|
||||||
}
|
}
|
||||||
else if(item is Settings.Provider { AllowUserProvidedAPIKey: true })
|
else if(item is IUserProvidedAPIKey { AllowUserProvidedAPIKey: true })
|
||||||
{
|
{
|
||||||
// The user manages their own key for this provider. Keep it in the OS keyring
|
// The user manages their own key for this provider. Keep it in the OS keyring
|
||||||
// in case the organization's configuration comes back later, instead of forcing
|
// in case the organization's configuration comes back later, instead of forcing
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user