Skip to content

Commit

Permalink
Fix KernelMemoryBuilderExtensions (#433)
Browse files Browse the repository at this point in the history
## Motivation and Context (Why the change? What's the scenario?)
This PR fixes the issue described at
#424 (comment).
  • Loading branch information
marcominerva authored Apr 24, 2024
1 parent 99f5f0b commit df39a41
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions service/Abstractions/KernelMemoryBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ public static IKernelMemoryBuilder WithCustomIngestionQueueClientFactory(
}

public static IKernelMemoryBuilder WithCustomIngestionQueueClientFactory<T>(
this IKernelMemoryBuilder builder, T service) where T : QueueClientFactory
this IKernelMemoryBuilder builder) where T : QueueClientFactory
{
service = service ?? throw new ConfigurationException("Memory Builder: the ingestion queue client factory instance is NULL");
builder.AddSingleton<QueueClientFactory, T>();
return builder;
}
Expand All @@ -96,9 +95,8 @@ public static IKernelMemoryBuilder WithCustomStorage(
}

public static IKernelMemoryBuilder WithCustomStorage<T>(
this IKernelMemoryBuilder builder, T service) where T : class, IContentStorage
this IKernelMemoryBuilder builder) where T : class, IContentStorage
{
service = service ?? throw new ConfigurationException("Memory Builder: the content storage instance is NULL");
builder.AddSingleton<IContentStorage, T>();
return builder;
}
Expand All @@ -112,9 +110,8 @@ public static IKernelMemoryBuilder WithCustomMimeTypeDetection(
}

public static IKernelMemoryBuilder WithCustomMimeTypeDetection<T>(
this IKernelMemoryBuilder builder, T service) where T : class, IMimeTypeDetection
this IKernelMemoryBuilder builder) where T : class, IMimeTypeDetection
{
service = service ?? throw new ConfigurationException("Memory Builder: the MIME type detection instance is NULL");
builder.AddSingleton<IMimeTypeDetection, T>();
return builder;
}
Expand Down Expand Up @@ -171,10 +168,8 @@ public static IKernelMemoryBuilder WithCustomTextGenerator(
}

public static IKernelMemoryBuilder WithCustomTextGenerator<T>(
this IKernelMemoryBuilder builder,
T service) where T : class, ITextGenerator
this IKernelMemoryBuilder builder) where T : class, ITextGenerator
{
service = service ?? throw new ConfigurationException("Memory Builder: the text generator instance is NULL");
builder.AddSingleton<ITextGenerator, T>();
return builder;
}
Expand All @@ -189,10 +184,8 @@ public static IKernelMemoryBuilder WithCustomImageOcr(
}

public static IKernelMemoryBuilder WithCustomImageOcr<T>(
this IKernelMemoryBuilder builder,
T service) where T : class, IOcrEngine
this IKernelMemoryBuilder builder) where T : class, IOcrEngine
{
service = service ?? throw new ConfigurationException("Memory Builder: the OCR engine instance is NULL");
builder.AddSingleton<IOcrEngine, T>();
return builder;
}
Expand All @@ -206,9 +199,8 @@ public static IKernelMemoryBuilder WithCustomPromptProvider(
}

public static IKernelMemoryBuilder WithCustomPromptProvider<T>(
this IKernelMemoryBuilder builder, T service) where T : class, IPromptProvider
this IKernelMemoryBuilder builder) where T : class, IPromptProvider
{
service = service ?? throw new ConfigurationException("Memory Builder: the prompt provider instance is NULL");
builder.AddSingleton<IPromptProvider, T>();
return builder;
}
Expand Down

0 comments on commit df39a41

Please sign in to comment.