MoonshotNet 1.0.2

dotnet add package MoonshotNet --version 1.0.2                
NuGet\Install-Package MoonshotNet -Version 1.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MoonshotNet" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MoonshotNet --version 1.0.2                
#r "nuget: MoonshotNet, 1.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MoonshotNet as a Cake Addin
#addin nuget:?package=MoonshotNet&version=1.0.2

// Install MoonshotNet as a Cake Tool
#tool nuget:?package=MoonshotNet&version=1.0.2                

Moonshot .NET Client Service

NuGet version (MoonshotNet) NuGet downloads (MoonshotNet) GitHub license

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 150 6/8/2024
1.0.1 107 6/8/2024
1.0.0 130 5/14/2024