|
| 1 | +# xAI .NET SDK Repository |
| 2 | + |
| 3 | +**Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.** |
| 4 | + |
| 5 | +The xAI .NET SDK repository contains a gRPC client for xAI generated from the original .proto files as well as implementations for Microsoft.Extensions.AI abstractions. |
| 6 | + |
| 7 | +## Working Effectively |
| 8 | + |
| 9 | +### Essential Build Commands |
| 10 | +- **Restore dependencies**: `dotnet restore` |
| 11 | + |
| 12 | +- **Build the entire solution**: `dotnet build` |
| 13 | + |
| 14 | +- **Run tests**: `dotnet test` |
| 15 | + - Runs all unit tests across the solution |
| 16 | + |
| 17 | +### Build Validation and CI Requirements |
| 18 | +- **Always run before committing**: `dnx --yes retest` |
| 19 | +- **NEVER CANCEL** long-running builds or tests |
| 20 | + |
| 21 | +### Project Structure and Navigation |
| 22 | + |
| 23 | +#### Key Directories |
| 24 | + |
| 25 | +| Directory | Description | |
| 26 | +|-----------|-------------| |
| 27 | +| `src/xAI.Protocol/` | gRPC protocol client generated from `.proto` files. Contains protobuf definitions and generated gRPC service clients. | |
| 28 | +| `src/xAI/` | Main SDK library implementing `Microsoft.Extensions.AI` abstractions (`IChatClient`). | |
| 29 | +| `src/xAI/Extensions/` | Helper extension methods (`ChatExtensions.cs`, `Throw.cs`). | |
| 30 | +| `src/xAI.Tests/` | Unit tests using xUnit. | |
| 31 | +| `src/xAI.Tests/Extensions/` | Test helper utilities (`Attributes.cs`, `Configuration.cs`, `Logging.cs`, `CallHelpers.cs`). | |
| 32 | +| `src/xAI.Protocol/google/protobuf/` | Google Protobuf well-known types (`empty.proto`, `timestamp.proto`). | |
| 33 | + |
| 34 | +#### Projects |
| 35 | + |
| 36 | +| Project | Target Framework(s) | Description | |
| 37 | +|---------|---------------------|-------------| |
| 38 | +| `xAI.Protocol` | `net8.0` | gRPC protocol client with generated Protobuf/gRPC code from `.proto` files. | |
| 39 | +| `xAI` | `net8.0`, `net10.0` | Main SDK with `IChatClient` implementation and AI tool abstractions. | |
| 40 | +| `xAI.Tests` | `net10.0` | Unit tests using xUnit, Moq, and Microsoft.NET.Test.Sdk. | |
| 41 | + |
| 42 | +#### Build Outputs |
| 43 | + |
| 44 | +| Output | Location | |
| 45 | +|--------|----------| |
| 46 | +| Protocol generated code | `src/xAI.Protocol/obj/Debug/net8.0/` (e.g., `Chat.cs`, `ChatGrpc.cs`, `Models.cs`, etc.) | |
| 47 | +| xAI assembly | `src/xAI/bin/Debug/net8.0/` and `src/xAI/bin/Debug/net10.0/` | |
| 48 | +| Test assembly | `src/xAI.Tests/bin/Debug/net10.0/` | |
| 49 | + |
| 50 | +#### Protobuf Files |
| 51 | + |
| 52 | +| File | Description | |
| 53 | +|------|-------------| |
| 54 | +| `src/xAI.Protocol/chat.proto` | Chat completion service definitions. | |
| 55 | +| `src/xAI.Protocol/models.proto` | Model listing service definitions. | |
| 56 | +| `src/xAI.Protocol/embed.proto` | Embedding service definitions. | |
| 57 | +| `src/xAI.Protocol/image.proto` | Image generation service definitions. | |
| 58 | +| `src/xAI.Protocol/tokenize.proto` | Tokenization service definitions. | |
| 59 | +| `src/xAI.Protocol/sample.proto` | Sampling service definitions. | |
| 60 | +| `src/xAI.Protocol/auth.proto` | Authentication service definitions. | |
| 61 | +| `src/xAI.Protocol/documents.proto` | Document service definitions. | |
| 62 | +| `src/xAI.Protocol/deferred.proto` | Deferred operations service definitions. | |
| 63 | +| `src/xAI.Protocol/usage.proto` | Usage tracking service definitions. | |
0 commit comments