![]() |
VOOZH | about |
dotnet add package ChatVPet.ChatProcess --version 1.1.1
NuGet\Install-Package ChatVPet.ChatProcess -Version 1.1.1
<PackageReference Include="ChatVPet.ChatProcess" Version="1.1.1" />
<PackageVersion Include="ChatVPet.ChatProcess" Version="1.1.1" />Directory.Packages.props
<PackageReference Include="ChatVPet.ChatProcess" />Project file
paket add ChatVPet.ChatProcess --version 1.1.1
#r "nuget: ChatVPet.ChatProcess, 1.1.1"
#:package ChatVPet.ChatProcess@1.1.1
#addin nuget:?package=ChatVPet.ChatProcess&version=1.1.1Install as a Cake Addin
#tool nuget:?package=ChatVPet.ChatProcess&version=1.1.1Install as a Cake Tool
ChatVPetProcess 是一个用于处理和模拟自然语言交互的聊天系统。它通过整合 GPT 模型、知识库和工具,实现了对用户输入的自然语言的理解和处理。
ChatVPet 和 后续训练均会使用该处理模式和结构
通过Parckage Manager
Install-Package ChatVPetProcess
通过nuget.org
准备聊天方法:
// 可以用自己或者其他的AI聊天程序, 这里是使用 ChatGPT.API.Framework
// https://github.com/LorisYounger/ChatGPT.API.Framework
/// <summary>
/// 调用GPT的方法
/// </summary>
public string GPTAsk(string system, List<string[]> historys, string message)
{
Completions completions = new Completions();
completions.max_tokens = 8000;//最大token限制
completions.model = "gpt-4o-mini";
completions.messages.Add(new Message() { role = Message.RoleType.system, content = system });
foreach (var h in historys)
{
completions.messages.Add(new Message() { role = Message.RoleType.user, content = h[0] });
completions.messages.Add(new Message() { role = Message.RoleType.system, content = h[1] });
}
completions.messages.Add(new Message() { role = Message.RoleType.user, content = message });
var resp = completions.GetResponse("APIUrl", "APIKey");
var reply = resp.GetMessageContent();
if (resp.choices.Length == 0)
{
return "请检查API token设置".Translate();
}
else if (resp.choices[0].finish_reason == "length")
{
reply += " ...";
}
temptoken = resp.usage.total_tokens;
TokenCount = temptoken;
return reply;
}
实例化 VPetChatProcess
public VPetChatProcess VPetChatProcess = new VPetChatProcess(new ILocalization.LChineseSimple(),GPTAsk);
加载知识和工具:
// 加载知识库
VPetChatProcess.AddKnowledgeDataBase(KnowledgeDataBase.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries));
// 加载工具
VPetChatProcess.Tools.Add(new Tool("takeitem", "购买并使用有物品id的物品,例如(吃)食物/正餐/零食/(喝)饮料/功能性/药品/(送)礼品".Translate(), ToolTakeItem, new List<Tool.Arg>()
{
new Tool.Arg(){ Name = "itemID", Description = "(int)物品id, 没有物品ID的物品没法使用".Translate() }
}, VPetChatProcess.Localization));
发送聊天请求:
// 聊天控制器
var pc = new ProcessControl();
VPetChatProcess.Ask(content, (pr) =>
{
if (pr.IsError)
{// 处理错误情况
MessageBox.Show("VCP报错: " + pr.Reply);
}
else if (!string.IsNullOrWhiteSpace(pr.Reply))
{// 处理正常回复
MessageBox.Show(pr.Reply);
}
if (pr.IsEnd || pr.IsError)
{
//结束前的处理
}
else if (pr.ListPosition >= 5)
{
MessageBox.Show("轮询次数超过5,已停止下一轮轮询");
pc.StopBeforeNext = true;
}
}, pc);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.