using AIStudio.Chat; using AIStudio.Settings; using Microsoft.JSInterop; using MudBlazor; namespace AIStudio.Provider; /// /// A common interface for all providers. /// public interface IProvider { /// /// The provider's ID. /// public string Id { get; } /// /// The provider's instance name. Useful for multiple instances of the same provider, /// e.g., to distinguish between different OpenAI API keys. /// public string InstanceName { get; set; } /// /// Starts a chat completion stream. /// /// The JS runtime to access the Rust code. /// The settings manager to access the API key. /// The model to use for chat completion. /// The chat thread to continue. /// The cancellation token. /// The chat completion stream. public IAsyncEnumerable StreamChatCompletion(IJSRuntime jsRuntime, SettingsManager settings, Model chatModel, ChatThread chatThread, CancellationToken token = default); /// /// Starts an image completion stream. /// /// The JS runtime to access the Rust code. /// The settings manager to access the API key. /// The model to use for image completion. /// The positive prompt. /// The negative prompt. /// The reference image URL. /// The cancellation token. /// The image completion stream. public IAsyncEnumerable StreamImageCompletion(IJSRuntime jsRuntime, SettingsManager settings, Model imageModel, string promptPositive, string promptNegative = FilterOperator.String.Empty, ImageURL referenceImageURL = default, CancellationToken token = default); /// /// Load all possible text models that can be used with this provider. /// /// The JS runtime to access the Rust code. /// The settings manager to access the API key. /// The cancellation token. /// The list of text models. public Task> GetTextModels(IJSRuntime jsRuntime, SettingsManager settings, CancellationToken token = default); /// /// Load all possible image models that can be used with this provider. /// /// The JS runtime to access the Rust code. /// The settings manager to access the API key. /// The cancellation token. /// The list of image models. public Task> GetImageModels(IJSRuntime jsRuntime, SettingsManager settings, CancellationToken token = default); }