diff --git a/LLama/Extensions/LLamaExecutorExtensions.cs b/LLama/Extensions/LLamaExecutorExtensions.cs
index 9a19e8d03..4a83b9669 100644
--- a/LLama/Extensions/LLamaExecutorExtensions.cs
+++ b/LLama/Extensions/LLamaExecutorExtensions.cs
@@ -54,9 +54,11 @@ private sealed class LLamaExecutorChatClient(
public void Dispose() { }
///
- public TService? GetService(object? key = null) where TService : class =>
- typeof(TService) == typeof(ILLamaExecutor) ? (TService)_executor :
- this as TService;
+ public object? GetService(Type serviceType, object? key = null) =>
+ key is not null ? null :
+ serviceType?.IsInstanceOfType(_executor) is true ? _executor :
+ serviceType?.IsInstanceOfType(this) is true ? this :
+ null;
///
public async Task CompleteAsync(
diff --git a/LLama/LLamaEmbedder.EmbeddingGenerator.cs b/LLama/LLamaEmbedder.EmbeddingGenerator.cs
index c404d7b3e..62a6d1940 100644
--- a/LLama/LLamaEmbedder.EmbeddingGenerator.cs
+++ b/LLama/LLamaEmbedder.EmbeddingGenerator.cs
@@ -21,9 +21,11 @@ public partial class LLamaEmbedder
dimensions: EmbeddingSize);
///
- TService? IEmbeddingGenerator>.GetService(object? key) where TService : class =>
- typeof(TService) == typeof(LLamaContext) ? (TService)(object)Context :
- this as TService;
+ object? IEmbeddingGenerator>.GetService(Type serviceType, object? key) =>
+ key is not null ? null :
+ serviceType?.IsInstanceOfType(Context) is true ? Context :
+ serviceType?.IsInstanceOfType(this) is true ? this :
+ null;
///
async Task>> IEmbeddingGenerator>.GenerateAsync(IEnumerable values, EmbeddingGenerationOptions? options, CancellationToken cancellationToken)
diff --git a/LLama/LLamaSharp.csproj b/LLama/LLamaSharp.csproj
index 85f3b8196..735fa81a5 100644
--- a/LLama/LLamaSharp.csproj
+++ b/LLama/LLamaSharp.csproj
@@ -50,7 +50,7 @@
-
+