@@ -9,6 +9,7 @@ namespace Devlooped.Extensions.AI.Grok;
99
1010class GrokChatClient : IChatClient
1111{
12+ readonly ChatClientMetadata metadata ;
1213 readonly ChatClient client ;
1314 readonly string defaultModelId ;
1415 readonly GrokClientOptions clientOptions ;
@@ -18,6 +19,7 @@ internal GrokChatClient(GrpcChannel channel, GrokClientOptions clientOptions, st
1819 client = new ChatClient ( channel ) ;
1920 this . clientOptions = clientOptions ;
2021 this . defaultModelId = defaultModelId ;
22+ metadata = new ChatClientMetadata ( "xai" , clientOptions . Endpoint , defaultModelId ) ;
2123 }
2224
2325 public async Task < ChatResponse > GetResponseAsync ( IEnumerable < ChatMessage > messages , ChatOptions ? options = null , CancellationToken cancellationToken = default )
@@ -436,8 +438,14 @@ codeResult.RawRepresentation is ToolCall codeToolCall &&
436438 TotalTokenCount = usage . TotalTokens
437439 } ;
438440
439- public object ? GetService ( Type serviceType , object ? serviceKey = null ) =>
440- serviceType == typeof ( GrokChatClient ) ? this : null ;
441+ /// <inheritdoc />
442+ public object ? GetService ( Type serviceType , object ? serviceKey = null ) => serviceType switch
443+ {
444+ Type t when t == typeof ( ChatClientMetadata ) => metadata ,
445+ Type t when t == typeof ( GrokChatClient ) => this ,
446+ _ => null
447+ } ;
441448
449+ /// <inheritdoc />
442450 public void Dispose ( ) { }
443451}
0 commit comments