mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-05 07: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
@@ -6,7 +6,7 @@ public static class AllowedLLMProvidersExtensions
|
||||
|
||||
extension(AllowedLLMProviders provider)
|
||||
{
|
||||
public string Description() => provider switch
|
||||
public string Description => provider switch
|
||||
{
|
||||
AllowedLLMProviders.NONE => TB("Please select what kind of LLM provider are allowed for this data source"),
|
||||
AllowedLLMProviders.ANY => TB("Any LLM provider is allowed: users might choose a cloud-based or a self-hosted provider"),
|
||||
|
||||
@@ -97,7 +97,7 @@ else
|
||||
@foreach (var language in Enum.GetValues<ProgrammingLanguages>())
|
||||
{
|
||||
<MudSelectItem Value="@language">
|
||||
@language.Name()
|
||||
@language.Name
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
@@ -130,7 +130,7 @@ else
|
||||
@foreach (var dataSource in Enum.GetValues<DataSources>())
|
||||
{
|
||||
<MudSelectItem Value="@dataSource">
|
||||
@dataSource.Name()
|
||||
@dataSource.Name
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
@@ -181,7 +181,7 @@ else
|
||||
@foreach (var authMethod in Enum.GetValues<Auth>())
|
||||
{
|
||||
<MudSelectItemExtended Value="@authMethod">
|
||||
@authMethod.Name()
|
||||
@authMethod.Name
|
||||
</MudSelectItemExtended>
|
||||
}
|
||||
</MudSelectExtended>
|
||||
@@ -194,7 +194,7 @@ else
|
||||
@foreach (var os in Enum.GetValues<OperatingSystem>())
|
||||
{
|
||||
<MudSelectItem Value="@os">
|
||||
@os.Name()
|
||||
@os.Name
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
@@ -208,7 +208,7 @@ else
|
||||
@foreach (var option in Enum.GetValues<AllowedLLMProviders>())
|
||||
{
|
||||
<MudSelectItem Value="@option">
|
||||
@option.Description()
|
||||
@option.Description
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
|
||||
@@ -378,7 +378,7 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
/// <summary>
|
||||
/// Gets whether the selected ERI specification cannot be saved.
|
||||
/// </summary>
|
||||
private bool IsSpecificationSavingDisabled => !this.selectedERIVersion.WasSpecificationSelected() || this.IsERIInputDisabled;
|
||||
private bool IsSpecificationSavingDisabled => !this.selectedERIVersion.WasSpecificationSelected || this.IsERIInputDisabled;
|
||||
|
||||
/// <summary>
|
||||
/// Lets the user save the selected ERI specification, a copy of the one the app carries.
|
||||
@@ -389,7 +389,7 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
|
||||
/// </remarks>
|
||||
private async Task SaveSpecificationAsync()
|
||||
{
|
||||
var specificationPath = this.selectedERIVersion.SpecificationURL();
|
||||
var specificationPath = this.selectedERIVersion.SpecificationURL;
|
||||
var response = await this.RustService.SaveFile(T("Save the ERI specification"), [FileTypes.JSON], Path.GetFileName(specificationPath));
|
||||
if (response.UserCancelled)
|
||||
return;
|
||||
|
||||
@@ -6,7 +6,7 @@ public static class AuthExtensions
|
||||
|
||||
extension(Auth auth)
|
||||
{
|
||||
public string Name() => auth switch
|
||||
public string Name => auth switch
|
||||
{
|
||||
Auth.NONE => TB("No login necessary: useful for public data sources"),
|
||||
|
||||
@@ -17,7 +17,7 @@ public static class AuthExtensions
|
||||
_ => TB("Unknown login method")
|
||||
};
|
||||
|
||||
public string ToPrompt() => auth switch
|
||||
public string Prompt => auth switch
|
||||
{
|
||||
Auth.NONE => "No login is necessary, the data source is public.",
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ public static class DataSourcesExtensions
|
||||
|
||||
extension(DataSources dataSource)
|
||||
{
|
||||
public string Name() => dataSource switch
|
||||
public string Name => dataSource switch
|
||||
{
|
||||
DataSources.NONE => TB("No data source selected"),
|
||||
DataSources.CUSTOM => TB("Custom description"),
|
||||
|
||||
@@ -58,7 +58,7 @@ internal sealed class ERIServerPrompt
|
||||
// Introduction
|
||||
// ---------------------------------
|
||||
//
|
||||
var programmingLanguage = this.ProgrammingLanguage is ProgrammingLanguages.OTHER ? this.OtherProgrammingLanguage : this.ProgrammingLanguage.ToPrompt();
|
||||
var programmingLanguage = this.ProgrammingLanguage is ProgrammingLanguages.OTHER ? this.OtherProgrammingLanguage : this.ProgrammingLanguage.Prompt;
|
||||
sb.Append($"""
|
||||
# Introduction
|
||||
You are an experienced {programmingLanguage} developer. Your task is to implement an API server in
|
||||
@@ -172,7 +172,7 @@ internal sealed class ERIServerPrompt
|
||||
{
|
||||
sb.Append($"""
|
||||
|
||||
- {auth.ToPrompt()}
|
||||
- {auth.Prompt}
|
||||
""");
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ internal sealed class ERIServerPrompt
|
||||
{
|
||||
sb.Append($"""
|
||||
|
||||
The server will run on {this.OperatingSystem.ToPrompt()} operating systems. Keep
|
||||
The server will run on {this.OperatingSystem.Prompt} operating systems. Keep
|
||||
this in mind when implementing the SSO with Kerberos.
|
||||
""");
|
||||
}
|
||||
|
||||
@@ -4,15 +4,18 @@ public static class ERIVersionExtensions
|
||||
{
|
||||
extension(ERIVersion version)
|
||||
{
|
||||
public Task<string> ReadSpecification(WebRootFiles webRootFiles) => webRootFiles.ReadTextAsync(version.SpecificationURL());
|
||||
public Task<string> ReadSpecification(WebRootFiles webRootFiles) => webRootFiles.ReadTextAsync(version.SpecificationURL);
|
||||
|
||||
public string SpecificationURL()
|
||||
public string SpecificationURL
|
||||
{
|
||||
var nameLower = version.ToString().ToLowerInvariant();
|
||||
var filename = $"{nameLower}.json";
|
||||
return $"specs/eri/{filename}";
|
||||
get
|
||||
{
|
||||
var nameLower = version.ToString().ToLowerInvariant();
|
||||
var filename = $"{nameLower}.json";
|
||||
return $"specs/eri/{filename}";
|
||||
}
|
||||
}
|
||||
|
||||
public bool WasSpecificationSelected() => version != ERIVersion.NONE;
|
||||
public bool WasSpecificationSelected => version != ERIVersion.NONE;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ public static class OperatingSystemExtensions
|
||||
|
||||
extension(OperatingSystem os)
|
||||
{
|
||||
public string Name() => os switch
|
||||
public string Name => os switch
|
||||
{
|
||||
OperatingSystem.NONE => TB("No operating system specified"),
|
||||
|
||||
@@ -16,7 +16,7 @@ public static class OperatingSystemExtensions
|
||||
_ => TB("Unknown operating system")
|
||||
};
|
||||
|
||||
public string ToPrompt() => os switch
|
||||
public string Prompt => os switch
|
||||
{
|
||||
OperatingSystem.NONE => "No operating system specified",
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ public static class ProgrammingLanguagesExtensions
|
||||
|
||||
extension(ProgrammingLanguages language)
|
||||
{
|
||||
public string Name() => language switch
|
||||
public string Name => language switch
|
||||
{
|
||||
ProgrammingLanguages.NONE => TB("No programming language selected"),
|
||||
|
||||
@@ -26,7 +26,7 @@ public static class ProgrammingLanguagesExtensions
|
||||
_ => TB("Unknown")
|
||||
};
|
||||
|
||||
public string ToPrompt() => language switch
|
||||
public string Prompt => language switch
|
||||
{
|
||||
ProgrammingLanguages.NONE => "No programming language selected",
|
||||
|
||||
|
||||
Reference in new issue
Block a user