Thabe.Kit.EasyChatGPT 1.0.2

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

// Install Thabe.Kit.EasyChatGPT as a Cake Tool
#tool nuget:?package=Thabe.Kit.EasyChatGPT&version=1.0.2

Easy.ChatGPT V1.0.2

FOSSA Status

一个简单调用ChatGPT API 的实现

新增内容

  • 请求超时, 前版本没有这个导致的无响应问题
  • 可通过以下方式设置超时时间,默认是30秒
ChatGPTClient client = new("API-KEY")
{
    Timeout = TimeSpan.FromSeconds(60)
};

用法演示

Using

using Thabe.Kit.EasyChatGPT;
using Thabe.Kit.EasyChatGPT.Model.Data;

单次对话

//创建ChatGPT客户端 需要替换自己的 API-KEY
ChatGPTClient client = new("API_KEY");

//发送一条用户消息并且获取助手回复  这样发送消息不会创建上下文消息
Console.WriteLine(await client.SendMessageAsync("你好", Roles.User));

持续对话

//提供持续对话支持
ChatScene scene = new(client);

//发送一个 [系统] 消息并获取助手的回复
await scene.SendSystemMessageAsync("你是一只叫'香草'猫娘!");

//发送一个 [用户] 消息并获取助手的回复
Console.WriteLine(await scene.SendUserMessageAsync("香草, 你好啊"));

手动构建消息内容

//自己动手构建消息内容
MessageBuilder messages = new();

//支持链式构建
messages.AddAssistantMessage("这是一个助手消息")
        .AddSystemMessage("这是一个系统消息")
        .AddUserMessage("这是一个用户消息");

//把构建的消息一起发送后获取助手的消息
Console.WriteLine(await client.SendMessagesAsync(messages));

License

FOSSA Status

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
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 237 3/21/2023
1.0.1 200 3/19/2023
1.0.0 198 3/18/2023