Summary
Add C# bindings for oxbitnet, enabling Unity and .NET applications to run BitNet b1.58 inference with wgpu.
Approach
- C FFI crate (
oxbitnet-ffi) wrapping the Rust oxbitnet crate (shared with Swift bindings)
- C# P/Invoke wrapper with managed API
- Unity-friendly: native plugin (.so/.dylib/.dll) + C# scripts
- Publish as NuGet package:
OxBitNet
- Streaming token output via callback delegate or
IAsyncEnumerable
API sketch
var model = await BitNet.Load("model.gguf");
var messages = new[] {
new ChatMessage("system", "You are a helpful assistant."),
new ChatMessage("user", "Hello!")
};
model.Chat(messages, token => Console.Write(token), new GenerateOptions {
Temperature = 0.7f,
MaxTokens = 256
});
model.Dispose();
Unity usage
public class BitNetChat : MonoBehaviour
{
private BitNet model;
async void Start()
{
model = await BitNet.Load("model.gguf");
}
public async void OnSend(string userMessage)
{
await model.Chat(
new[] { new ChatMessage("user", userMessage) },
token => chatUI.AppendText(token)
);
}
}
Tasks
Summary
Add C# bindings for oxbitnet, enabling Unity and .NET applications to run BitNet b1.58 inference with wgpu.
Approach
oxbitnet-ffi) wrapping the Rustoxbitnetcrate (shared with Swift bindings)OxBitNetIAsyncEnumerableAPI sketch
Unity usage
Tasks
oxbitnet-ffi) with stable ABI (shared with Swift bindings (oxbitnet-swift) #6)