using AIStudio.Provider; namespace AIStudio.Assistants.ModelComparison; /// /// What tells one model apart from another across stored comparisons, see ModelComparisonModelIdentity. /// /// The kind of provider which ran the model. /// The address of the server of a self-hosted model in lowercase, without a trailing slash; empty for every other provider. /// The ID of the model at its provider. public readonly record struct ModelComparisonModelKey(LLMProviders LLMProvider, string Hostname, string ModelId) : IComparable { /// /// Gets the key of a model, with its host written the same way however the user typed it. /// /// The kind of provider which ran the model. /// The address of the server of a self-hosted model, or empty. /// The ID of the model at its provider. /// The key. public static ModelComparisonModelKey Of(LLMProviders llmProvider, string hostname, string modelId) => new(llmProvider, hostname.Trim().TrimEnd('/').ToLowerInvariant(), modelId); /// /// Orders keys the same way on every computer, so that a pair of models is always written in the same order. /// /// The other key. public int CompareTo(ModelComparisonModelKey other) { var byProvider = this.LLMProvider.CompareTo(other.LLMProvider); if (byProvider != 0) return byProvider; var byHost = string.CompareOrdinal(this.Hostname, other.Hostname); return byHost != 0 ? byHost : string.CompareOrdinal(this.ModelId, other.ModelId); } }