Sdcb.SparkDesk 1.1.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Sdcb.SparkDesk --version 1.1.0
NuGet\Install-Package Sdcb.SparkDesk -Version 1.1.0
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="Sdcb.SparkDesk" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sdcb.SparkDesk --version 1.1.0
#r "nuget: Sdcb.SparkDesk, 1.1.0"
#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 Sdcb.SparkDesk as a Cake Addin
#addin nuget:?package=Sdcb.SparkDesk&version=1.1.0

// Install Sdcb.SparkDesk as a Cake Tool
#tool nuget:?package=Sdcb.SparkDesk&version=1.1.0

Sdcb.SparkDesk NuGet NuGet GitHub

Sdcb.SparkDesk is an unofficial open-source project that provides a .NET client for SparkDesk WebSocket API(https://console.xfyun.cn/services/cbm). Upstream document: https://www.xfyun.cn/doc/spark/Guide.html

It can be used to build chatbots and virtual assistants that can communicate with users in natural language.

Sdcb.SparkDesk��Ѷ���ǻ��ģ��WebSocket API�ķǹٷ�.NET��Դ�ͻ���(https://console.xfyun.cn/services/cbm)��

Features

  • Provides a .NET client for the SparkDesk API
  • Supports both synchronous and asynchronous communication
  • Implements streaming APIs for real-time communication
  • Provides a simple and intuitive API for chatbot development

Installation

Sdcb.SparkDesk can be installed using NuGet. To install the package, run the following command in the Package Manager Console:

Install-Package Sdcb.SparkDesk

Usage

To use Sdcb.SparkDesk, you need to create an instance of the SparkDeskClient class. You can create the client by passing your SparkDesk API credentials to the constructor:

SparkDeskClient client = new SparkDeskClient(appId, apiKey, apiSecret);

Example 1: Chatting with a virtual assistant

The following example shows how to use the ChatAsync method to chat with a virtual assistant:

SparkDeskClient client = new SparkDeskClient(appId, apiKey, apiSecret);
ChatResponse response = await client.ChatAsync(new ChatMessage[] 
{
    ChatMessage.FromUser("ϵͳ��ʾ�����������һ��5���к������ڽ�ɫҡ���׶�԰��ѧ�������������ģ���һ������ʦ"),
    ChatMessage.FromUser("���С���ѣ���������ʦ��������ѧ��"),
});
Console.WriteLine(response.Text);

Example 2: Chatting with a virtual assistant using streaming API

The following example shows how to use the ChatAsStreamAsync method to chat with a virtual assistant using streaming API:

SparkDeskClient client = new SparkDeskClient(appId, apiKey, apiSecret);
await foreach (StreamedChatResponse msg in client.ChatAsStreamAsync(new ChatMessage[] { ChatMessage.FromUser("���ϵ�ʡ�����ģ�") }, new ChatRequestParameters
{
    ChatId = "test",
    MaxTokens = 20,
    Temperature = 0.5f,
    TopK = 4,
}))
{
    Console.WriteLine(msg);
}

Example 3: Chatting with a virtual assistant using streaming API and callback

The following example shows how to use the ChatAsStreamViaCallbackAsync method to chat with a virtual assistant using streaming API and callback:

SparkDeskClient client = new SparkDeskClient(appId, apiKey, apiSecret);
StringBuilder sb = new();
TokensUsage usage = await client.ChatAsStreamAsync(new ChatMessage[] 
{ 
    ChatMessage.FromUser("1+1=?"),
    ChatMessage.FromAssistant("1+1=3"),
    ChatMessage.FromUser("���԰����������룿")
}, s => sb.Append(s), uid: "zhoujie");

string realResponse = sb.ToString();
Console.WriteLine(realResponse);

License

Sdcb.SparkDesk is licensed under the MIT License. See the LICENSE.txt file for more information.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Sdcb.SparkDesk:

Package Downloads
AIDotNet.SparkDesk

AI DotNet API

BotSharp.Plugin.SparkDesk

Package Description

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Sdcb.SparkDesk:

Repository Stars
AIDotNet/AntSK
基于.Net8+AntBlazor+SemanticKernel 和KernelMemory 打造的AI知识库/智能体,支持本地离线AI大模型。可以不联网离线运行。
Version Downloads Last updated
3.0.0 1,440 3/9/2024
2.3.0 108 1/30/2024
2.2.0 462 10/26/2023
2.1.0 128 10/24/2023
2.0.0 177 8/19/2023
1.1.0 133 6/20/2023