2024-04-19 19:25:44 +00:00
using AIStudio.Provider ;
2024-07-16 08:28:13 +00:00
using Host = AIStudio . Provider . SelfHosted . Host ;
2024-04-19 19:25:44 +00:00
namespace AIStudio.Settings ;
2024-05-04 08:55:00 +00:00
/// <summary>
/// Data model for configured providers.
/// </summary>
2024-05-19 18:28:25 +00:00
/// <param name="Num">The provider's number.</param>
2024-05-04 08:55:00 +00:00
/// <param name="Id">The provider's ID.</param>
/// <param name="InstanceName">The provider's instance name. Useful for multiple instances of the same provider, e.g., to distinguish between different OpenAI API keys.</param>
/// <param name="UsedProvider">The provider used.</param>
2024-07-03 18:31:04 +00:00
/// <param name="IsSelfHosted">Whether the provider is self-hosted.</param>
/// <param name="Hostname">The hostname of the provider. Useful for self-hosted providers.</param>
2024-05-19 14:10:37 +00:00
/// <param name="Model">The LLM model to use for chat.</param>
2024-07-16 08:28:13 +00:00
public readonly record struct Provider (
uint Num ,
string Id ,
string InstanceName ,
Providers UsedProvider ,
Model Model ,
bool IsSelfHosted = false ,
string Hostname = "http://localhost:1234" ,
Host Host = Host . NONE )
2024-05-04 08:55:00 +00:00
{
#region Overrides of ValueType
/// <summary>
/// Returns a string that represents the current provider in a human-readable format.
/// We use this to display the provider in the chat UI.
/// </summary>
/// <returns>A string that represents the current provider in a human-readable format.</returns>
public override string ToString ( )
{
2024-07-03 18:31:04 +00:00
if ( this . IsSelfHosted )
2024-07-16 08:28:13 +00:00
return $"{this.InstanceName} ({this.UsedProvider.ToName()}, {this.Host}, {this.Hostname}, {this.Model})" ;
2024-07-03 18:31:04 +00:00
2024-05-19 14:10:57 +00:00
return $"{this.InstanceName} ({this.UsedProvider.ToName()}, {this.Model})" ;
2024-05-04 08:55:00 +00:00
}
#endregion
}