using AIStudio.Tools.PluginSystem;
namespace AIStudio.Provider;
///
/// The data model for the model to use.
///
/// The model's ID.
/// The model's display name.
public readonly record struct Model(string Id, string? DisplayName)
{
///
/// 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).
///
private const string SYSTEM_MODEL_ID = "::system::";
///
/// Creates a system-configured model placeholder.
///
public static readonly Model SYSTEM_MODEL = new(SYSTEM_MODEL_ID, null);
///
/// Checks if this model is the system-configured placeholder.
///
public bool IsSystemModel => this == SYSTEM_MODEL;
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(Model).Namespace, nameof(Model));
#region Overrides of ValueType
public override string ToString()
{
if(!string.IsNullOrWhiteSpace(this.DisplayName))
return this.DisplayName;
if(!string.IsNullOrWhiteSpace(this.Id))
return this.Id;
return TB("no model selected");
}
#endregion
#region Implementation of IEquatable
public bool Equals(Model? other)
{
if(other is null)
return false;
return this.Id == other.Value.Id;
}
#endregion
}