semantic-kernel
semantic-kernel copied to clipboard
Suggested tweaks to Embedding types
Currently, Semantic Kernel contains:
// *** In Microsoft.SemanticKernel.dll ***
namespace Microsoft.SemanticKernel.AI.Embeddings
{
public static class SupportedTypes
{
public static bool IsSupported<T>();
public static bool IsSupported(Type type);
public static IEnumerable<Type> Types { get; }
}
public ref struct EmbeddingSpan<TEmbedding>
{
public static bool IsSupported { get; }
...
}
public ref struct EmbeddingReadOnlySpan<TEmbedding>
{
public static bool IsSupported { get; }
...
}
...
}
// *** In Microsoft.SemanticKernel.Abstractions ***
namespace Microsoft.SemanticKernel.AI.Embeddings
{
public readonly struct Embedding<TEmbedding>
{
...
public static bool IsSupported { get; }
}
public static class Embedding
{
public static readonly Type[] SupportedTypes { get; }
}
}
This is duplicative. The Embedding.SupportedTypes property is also returning an array that can be mutated without requiring any casting. I propose:
- Remove the
IsSupportedproperties fromEmbedding<T>,EmbeddedSpan<T>, andEmbeddedReadOnlySpan<T>. - Move the contents of the
SupportedTypesclass to theEmbeddingclass, while also renaming theTypesproperty to beSupportedTypesand deleting the one that's currently onEmbedding. - Delete the
SupportedTypesclass.
That would result in:
// *** In Microsoft.SemanticKernel.dll ***
namespace Microsoft.SemanticKernel.AI.Embeddings
{
public ref struct EmbeddingSpan<TEmbedding>
{
...
}
public ref struct EmbeddingReadOnlySpan<TEmbedding>
{
...
}
...
}
// *** In Microsoft.SemanticKernel.Abstractions ***
namespace Microsoft.SemanticKernel.AI.Embeddings
{
public readonly struct Embedding<TEmbedding>
{
...
}
public static class Embedding
{
public static bool IsSupported<TEmbedding>();
public static bool IsSupported(Type type);
public static IEnumerable<Type> SupportedTypes { get; }
}
}
cc: @dluc, @shawncal
@awharrison-28