Skip to content

Commit cd3fa1c

Browse files
committed
Register all clients, fixup namespace
1 parent 69f9611 commit cd3fa1c

File tree

13 files changed

+86
-10
lines changed

13 files changed

+86
-10
lines changed

src/GrokClient/GrokClient.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22

33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
5+
<RootNamespace>Devlooped.Grok</RootNamespace>
6+
<AssemblyName>Devlooped.Grok</AssemblyName>
7+
<PackageId>GrokClient</PackageId>
8+
<Description>Grok gRPC client based on the official protocol buffers from xAI.</Description>
59
</PropertyGroup>
610

711
<ItemGroup>
812
<PackageReference Include="Google.Protobuf" Version="3.33.1" />
913
<PackageReference Include="Grpc.Net.Client" Version="2.71.0" />
14+
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.71.0" />
1015
<PackageReference Include="Grpc.Tools" Version="2.76.0" PrivateAssets="all" />
16+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0" />
1117
</ItemGroup>
1218

1319
<ItemGroup>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System;
2+
using Grpc.Net.ClientFactory;
3+
using Microsoft.Extensions.DependencyInjection;
4+
5+
namespace Devlooped.Grok;
6+
7+
public static class GrokServiceCollectionExtensions
8+
{
9+
public static IServiceCollection AddGrokClient(this IServiceCollection services, Action<GrpcClientFactoryOptions>? configure = null)
10+
{
11+
var address = new Uri("https://api.x.ai:443");
12+
13+
services.AddGrpcClient<Auth.AuthClient>(options =>
14+
{
15+
options.Address = address;
16+
configure?.Invoke(options);
17+
});
18+
19+
services.AddGrpcClient<Chat.ChatClient>(options =>
20+
{
21+
options.Address = address;
22+
configure?.Invoke(options);
23+
});
24+
25+
services.AddGrpcClient<Embedder.EmbedderClient>(options =>
26+
{
27+
options.Address = address;
28+
configure?.Invoke(options);
29+
});
30+
31+
services.AddGrpcClient<Image.ImageClient>(options =>
32+
{
33+
options.Address = address;
34+
configure?.Invoke(options);
35+
});
36+
37+
services.AddGrpcClient<Models.ModelsClient>(options =>
38+
{
39+
options.Address = address;
40+
configure?.Invoke(options);
41+
});
42+
43+
services.AddGrpcClient<Sample.SampleClient>(options =>
44+
{
45+
options.Address = address;
46+
configure?.Invoke(options);
47+
});
48+
49+
services.AddGrpcClient<Tokenize.TokenizeClient>(options =>
50+
{
51+
options.Address = address;
52+
configure?.Invoke(options);
53+
});
54+
55+
services.AddGrpcClient<Documents.DocumentsClient>(options =>
56+
{
57+
options.Address = address;
58+
configure?.Invoke(options);
59+
});
60+
61+
return services;
62+
}
63+
}

src/GrokClient/auth.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
syntax = "proto3";
22

3-
package xai_api;
3+
package Devlooped.Grok;
44

55
import "google/protobuf/empty.proto";
66
import "google/protobuf/timestamp.proto";

src/GrokClient/chat.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
syntax = "proto3";
22

3-
package xai_api;
3+
package Devlooped.Grok;
44

55
import "google/protobuf/timestamp.proto";
66
import "deferred.proto";

src/GrokClient/deferred.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
syntax = "proto3";
22

3-
package xai_api;
3+
package Devlooped.Grok;
44

55
// The response from the service, when creating a deferred completion request.
66
message StartDeferredResponse {

src/GrokClient/documents.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
syntax = "proto3";
22

3-
package xai_api;
3+
package Devlooped.Grok;
44

55
service Documents {
66
rpc Search(SearchRequest) returns (SearchResponse) {}

src/GrokClient/embed.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
syntax = "proto3";
22

3-
package xai_api;
3+
package Devlooped.Grok;
44

55
import "image.proto";
66
import "usage.proto";

src/GrokClient/image.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
syntax = "proto3";
22

3-
package xai_api;
3+
package Devlooped.Grok;
44

55
// An API service for interaction with image generation models.
66
service Image {

src/GrokClient/models.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
syntax = "proto3";
22

3-
package xai_api;
3+
package Devlooped.Grok;
44

55
import "google/protobuf/empty.proto";
66
import "google/protobuf/timestamp.proto";

src/GrokClient/sample.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
syntax = "proto3";
22

3-
package xai_api;
3+
package Devlooped.Grok;
44

55
import "google/protobuf/timestamp.proto";
66
import "usage.proto";

0 commit comments

Comments
 (0)