Sdcb.WenXinQianFan 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
dotnet add package Sdcb.WenXinQianFan --version 1.1.0
NuGet\Install-Package Sdcb.WenXinQianFan -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.WenXinQianFan" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sdcb.WenXinQianFan --version 1.1.0
#r "nuget: Sdcb.WenXinQianFan, 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.WenXinQianFan as a Cake Addin
#addin nuget:?package=Sdcb.WenXinQianFan&version=1.1.0

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

Sdcb.WenXinQianFan NuGet NuGet GitHub

English | 简体中文

Sdcb.WenXinQianFan是一个非官方的开源项目,提供WenXin QianFan API 的 .NET 客户端。这个项目可以用来开发能够用自然语言与用户交流的聊天机器人和虚拟助手。

功能

  • 为 WenXin QianFan API 提供 .NET 客户端。
  • 支持同步和异步通信。
  • 实现了流API,以实现实时通信。
  • 为聊天机器人开发提供了简单直观的API。

安装

通过NuGet可以安装 Sdcb.WenXinQianFan。 在程序包管理器控制台中运行以下命令以安装软件包:

Install-Package Sdcb.WenXinQianFan

使用方法

要使用 Sdcb.WenXinQianFan,您需要创建一个 QianFanClient 类实例。您可以通过将WenXin QianFan API凭据传递给构造函数来创建客户端:

QianFanClient client = new QianFanClient(apiKey, apiSecret);

示例1:使用同步API与虚拟助手聊天

以下示例显示了如何使用 ChatAsync 方法与虚拟助手聊天:

QianFanClient c = new QianFanClient(apiKey, apiSecret);
ChatResponse msg = await c.ChatAsync(KnownModel.ERNIEBotTurbo, new ChatMessage[]
{
    ChatMessage.FromUser("系统提示:你叫张三,一名5岁男孩,你在金色摇篮幼儿园上学,你的妈妈叫李四,是一名工程师"),
    ChatMessage.FromAssistant("明白"),
    ChatMessage.FromUser("你好小朋友,我是周老师,你在哪上学?"),
});
Console.WriteLine(msg.Result);

示例2:使用流API与虚拟助手聊天

以下示例显示了如何使用 ChatAsStreamAsync 方法以及流API与虚拟助手聊天:

StringBuilder sb = new StringBuilder();
QianFanClient c = new QianFanClient(apiKey, apiSecret);
await foreach (StreamedChatResponse msg in c.ChatAsStreamAsync(KnownModel.ERNIEBot, new ChatMessage[] { ChatMessage.FromUser("湖南的省会在哪?") }, new ChatRequestParameters
{
    Temperature = 0.5f,
    PenaltyScore = 2.0f,
    UserId = "zhoujie"
}))
{
    sb.Append(msg.Result);
}
Console.WriteLine(sb.ToString());

支持的模型

以下是 Sdcb.WenXinQianFan 支持的语言模型列表:

模型 描述
ERNIEBot 百度自行研发的大语言模型,覆盖海量中文数据,具有更强的对话问答、内容创作生成等能力。
ERNIEBotTurbo 百度自行研发的大语言模型,覆盖海量中文数据,具有更强的对话问答、内容创作生成等能力,响应速度更快。
BLOOMZ_7B 业内知名的大语言模型,由BigScience研发并开源,能够以46种语言和13种编程语言输出文本。
Llama2_7bChat Meta AI研发并开源,在编码、推理及知识应用等场景表现优秀,Llama-2-7b-chat是高性能原生开源版本,适用于对话场景。
Llama2_13bChat Meta AI研发并开源,在编码、推理及知识应用等场景表现优秀,Llama-2-13b-chat是性能与效果均衡的原生开源版本,适用于对话场景。
Llama2_70bChat Meta AI研发并开源,在编码、推理及知识应用等场景表现优秀,Llama-2-70b-chat是高精度效果的原生开源版本。
QianfanBLOOMZ_7BCompressed 千帆团队在BLOOMZ-7B基础上的压缩版本,融合量化、稀疏化等技术,显存占用降低30%以上。
QianfanChineseLlama2_7B 千帆团队在Llama-2-7b基础上的中文增强版本,在CMMLU、C-EVAL等中文数据集上表现优异。
ChatGLM2_6B_32K 智谱AI与清华KEG实验室发布的中英双语对话模型,能够更好的处理最多32K长度的上下文。
AquilaChat_7B 由智源研究院研发,基于Aquila-7B训练的对话模型,支持流畅的文本对话及多种语言类生成任务,通过定义可扩展的特殊指令规范,实现 AquilaChat对其它模型和工具的调用,且易于扩展。

最新的列表可以在官网这里了解。

许可证

Sdcb.WenXinQianFan 遵循 MIT 许可证。 请参阅LICENSE.txt文件以获取更多信息。

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

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.1.0 619 10/24/2023
1.0.0 164 9/4/2023