Skip to content

Commit be373f3

Browse files
committed
Add missing provider metadata from grok client
1 parent d48be07 commit be373f3

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/Extensions.Grok/GrokChatClient.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Devlooped.Extensions.AI.Grok;
99

1010
class 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
}

src/Tests/ConfigurableClientTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Devlooped.Extensions.AI;
66

7-
public class ConfigurableTests(ITestOutputHelper output)
7+
public class ConfigurableClientTests(ITestOutputHelper output)
88
{
99
[Fact]
1010
public void CanConfigureClients()

0 commit comments

Comments
 (0)