2025-05-11 14:57:52 +00:00
|
|
|
using AIStudio.Tools.PluginSystem;
|
|
|
|
|
|
2024-05-04 08:58:32 +00:00
|
|
|
namespace AIStudio.Provider;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The data model for the model to use.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Id">The model's ID.</param>
|
2024-11-09 21:04:00 +00:00
|
|
|
/// <param name="DisplayName">The model's display name.</param>
|
|
|
|
|
public readonly record struct Model(string Id, string? DisplayName)
|
2024-05-19 14:06:35 +00:00
|
|
|
{
|
2026-01-18 16:15:18 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Special model ID used when the model is selected by the system/host
|
|
|
|
|
/// and cannot be changed by the user (e.g., llama.cpp, whisper.cpp).
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const string SYSTEM_MODEL_ID = "::system::";
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a system-configured model placeholder.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static readonly Model SYSTEM_MODEL = new(SYSTEM_MODEL_ID, null);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Checks if this model is the system-configured placeholder.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsSystemModel => this == SYSTEM_MODEL;
|
|
|
|
|
|
2025-05-11 14:57:52 +00:00
|
|
|
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(Model).Namespace, nameof(Model));
|
|
|
|
|
|
2024-05-19 14:06:35 +00:00
|
|
|
#region Overrides of ValueType
|
|
|
|
|
|
2024-11-09 21:04:00 +00:00
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
if(!string.IsNullOrWhiteSpace(this.DisplayName))
|
|
|
|
|
return this.DisplayName;
|
|
|
|
|
|
|
|
|
|
if(!string.IsNullOrWhiteSpace(this.Id))
|
|
|
|
|
return this.Id;
|
|
|
|
|
|
2025-05-11 14:57:52 +00:00
|
|
|
return TB("no model selected");
|
2024-11-09 21:04:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Implementation of IEquatable<Model?>
|
|
|
|
|
|
|
|
|
|
public bool Equals(Model? other)
|
|
|
|
|
{
|
|
|
|
|
if(other is null)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return this.Id == other.Value.Id;
|
|
|
|
|
}
|
2024-05-19 14:06:35 +00:00
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|