mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-05 02:27:21 +00:00
Turned getter-like extension methods into extension properties (#1157)
This commit is contained in:
1 parent
0375318b1b
commit
f649febf88
286 files changed
+1379
-1109
No files matched your search
@@ -153,12 +153,12 @@ public sealed class AgentDataSourceSelection (ILogger<AgentDataSourceSelection>
|
||||
|
||||
if (!agentProvider.AllowsDataSourceAccess(this.SettingsManager, requiredDataSecurity, requiredConfidenceLevel))
|
||||
{
|
||||
logger.LogWarning($"The agent for data source selection uses provider '{agentProvider.InstanceName}' with confidence '{agentProvider.GetConfidenceLevel(this.SettingsManager).GetName()}', but the available data sources require data security '{requiredDataSecurity}' and provider confidence '{requiredConfidenceLevel.GetName()}'. The agent cannot select data sources.");
|
||||
logger.LogWarning($"The agent for data source selection uses provider '{agentProvider.InstanceName}' with confidence '{agentProvider.GetConfidenceLevel(this.SettingsManager).Name}', but the available data sources require data security '{requiredDataSecurity}' and provider confidence '{requiredConfidenceLevel.Name}'. The agent cannot select data sources.");
|
||||
return [];
|
||||
}
|
||||
|
||||
// Assign the provider settings to the agent:
|
||||
logger.LogInformation($"The agent for the data source selection uses the provider '{agentProvider.InstanceName}' ({agentProvider.UsedLLMProvider.ToName()}, confidence={agentProvider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level.GetName()}).");
|
||||
logger.LogInformation($"The agent for the data source selection uses the provider '{agentProvider.InstanceName}' ({agentProvider.UsedLLMProvider.Name}, confidence={agentProvider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level.Name}).");
|
||||
this.ProviderSettings = agentProvider;
|
||||
|
||||
//
|
||||
|
||||
@@ -148,13 +148,13 @@ public sealed class AgentRetrievalContextValidation (ILogger<AgentRetrievalConte
|
||||
|
||||
if (!agentProvider.AllowsDataSourceAccess(this.SettingsManager, requiredDataSecurity, requiredConfidenceLevel))
|
||||
{
|
||||
logger.LogWarning($"The agent for retrieval context validation uses provider '{agentProvider.InstanceName}' with confidence '{agentProvider.GetConfidenceLevel(this.SettingsManager).GetName()}', but the retrieved data requires data security '{requiredDataSecurity}' and provider confidence '{requiredConfidenceLevel.GetName()}'. The agent cannot validate retrieval contexts.");
|
||||
logger.LogWarning($"The agent for retrieval context validation uses provider '{agentProvider.InstanceName}' with confidence '{agentProvider.GetConfidenceLevel(this.SettingsManager).Name}', but the retrieved data requires data security '{requiredDataSecurity}' and provider confidence '{requiredConfidenceLevel.Name}'. The agent cannot validate retrieval contexts.");
|
||||
this.ProviderSettings = Settings.Provider.NONE;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Assign the provider settings to the agent:
|
||||
logger.LogInformation($"The agent for the retrieval context validation uses the provider '{agentProvider.InstanceName}' ({agentProvider.UsedLLMProvider.ToName()}, confidence={agentProvider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level.GetName()}).");
|
||||
logger.LogInformation($"The agent for the retrieval context validation uses the provider '{agentProvider.InstanceName}' ({agentProvider.UsedLLMProvider.Name}, confidence={agentProvider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level.Name}).");
|
||||
this.ProviderSettings = agentProvider;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ public sealed class AssistantAuditAgent(ILogger<AssistantAuditAgent> logger, ILo
|
||||
};
|
||||
}
|
||||
|
||||
logger.LogInformation($"The assistant plugin audit agent uses the provider '{provider.InstanceName}' ({provider.UsedLLMProvider.ToName()}, confidence={provider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level.GetName()}).");
|
||||
logger.LogInformation($"The assistant plugin audit agent uses the provider '{provider.InstanceName}' ({provider.UsedLLMProvider.Name}, confidence={provider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level.Name}).");
|
||||
|
||||
var promptPreview = await plugin.BuildAuditPromptPreviewAsync(token);
|
||||
var promptFallbackPreview = plugin.BuildAuditPromptFallbackPreview();
|
||||
@@ -288,7 +288,7 @@ public sealed class AssistantAuditAgent(ILogger<AssistantAuditAgent> logger, ILo
|
||||
private static AssistantAuditResult NormalizeResult(AssistantAuditResult result)
|
||||
{
|
||||
var normalizedFindings = result.Findings;
|
||||
var parsedLevel = AssistantAuditLevelExtensions.Parse(result.Level);
|
||||
var parsedLevel = AssistantAuditLevel.ParseOrUnknown(result.Level);
|
||||
var lowestFindingLevel = GetMostSevereFindingLevel(normalizedFindings);
|
||||
if (lowestFindingLevel != AssistantAuditLevel.UNKNOWN && (parsedLevel == AssistantAuditLevel.UNKNOWN || lowestFindingLevel < parsedLevel))
|
||||
parsedLevel = lowestFindingLevel;
|
||||
|
||||
@@ -8,7 +8,7 @@ public static class AssistantAuditLevelExtensions
|
||||
|
||||
extension(AssistantAuditLevel level)
|
||||
{
|
||||
public string GetName() => level switch
|
||||
public string Name => level switch
|
||||
{
|
||||
AssistantAuditLevel.DANGEROUS => TB("Dangerous"),
|
||||
AssistantAuditLevel.CAUTION => TB("Concerning"),
|
||||
@@ -16,7 +16,7 @@ public static class AssistantAuditLevelExtensions
|
||||
_ => TB("Unknown"),
|
||||
};
|
||||
|
||||
public Severity GetSeverity() => level switch
|
||||
public Severity Severity => level switch
|
||||
{
|
||||
AssistantAuditLevel.DANGEROUS => Severity.Error,
|
||||
AssistantAuditLevel.CAUTION => Severity.Warning,
|
||||
@@ -24,7 +24,7 @@ public static class AssistantAuditLevelExtensions
|
||||
_ => Severity.Info,
|
||||
};
|
||||
|
||||
public Color GetColor() => level switch
|
||||
public Color Color => level switch
|
||||
{
|
||||
AssistantAuditLevel.DANGEROUS => Color.Error,
|
||||
AssistantAuditLevel.CAUTION => Color.Warning,
|
||||
@@ -32,19 +32,19 @@ public static class AssistantAuditLevelExtensions
|
||||
_ => Color.Default,
|
||||
};
|
||||
|
||||
public string GetIcon() => level switch
|
||||
public string Icon => level switch
|
||||
{
|
||||
AssistantAuditLevel.DANGEROUS => Icons.Material.Filled.Dangerous,
|
||||
AssistantAuditLevel.CAUTION => Icons.Material.Filled.Warning,
|
||||
AssistantAuditLevel.SAFE => Icons.Material.Filled.Verified,
|
||||
_ => Icons.Material.Filled.HelpOutline,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses an audit level string and falls back to <see cref="AssistantAuditLevel.UNKNOWN"/> when parsing fails.
|
||||
/// </summary>
|
||||
/// <param name="value">The audit level text to parse.</param>
|
||||
/// <returns>The parsed audit level, or <see cref="AssistantAuditLevel.UNKNOWN"/> for null, empty, or invalid values.</returns>
|
||||
public static AssistantAuditLevel Parse(string? value) => Enum.TryParse<AssistantAuditLevel>(value, true, out var level) ? level : AssistantAuditLevel.UNKNOWN;
|
||||
/// <summary>
|
||||
/// Parses an audit level string and falls back to <see cref="AssistantAuditLevel.UNKNOWN"/> when parsing fails.
|
||||
/// </summary>
|
||||
/// <param name="value">The audit level text to parse.</param>
|
||||
/// <returns>The parsed audit level, or <see cref="AssistantAuditLevel.UNKNOWN"/> for null, empty, or invalid values.</returns>
|
||||
public static AssistantAuditLevel ParseOrUnknown(string? value) => Enum.TryParse<AssistantAuditLevel>(value, true, out var parsedLevel) ? parsedLevel : AssistantAuditLevel.UNKNOWN;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user