Added embedding configurations (#224)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2024-12-03 15:24:40 +01:00
1 parent f806ee28c5
commit 799112eb9d
39 files changed
+1359 -439

No files matched your search

@@ -1,3 +1,5 @@
using AIStudio.Chat;
using RustService = AIStudio.Tools.RustService;
namespace AIStudio.Provider;
@@ -5,10 +7,10 @@ namespace AIStudio.Provider;
/// <summary>
/// The base class for all providers.
/// </summary>
public abstract class BaseProvider
public abstract class BaseProvider : IProvider, ISecretId
{
/// <summary>
/// The HTTP client to use for all requests.
/// The HTTP client to use it for all requests.
/// </summary>
protected readonly HttpClient httpClient = new();
@@ -39,4 +41,37 @@ public abstract class BaseProvider
// Set the base URL:
this.httpClient.BaseAddress = new(url);
}
#region Handling of IProvider, which all providers must implement
/// <inheritdoc />
public abstract string Id { get; }
/// <inheritdoc />
public abstract string InstanceName { get; set; }
/// <inheritdoc />
public abstract IAsyncEnumerable<string> StreamChatCompletion(Model chatModel, ChatThread chatThread, CancellationToken token = default);
/// <inheritdoc />
public abstract IAsyncEnumerable<ImageURL> StreamImageCompletion(Model imageModel, string promptPositive, string promptNegative = FilterOperator.String.Empty, ImageURL referenceImageURL = default, CancellationToken token = default);
/// <inheritdoc />
public abstract Task<IEnumerable<Model>> GetTextModels(string? apiKeyProvisional = null, CancellationToken token = default);
/// <inheritdoc />
public abstract Task<IEnumerable<Model>> GetImageModels(string? apiKeyProvisional = null, CancellationToken token = default);
/// <inheritdoc />
public abstract Task<IEnumerable<Model>> GetEmbeddingModels(string? apiKeyProvisional = null, CancellationToken token = default);
#endregion
#region Implementation of ISecretId
public string SecretId => this.Id;
public string SecretName => this.InstanceName;
#endregion
}