80 references to GetService
Aspire.Azure.AI.Inference.Tests (1)
AspireAzureAIInferenceExtensionTests.cs (1)
136var metadata = client?.GetService<ChatClientMetadata>();
Aspire.Azure.AI.OpenAI.Tests (4)
AspireAzureOpenAIClientBuilderChatClientExtensionsTests.cs (4)
40Assert.Equal("testdeployment1", client.GetService<ChatClientMetadata>()?.DefaultModelId); 70Assert.Equal("testdeployment1", client.GetService<ChatClientMetadata>()?.DefaultModelId); 98Assert.Equal("testdeployment1", client.GetService<ChatClientMetadata>()?.DefaultModelId); 190Assert.Equal(disableOpenTelemetry, client.GetService<OpenTelemetryChatClient>() is null);
Aspire.OpenAI.Tests (4)
AspireOpenAIClientBuilderChatClientExtensionsTests.cs (4)
43Assert.Equal("testdeployment1", client.GetService<ChatClientMetadata>()?.DefaultModelId); 73Assert.Equal("testdeployment1", client.GetService<ChatClientMetadata>()?.DefaultModelId); 101Assert.Equal("testdeployment1", client.GetService<ChatClientMetadata>()?.DefaultModelId); 193Assert.Equal(disableOpenTelemetry, client.GetService<OpenTelemetryChatClient>() is null);
Microsoft.Extensions.AI (4)
ChatCompletion\FunctionInvokingChatClient.cs (1)
79_activitySource = innerClient.GetService<ActivitySource>();
ChatCompletion\LoggingChatClient.cs (2)
61LogInvokedSensitive(nameof(GetResponseAsync), AsJson(messages), AsJson(options), AsJson(this.GetService<ChatClientMetadata>())); 107LogInvokedSensitive(nameof(GetStreamingResponseAsync), AsJson(messages), AsJson(options), AsJson(this.GetService<ChatClientMetadata>()));
ChatCompletion\OpenTelemetryChatClient.cs (1)
60if (innerClient!.GetService<ChatClientMetadata>() is ChatClientMetadata metadata)
Microsoft.Extensions.AI.Abstractions.Tests (10)
ChatCompletion\ChatClientExtensionsTests.cs (7)
17Assert.Throws<ArgumentNullException>("client", () => ChatClientExtensions.GetService<object>(null!)); 51Assert.Equal("null key", client.GetService<string>()); 52Assert.Equal("null key", client.GetService<string>(null)); 53Assert.Equal("non-null key", client.GetService<string>("key")); 55Assert.Null(client.GetService<object>()); 56Assert.Null(client.GetService<object>("key")); 57Assert.Null(client.GetService<IChatClient>());
ChatCompletion\DelegatingChatClientTests.cs (3)
106var client = delegating.GetService<DelegatingChatClient>(); 126var client = delegating.GetService<IChatClient>(expectedKey); 148var tzi = delegating.GetService<TimeZoneInfo>(expectedKey);
Microsoft.Extensions.AI.AzureAIInference.Tests (12)
AzureAIInferenceChatClientTests.cs (12)
58var metadata = chatClient.GetService<ChatClientMetadata>(); 70Assert.Same(chatClient, chatClient.GetService<IChatClient>()); 71Assert.Same(client, chatClient.GetService<ChatCompletionsClient>()); 80Assert.NotNull(pipeline.GetService<FunctionInvokingChatClient>()); 81Assert.NotNull(pipeline.GetService<DistributedCachingChatClient>()); 82Assert.NotNull(pipeline.GetService<CachingChatClient>()); 83Assert.NotNull(pipeline.GetService<OpenTelemetryChatClient>()); 84Assert.NotNull(pipeline.GetService<object>()); 86Assert.Same(client, pipeline.GetService<ChatCompletionsClient>()); 87Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<IChatClient>()); 89Assert.Null(pipeline.GetService<ChatCompletionsClient>("key")); 90Assert.Null(pipeline.GetService<string>("key"));
Microsoft.Extensions.AI.Evaluation.Integration.Tests (2)
QualityEvaluatorTests.cs (1)
40ChatClientMetadata? clientMetadata = chatConfiguration.ChatClient.GetService<ChatClientMetadata>();
SafetyEvaluatorTests.cs (1)
40ChatClientMetadata? clientMetadata = llmChatConfiguration.ChatClient.GetService<ChatClientMetadata>();
Microsoft.Extensions.AI.Evaluation.Reporting (1)
ReportingConfiguration.cs (1)
269ChatClientMetadata? metadata = chatClient.GetService<ChatClientMetadata>();
Microsoft.Extensions.AI.Evaluation.Safety (1)
ContentSafetyChatClient.cs (1)
36ChatClientMetadata? originalMetadata = _originalChatClient?.GetService<ChatClientMetadata>();
Microsoft.Extensions.AI.Integration.Tests (4)
ChatClientIntegrationTests.cs (4)
571var llmCallCount = chatClient.GetService<CallCountingChatClient>(); 610var llmCallCount = chatClient.GetService<CallCountingChatClient>(); 652var llmCallCount = chatClient.GetService<CallCountingChatClient>(); 785Assert.Equal(chatClient.GetService<ChatClientMetadata>()?.ProviderUri?.Port, (int)activity.GetTagItem("server.port")!);
Microsoft.Extensions.AI.Ollama.Tests (9)
OllamaChatClientTests.cs (9)
48Assert.Same(client, client.GetService<OllamaChatClient>()); 49Assert.Same(client, client.GetService<IChatClient>()); 58Assert.NotNull(pipeline.GetService<FunctionInvokingChatClient>()); 59Assert.NotNull(pipeline.GetService<DistributedCachingChatClient>()); 60Assert.NotNull(pipeline.GetService<CachingChatClient>()); 61Assert.NotNull(pipeline.GetService<OpenTelemetryChatClient>()); 63Assert.Same(client, pipeline.GetService<OllamaChatClient>()); 64Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<IChatClient>()); 74var metadata = chatClient.GetService<ChatClientMetadata>();
Microsoft.Extensions.AI.OpenAI.Tests (28)
OpenAIChatClientTests.cs (19)
46var metadata = chatClient.GetService<ChatClientMetadata>(); 52metadata = chatClient.GetService<ChatClientMetadata>(); 64Assert.Same(chatClient, chatClient.GetService<IChatClient>()); 66Assert.Same(openAIClient, chatClient.GetService<ChatClient>()); 68Assert.NotNull(chatClient.GetService<ChatClient>()); 77Assert.NotNull(pipeline.GetService<FunctionInvokingChatClient>()); 78Assert.NotNull(pipeline.GetService<DistributedCachingChatClient>()); 79Assert.NotNull(pipeline.GetService<CachingChatClient>()); 80Assert.NotNull(pipeline.GetService<OpenTelemetryChatClient>()); 82Assert.Same(openAIClient, pipeline.GetService<ChatClient>()); 83Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<IChatClient>()); 92Assert.Same(chatClient, chatClient.GetService<IChatClient>()); 93Assert.Same(openAIClient, chatClient.GetService<ChatClient>()); 102Assert.NotNull(pipeline.GetService<FunctionInvokingChatClient>()); 103Assert.NotNull(pipeline.GetService<DistributedCachingChatClient>()); 104Assert.NotNull(pipeline.GetService<CachingChatClient>()); 105Assert.NotNull(pipeline.GetService<OpenTelemetryChatClient>()); 107Assert.Same(openAIClient, pipeline.GetService<ChatClient>()); 108Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<IChatClient>());
OpenAIResponseClientTests.cs (9)
45var metadata = chatClient.GetService<ChatClientMetadata>(); 57Assert.Same(chatClient, chatClient.GetService<IChatClient>()); 58Assert.Same(openAIClient, chatClient.GetService<OpenAIResponseClient>()); 67Assert.NotNull(pipeline.GetService<FunctionInvokingChatClient>()); 68Assert.NotNull(pipeline.GetService<DistributedCachingChatClient>()); 69Assert.NotNull(pipeline.GetService<CachingChatClient>()); 70Assert.NotNull(pipeline.GetService<OpenTelemetryChatClient>()); 72Assert.Same(openAIClient, pipeline.GetService<OpenAIResponseClient>()); 73Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<IChatClient>());