Skip to content

Commit 6805f73

Browse files
authored
Add support for Dependency Injection with ITextEmbeddingGenerator (#503)
## Motivation and Context (Why the change? What's the scenario?) Add support for Dependency Injection with ITextEmbeddingGenerator See #334. This PR replaces #444 so that it excludes unnecessary changes.
1 parent 01537eb commit 6805f73

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

service/Abstractions/KernelMemoryBuilderExtensions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ public static IKernelMemoryBuilder WithCustomEmbeddingGenerator(
137137
return builder;
138138
}
139139

140+
public static IKernelMemoryBuilder WithCustomEmbeddingGenerator<T>(
141+
this IKernelMemoryBuilder builder) where T : class, ITextEmbeddingGenerator
142+
{
143+
builder.AddSingleton<ITextEmbeddingGenerator, T>();
144+
return builder;
145+
}
146+
140147
public static IKernelMemoryBuilder WithCustomMemoryDb(
141148
this IKernelMemoryBuilder builder,
142149
IMemoryDb service,

0 commit comments

Comments
 (0)