XFEExtension
【DLL】XFE各类拓展是一个C#的DLL库,旨在优化C#代码中常用语句的使用,并提供更简洁的访问方式,同时提供Xunit测试框架,快速搭建服务器/客户端,免费ChatGPTAPI接口,免费通讯服务器,XFE下载器,新增格式等
关注
0
Fork
0
Star
0
返回提交历史
Modified
XFEExtension.NetCore.Test/Program.cs
+38
-14
Modified
XFEExtension.NetCore/XFEChatGPT/MemorableXFEChatGPT.cs
+5
-5
Modified
XFEExtension.NetCore/XFEExtension.NetCore.csproj
+2
-2
XFEstudio/XFEExtension
fix-修复了MemorableXFEChatGPT中流式输出和记忆功能传参问题
f3f94ff
代码差异
3 个文件
+45
-21
@@ -1,25 +1,49 @@
1
using XFEExtension.NetCore.Test;
2
using XFEExtension.NetCore.XFEConsole;
3
using XFEExtension.NetCore.XUnit;
1
using XFEExtension.NetCore.XFEChatGPT;
4
2
5
3
internal class Program
6
4
{
7
5
public static MemorableXFEChatGPT XFEChatGPT { get; set; } = new MemorableXFEChatGPT();
6
public static string CurrentDialogID { get; set; } = Guid.NewGuid().ToString();
8
7
private static async Task Main(string[] args)
9
8
{
10
await XFECode.RunTest();
9
XFEChatGPT.XFEChatGPTMessageReceived += XFEChatGPT_XFEChatGPTMessageReceived;
10
XFEChatGPT.CreateDialog(CurrentDialogID, "你是一个专门负责整理谣言的人工智能,我会提供给你一些带有时间线的谣言,这其中可能会有很多不相干的信息和没有时间线的信息,你需要自己辨别判断有用信息并将其排序从最早的到最新的日期来排序,除此之外不要说任何多余的内容,格式是:[+-RumorEntry { TimeLine = 2017/2/4, Content = 你整理的第一条谣言内容 }-+][+-RumorEntry { TimeLine = 2019/8/12, Content = 你整理的第二条谣言内容 }-+][+-RumorEntry { TimeLine = 2022/10/4, Content = 你整理的第三条谣言内容 }-+][+-RumorEntry { TimeLine = 2023/1/23, Content = 你整理的第四条谣言内容 }-+]...以此类推", true, false, ChatGPTModel.gpt4o);
11
//await XFEConsole.WriteObject(XFEChatGPT, false, false);
12
//Console.WriteLine(XFEChatGPT);
13
await XFEChatGPT.AskChatGPT(CurrentDialogID, Guid.NewGuid().ToString(), "测试谣言");
14
Console.ReadLine();
11
15
}
12
16
13
[SMTest]
14
[UseXFEConsole]
15
public static async Task TestMethod()
17
private static void XFEChatGPT_XFEChatGPTMessageReceived(object? sender, XFEExtension.NetCore.XFEChatGPT.ChatGPTInnerClass.HelperClass.MemorableGPTMessageReceivedEventArgs e)
16
18
{
17
var testClass = new TestClass("测试类", "测试描述:我上早八", 56)
19
switch (e.GenerateState)
18
20
{
19
Tags = [["标签11", "标签12"], ["标签21", "标签22"]]
20
};
21
Console.WriteLine(testClass);
22
Console.WriteLine("Program End");
23
Console.ReadLine();
21
case GenerateState.Start:
22
Console.Write(e.Message);
23
break;
24
case GenerateState.Continue:
25
Console.Write(e.Message);
26
break;
27
case GenerateState.End:
28
Console.WriteLine(e.Message);
29
break;
30
case GenerateState.Error:
31
Console.WriteLine(e.Message);
32
break;
33
default:
34
break;
35
}
24
36
}
37
//[SMTest]
38
//[UseXFEConsole]
39
//public static async Task TestMethod()
40
//{
41
// var testClass = new TestClass("测试类", "测试描述:我上早八", 56)
42
// {
43
// Tags = [["标签11", "标签12"], ["标签21", "标签22"]]
44
// };
45
// Console.WriteLine(testClass);
46
// Console.WriteLine("Program End");
47
// Console.ReadLine();
48
//}
25
49
}
@@ -53,7 +53,7 @@ public class MemorableXFEChatGPT : XFEChatGPTBase
53
53
/// <param name="streamMode">是否为流式输出</param>
54
54
public void CreateDialog(string dialogId, string system, bool hasMemory, bool streamMode)
55
55
{
56
xFEGPTMemoryDialog.Add(dialogId, new XFEGPTMessageCollection([new XFEGPTMessage(dialogId, new GPTMessage("system", system))], streamMode, ChatGPTModel.gpt3point5turbo, XFEComProtocol.XFEFAST, hasMemory, 0.7));
56
xFEGPTMemoryDialog.Add(dialogId, new XFEGPTMessageCollection([new XFEGPTMessage(dialogId, new GPTMessage("system", system))], hasMemory, ChatGPTModel.gpt3point5turbo, XFEComProtocol.XFEFAST, streamMode, 0.7));
57
57
}
58
58
/// <summary>
59
59
/// 创建一个新的对话,使用默认通信协议(快速响应通讯协议)
@@ -65,7 +65,7 @@ public class MemorableXFEChatGPT : XFEChatGPTBase
65
65
/// <param name="chatGPTModel">所用的ChatGPT模型</param>
66
66
public void CreateDialog(string dialogId, string system, bool hasMemory, bool streamMode, ChatGPTModel chatGPTModel)
67
67
{
68
xFEGPTMemoryDialog.Add(dialogId, new XFEGPTMessageCollection([new XFEGPTMessage(dialogId, new GPTMessage("system", system))], streamMode, chatGPTModel, XFEComProtocol.XFEFAST, hasMemory, 0.7));
68
xFEGPTMemoryDialog.Add(dialogId, new XFEGPTMessageCollection([new XFEGPTMessage(dialogId, new GPTMessage("system", system))], hasMemory, chatGPTModel, XFEComProtocol.XFEFAST, streamMode, 0.7));
69
69
}
70
70
/// <summary>
71
71
/// 创建一个新的对话,使用默认通信协议(快速响应通讯协议)
@@ -78,7 +78,7 @@ public class MemorableXFEChatGPT : XFEChatGPTBase
78
78
/// <param name="temperature">系统的Temperature</param>
79
79
public void CreateDialog(string dialogId, string system, bool hasMemory, bool streamMode, ChatGPTModel chatGPTModel, double temperature)
80
80
{
81
xFEGPTMemoryDialog.Add(dialogId, new XFEGPTMessageCollection([new XFEGPTMessage(dialogId, new GPTMessage("system", system))], streamMode, chatGPTModel, XFEComProtocol.XFEFAST, hasMemory, temperature));
81
xFEGPTMemoryDialog.Add(dialogId, new XFEGPTMessageCollection([new XFEGPTMessage(dialogId, new GPTMessage("system", system))], hasMemory, chatGPTModel, XFEComProtocol.XFEFAST, streamMode, temperature));
82
82
}
83
83
/// <summary>
84
84
/// 创建一个新的对话,自定义通讯协议
@@ -91,7 +91,7 @@ public class MemorableXFEChatGPT : XFEChatGPTBase
91
91
/// <param name="comProtocol">通信协议</param>
92
92
public void CreateDialog(string dialogId, string system, bool hasMemory, bool streamMode, ChatGPTModel chatGPTModel, XFEComProtocol comProtocol)
93
93
{
94
xFEGPTMemoryDialog.Add(dialogId, new XFEGPTMessageCollection([new XFEGPTMessage(dialogId, new GPTMessage("system", system))], streamMode, chatGPTModel, comProtocol, hasMemory, 0.7));
94
xFEGPTMemoryDialog.Add(dialogId, new XFEGPTMessageCollection([new XFEGPTMessage(dialogId, new GPTMessage("system", system))], hasMemory, chatGPTModel, comProtocol, streamMode, 0.7));
95
95
}
96
96
/// <summary>
97
97
/// 创建一个新的对话,自定义通讯协议
@@ -105,7 +105,7 @@ public class MemorableXFEChatGPT : XFEChatGPTBase
105
105
/// <param name="comProtocol">通信协议</param>
106
106
public void CreateDialog(string dialogId, string system, bool hasMemory, bool streamMode, ChatGPTModel chatGPTModel, double temperature, XFEComProtocol comProtocol)
107
107
{
108
xFEGPTMemoryDialog.Add(dialogId, new XFEGPTMessageCollection([new XFEGPTMessage(dialogId, new GPTMessage("system", system))], streamMode, chatGPTModel, comProtocol, hasMemory, temperature));
108
xFEGPTMemoryDialog.Add(dialogId, new XFEGPTMessageCollection([new XFEGPTMessage(dialogId, new GPTMessage("system", system))], hasMemory, chatGPTModel, comProtocol, streamMode, temperature));
109
109
}
110
110
#endregion
111
111
#region 插入对话
@@ -5,7 +5,7 @@
5
5
<ImplicitUsings>enable</ImplicitUsings>
6
6
<Nullable>enable</Nullable>
7
7
<GenerateDocumentationFile>True</GenerateDocumentationFile>
8
<Version>3.0.3</Version>
8
<Version>3.0.4</Version>
9
9
<Title>XFEExtension</Title>
10
10
<RepositoryUrl>https://github.com/XFEstudio/XFEExtension</RepositoryUrl>
11
11
<AnalysisLevel>latest</AnalysisLevel>
@@ -20,7 +20,7 @@
20
20
<PackageTags>XFE;拓展;GPT;Server;服务器;测试;XFEExtension</PackageTags>
21
21
<PackageReleaseNotes>## 调整
22
22
23
为XFEConsole提供对XUnit测试框架的支持
23
修复了MemorableXFEChatGPT中流式输出和记忆功能传参问题
24
24
25
25
## 新增
26
26