Added documentation

This commit is contained in:
tsommer committed 2024-05-04 10:55:00 +02:00
1 parent 0859b1f2ec
commit 418f458118
11 files changed
+162 -3

No files matched your search

@@ -3,10 +3,20 @@ using Microsoft.JSInterop;
namespace AIStudio.Provider;
/// <summary>
/// A common interface for all providers.
/// </summary>
public interface IProvider
{
/// <summary>
/// The provider's ID.
/// </summary>
public string Id { get; }
/// <summary>
/// The provider's instance name. Useful for multiple instances of the same provider,
/// e.g., to distinguish between different OpenAI API keys.
/// </summary>
public string InstanceName { get; set; }
public IAsyncEnumerable<string> GetChatCompletion(IJSRuntime jsRuntime, SettingsManager settings, Model chatModel, Thread chatThread);
@@ -2,14 +2,25 @@ using AIStudio.Provider.OpenAI;
namespace AIStudio.Provider;
/// <summary>
/// Enum for all available providers.
/// </summary>
public enum Providers
{
NONE,
OPEN_AI,
}
/// <summary>
/// Extension methods for the provider enum.
/// </summary>
public static class ExtensionsProvider
{
/// <summary>
/// Returns the human-readable name of the provider.
/// </summary>
/// <param name="provider">The provider.</param>
/// <returns>The human-readable name of the provider.</returns>
public static string ToName(this Providers provider) => provider switch
{
Providers.OPEN_AI => "OpenAI",
@@ -17,6 +28,11 @@ public static class ExtensionsProvider
_ => "Unknown",
};
/// <summary>
/// Creates a new provider instance based on the provider value.
/// </summary>
/// <param name="provider">The provider value.</param>
/// <returns>The provider instance.</returns>
public static IProvider CreateProvider(this Providers provider) => provider switch
{
Providers.OPEN_AI => new ProviderOpenAI(),