Share via


ChatClientExtensions.GetService<TService>(IChatClient, Object) Method

Definition

Asks the IChatClient for an object of type TService.

public static TService? GetService<TService> (this Microsoft.Extensions.AI.IChatClient client, object? serviceKey = default);
static member GetService : Microsoft.Extensions.AI.IChatClient * obj -> 'Service
<Extension()>
Public Function GetService(Of TService) (client As IChatClient, Optional serviceKey As Object = Nothing) As TService

Type Parameters

TService

The type of the object to be retrieved.

Parameters

client
IChatClient

The client.

serviceKey
Object

An optional key that can be used to help identify the target service.

Returns

TService

The found object, otherwise null.

Remarks

The purpose of this method is to allow for the retrieval of strongly typed services that may be provided by the IChatClient, including itself or any services it might be wrapping.

Applies to