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

66 lines
3.3 KiB
C#
Raw Permalink Normal View History

2024-05-04 08:58:18 +00:00
using AIStudio.Chat;
using AIStudio.Settings;
2024-05-04 08:58:18 +00:00
2024-04-20 15:06:50 +00:00
namespace AIStudio.Provider;
2024-05-04 08:55:00 +00:00
/// <summary>
/// A common interface for all providers.
/// </summary>
2024-04-20 15:06:50 +00:00
public interface IProvider
{
2024-05-04 08:55:00 +00:00
/// <summary>
/// The provider's ID.
/// </summary>
2024-04-20 15:06:50 +00:00
public string Id { get; }
2024-05-04 08:55:00 +00:00
/// <summary>
/// The provider's instance name. Useful for multiple instances of the same provider,
/// e.g., to distinguish between different OpenAI API keys.
/// </summary>
2024-12-03 14:24:40 +00:00
public string InstanceName { get; }
2024-04-20 15:06:50 +00:00
2024-05-04 08:58:18 +00:00
/// <summary>
/// Starts a chat completion stream.
/// </summary>
/// <param name="chatModel">The model to use for chat completion.</param>
/// <param name="chatThread">The chat thread to continue.</param>
/// <param name="settingsManager">The settings manager instance to use.</param>
2024-05-04 08:58:18 +00:00
/// <param name="token">The cancellation token.</param>
/// <returns>The chat completion stream.</returns>
public IAsyncEnumerable<string> StreamChatCompletion(Model chatModel, ChatThread chatThread, SettingsManager settingsManager, CancellationToken token = default);
2024-05-04 08:58:18 +00:00
/// <summary>
/// Starts an image completion stream.
/// </summary>
/// <param name="imageModel">The model to use for image completion.</param>
/// <param name="promptPositive">The positive prompt.</param>
/// <param name="promptNegative">The negative prompt.</param>
/// <param name="referenceImageURL">The reference image URL.</param>
/// <param name="token">The cancellation token.</param>
/// <returns>The image completion stream.</returns>
2024-09-01 18:10:03 +00:00
public IAsyncEnumerable<ImageURL> StreamImageCompletion(Model imageModel, string promptPositive, string promptNegative = FilterOperator.String.Empty, ImageURL referenceImageURL = default, CancellationToken token = default);
2024-04-20 15:06:50 +00:00
2024-05-04 08:58:18 +00:00
/// <summary>
/// Load all possible text models that can be used with this provider.
/// </summary>
2024-06-03 17:42:53 +00:00
/// <param name="apiKeyProvisional">The provisional API key to use. Useful when the user is adding a new provider. When null, the stored API key is used.</param>
2024-05-04 08:58:18 +00:00
/// <param name="token">The cancellation token.</param>
/// <returns>The list of text models.</returns>
2024-09-01 18:10:03 +00:00
public Task<IEnumerable<Model>> GetTextModels(string? apiKeyProvisional = null, CancellationToken token = default);
2024-06-03 17:42:53 +00:00
2024-05-04 08:58:18 +00:00
/// <summary>
/// Load all possible image models that can be used with this provider.
/// </summary>
2024-06-03 17:42:53 +00:00
/// <param name="apiKeyProvisional">The provisional API key to use. Useful when the user is adding a new provider. When null, the stored API key is used.</param>
2024-05-04 08:58:18 +00:00
/// <param name="token">The cancellation token.</param>
/// <returns>The list of image models.</returns>
2024-09-01 18:10:03 +00:00
public Task<IEnumerable<Model>> GetImageModels(string? apiKeyProvisional = null, CancellationToken token = default);
2024-12-03 14:24:40 +00:00
/// <summary>
/// Load all possible embedding models that can be used with this provider.
/// </summary>
/// <param name="apiKeyProvisional">The provisional API key to use. Useful when the user is adding a new provider. When null, the stored API key is used.</param>
/// <param name="token">The cancellation token.</param>
/// <returns>The list of embedding models.</returns>
public Task<IEnumerable<Model>> GetEmbeddingModels(string? apiKeyProvisional = null, CancellationToken token = default);
2024-04-20 15:06:50 +00:00
}