From bbb9d883a1192afc129dc40ed0f60a89d8f80be9 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sat, 4 May 2024 10:58:18 +0200 Subject: [PATCH] Refined provider interface --- app/MindWork AI Studio/Provider/IProvider.cs | 45 +++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/app/MindWork AI Studio/Provider/IProvider.cs b/app/MindWork AI Studio/Provider/IProvider.cs index 38b90ef..15403bf 100644 --- a/app/MindWork AI Studio/Provider/IProvider.cs +++ b/app/MindWork AI Studio/Provider/IProvider.cs @@ -1,6 +1,9 @@ +using AIStudio.Chat; using AIStudio.Settings; using Microsoft.JSInterop; +using MudBlazor; + namespace AIStudio.Provider; /// @@ -19,7 +22,45 @@ public interface IProvider /// public string InstanceName { get; set; } - public IAsyncEnumerable GetChatCompletion(IJSRuntime jsRuntime, SettingsManager settings, Model chatModel, Thread chatThread); + /// + /// 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); - public Task> GetModels(IJSRuntime jsRuntime, SettingsManager settings); + /// + /// 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); } \ No newline at end of file