forked from microsoft/kernel-memory
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmbeddingsConfig.cs
More file actions
37 lines (33 loc) · 1.36 KB
/
EmbeddingsConfig.cs
File metadata and controls
37 lines (33 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (c) Microsoft. All rights reserved.
using System.Text.Json.Serialization;
using KernelMemory.Core.Config.Enums;
using KernelMemory.Core.Config.Validation;
namespace KernelMemory.Core.Config.Embeddings;
/// <summary>
/// Base class for embeddings provider configurations
/// </summary>
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
[JsonDerivedType(typeof(OllamaEmbeddingsConfig), typeDiscriminator: "ollama")]
[JsonDerivedType(typeof(OpenAIEmbeddingsConfig), typeDiscriminator: "openai")]
[JsonDerivedType(typeof(AzureOpenAIEmbeddingsConfig), typeDiscriminator: "azureOpenAI")]
[JsonDerivedType(typeof(HuggingFaceEmbeddingsConfig), typeDiscriminator: "huggingFace")]
public abstract class EmbeddingsConfig : IValidatable
{
/// <summary>
/// Type of embeddings provider
/// </summary>
[JsonIgnore]
public abstract EmbeddingsTypes Type { get; }
/// <summary>
/// Maximum number of texts to send per embeddings API request.
/// Providers that support batch requests should chunk input using this size.
/// Default: 10.
/// </summary>
[JsonPropertyName("batchSize")]
public int BatchSize { get; set; } = Constants.EmbeddingDefaults.DefaultBatchSize;
/// <summary>
/// Validates the embeddings configuration
/// </summary>
/// <param name="path"></param>
public abstract void Validate(string path);
}