diff --git a/src/csharp/ChatClient.cs b/src/csharp/ChatClient.cs index 753ec8d5d..d47c3275b 100644 --- a/src/csharp/ChatClient.cs +++ b/src/csharp/ChatClient.cs @@ -183,10 +183,12 @@ public async IAsyncEnumerable CompleteStreamingAs } /// - public TService GetService(object key = null) where TService : class => - typeof(TService) == typeof(Model) ? (TService)(object)_model : - typeof(TService) == typeof(Tokenizer) ? (TService)(object)_tokenizer : - this as TService; + public object GetService(Type serviceType, object key = null) => + key is not null ? null : + serviceType == typeof(Model) ? _model : + serviceType == typeof(Tokenizer) ? _tokenizer : + serviceType?.IsInstanceOfType(this) is true ? this : + null; /// Gets whether the specified token is a stop sequence. private bool IsStop(string token, ChatOptions options) => diff --git a/src/csharp/Microsoft.ML.OnnxRuntimeGenAI.csproj b/src/csharp/Microsoft.ML.OnnxRuntimeGenAI.csproj index b6e838adb..83f729a7e 100644 --- a/src/csharp/Microsoft.ML.OnnxRuntimeGenAI.csproj +++ b/src/csharp/Microsoft.ML.OnnxRuntimeGenAI.csproj @@ -122,7 +122,7 @@ - +