MoonshotNet 1.0.0
See the version list below for details.
dotnet add package MoonshotNet --version 1.0.0
NuGet\Install-Package MoonshotNet -Version 1.0.0
<PackageReference Include="MoonshotNet" Version="1.0.0" />
paket add MoonshotNet --version 1.0.0
#r "nuget: MoonshotNet, 1.0.0"
// Install MoonshotNet as a Cake Addin #addin nuget:?package=MoonshotNet&version=1.0.0 // Install MoonshotNet as a Cake Tool #tool nuget:?package=MoonshotNet&version=1.0.0
Moonshot .NET Client Service
The Moonshot .NET is a library for interacting with the Moonshot API, the quickest LLM inference method available yet.
About
The library provides a simple and easy-to-use interface for accessing the Moonshot API, allowing developers to integrate the platform's capabilities into their applications.
Features
- Sends HTTP requests to the Moonshot API
- Streaming chat completions
- Handles rate limiting and retries when necessary
- Supports JSON serialization and deserialization using System.Text.Json
- Can be used with ILogger for logging
Usage
Here's an example of how to use the client library:
using MoonshotNet;
using MoonshotNet.ChatCompletions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var apiKey = Environment.GetEnvironmentVariable("API_Key_Moonshot", EnvironmentVariableTarget.User);
var host = new HostBuilder()
.ConfigureServices(services =>
{
services.AddHttpClient();
services.AddMoonshotClient(apiKey, MoonshotModel.Moonshot_v1_8kValue);
}).Build();
var moonshotClient = host.Services.GetRequiredService<MoonshotClient>();
var history = new MoonshotChatHistory
{
new("���� Kimi���� Moonshot AI �ṩ���˹��������֣�����ó����ĺ�Ӣ�ĵĶԻ������Ϊ�û��ṩ��ȫ���а�����ȷ�Ļش�ͬʱ�����ܾ�һ���漰�ֲ����壬�������ӣ���ɫ����������Ļش�Moonshot AI Ϊר�����ʣ����ɷ������������?")
};
// -- Example 1: Get chat completions without streaming
var result = await moonshotClient.GetChatCompletionsAsync(history);
Console.WriteLine(result.Choices.First().Message.Content);
Console.WriteLine($"Total tokens used: {result.Usage.TotalTokens}");
// -- Example 2: Get chat completions with streaming
await foreach (var msg in moonshotClient.GetChatCompletionsStreamingAsync(history))
{
Console.WriteLine(msg.Choices[0].Delta.Content);
}
License
The Moonshot .NET Client Library is licensed under the Apache 2.0 License.
Contribution
Contributions are welcome! If you find a bug or have an idea for a new feature, please open an issue and let us know.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.Http (>= 8.0.0)
- System.Memory.Data (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.