AI-Studio/app/MindWork AI Studio/Settings/Provider.cs

33 lines
1.5 KiB
C#
Raw Normal View History

2024-04-19 19:25:44 +00:00
using AIStudio.Provider;
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>
/// <param name="IsSelfHosted">Whether the provider is self-hosted.</param>
/// <param name="Hostname">The hostname of the provider. Useful for self-hosted providers.</param>
/// <param name="Model">The LLM model to use for chat.</param>
public readonly record struct Provider(uint Num, string Id, string InstanceName, Providers UsedProvider, Model Model, bool IsSelfHosted = false, string Hostname = "http://localhost:1234")
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()
{
if(this.IsSelfHosted)
return $"{this.InstanceName} ({this.UsedProvider.ToName()}, {this.Hostname}, {this.Model})";
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
}