Skip to content

Commit 6ed82a9

Browse files
committed
更新 Sample
1 parent 92668d3 commit 6ed82a9

File tree

6 files changed

+21
-26
lines changed

6 files changed

+21
-26
lines changed

Samples/Senparc.Weixin.AI.MPSample/App_Data/skills/ResponseChooseSkill/ResponseMessageChoose/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"presence_penalty": 0.6,
1010
"frequency_penalty": 0.0,
1111
"stop_sequences": [
12-
"# done"
12+
"[done]"
1313
]
1414
}
1515
}

Samples/Senparc.Weixin.AI.MPSample/App_Data/skills/ResponseChooseSkill/ResponseMessageChoose/skprompt.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ Example:
99
Input: What's the mean of animal?
1010
Output: {"MessageType":"Text", "Result":"The word \"animal\" is a broad term that refers to living organisms that are not plants or fungi, and it encompasses a wide range of species with diverse characteristics. Therefore, it is not possible to calculate a mean for the term "animal" as it is not a numerical value or a quantitative measure."}
1111

12+
Input: Can you tell me what's in the image?
13+
Output: [{""MessageType"":""Text"", ""Result"":""It's an image of a panda driving a car in the sky, with the car flying high and the panda looking happy and excited.""}]
14+
15+
Input: Create me a picture with sky and birds.
16+
Output: [{""MessageType"":""Image"", ""Result"":""The sky is filled with colorful birds.""}]
17+
1218
Input: Give me an image shows the spring of China.
1319
Output: {"MessageType":"Image", "Result":"Generate a high-quality and visually stunning image that depicts the beauty of spring in China, with a focus on blooming flowers, lush green landscapes, and perhaps a cultural or historical element such as a traditional Chinese garden or temple."}
1420

15-
# done
21+
[done]
1622

1723
Now tell me the follow message's output:
1824
{{$input}}

Samples/Senparc.Weixin.AI.MPSample/CustomMessageHandler.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public class CustomMessageHandler : MessageHandler<DefaultMpMessageContext>
3131
3232
===开源地址===
3333
Senparc.AI模块:https://github.com/Senparc/Senparc.AI
34-
微信SDK:https://github.com/JeffreySu/WeiXinMPSDK";
34+
Senparc.Weixin.AI:https://github.com/Senparc/Senparc.Weixin.AI
35+
微信SDK:https://github.com/JeffreySu/WeiXinMPSDK
36+
";
3537

3638
private readonly IBaseObjectCacheStrategy _cache;
3739
private string GetCacheKey(string openId) => $"SenparcAI-Chat-{openId}";
@@ -70,7 +72,7 @@ public override async Task<IResponseMessageBase> OnTextRequestAsync(RequestMessa
7072
await _cache.SetAsync(cacheKey, messages, TimeSpan.FromHours(1));
7173
responseMessage.Content = "Chat 准备就绪,请开始对话!";
7274

73-
//TODO:清空 Senparc.AI 层面的对话
75+
//清空 Senparc.AI 层面的对话
7476
ReponseMessageFactory.iWantToRunCollection.TryRemove(OpenId, out _);
7577
return responseMessage;
7678
});

Samples/Senparc.Weixin.AI.MPSample/appsettings.-remove-here-.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
//微信全局
1818
"IsDebug": true,
1919
//公众号
20-
"Token": "YourToken",
20+
"Token": "weixin",
2121
"EncodingAESKey": "YourEncodingAESKey",
22-
"WeixinAppId": "YourWeixinAppId",
23-
"WeixinAppSecret": "YourWeixinAppSecret"
22+
"WeixinAppId": "wxe273c3a02e09ff8c",
23+
"WeixinAppSecret": "631f30445f640e1a870f1ef79aa543bd"
2424
},
2525
//Senparc.AI 设置
2626
"SenparcAiSetting": {

src/Senparc.Weixin.AI/ReponseMessageFactory.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ public class ReponseMessageFactory
3636

3737
IServiceProvider ServiceProvider { get; set; }
3838

39-
40-
4139
public ReponseMessageFactory(IServiceProvider serviceProvider)
4240
{
4341
ServiceProvider = serviceProvider;
@@ -68,7 +66,7 @@ public async Task<string> GetResponseMessageByPlanAsync(IAiHandler aiHandler, st
6866
var skillsDirectory = Senparc.CO2NET.Utilities.ServerUtility.ContentRootMapPath("~/App_Data/skills");/* Path.Combine(dir, "..", "..", "..", "skills");*/
6967
await Console.Out.WriteLineAsync("skillsDirectory:" + skillsDirectory);
7068
//var skillList = iWantToRun.ImportSkillFromDirectory(skillsDirectory, "ResponseChooseSkill").skillList;
71-
iWantToRun.ImportSkill(new SenparcWeixinSkills(iWantToRun.Kernel), "BuildResponseMessage");
69+
//iWantToRun.ImportSkill(new SenparcWeixinSkills(iWantToRun.Kernel), "BuildResponseMessage");
7270

7371
//var ask = "I want to know which program language is the best one?";
7472

src/Senparc.Weixin.AI/WeixinSkills/SenparcWeixinSkills.cs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,23 @@ public class SenparcWeixinSkills
2121

2222
private const string BUILD_RESPONSE_MESSAGE_DEFINITION = @"Determine the type of message and result that should be returned based on the input information.
2323
24-
The context of the request may contains several history messages, only the last message can determine the type of the message, which always using the key of ""input"" in context.
25-
2624
There are two types of message:
2725
- Text: just need return text, without image required. The Result parameter will be returned as a ChatBot's reply.
2826
- Image: need to generate image. The Result parameter will give a better prompt to generate a image by general image generate engine.
2927
30-
Examples:
28+
Example:
3129
3230
Input: What's the mean of animal?
33-
Output: [{""MessageType"":""Text"", ""Result"":""The word \""animal\"" is a broad term that refers to living organisms that are not plants or fungi, and it encompasses a wide range of species with diverse characteristics. Therefore, it is not possible to calculate a mean for the term ""animal"" as it is not a numerical value or a quantitative measure.""}]
34-
35-
Input: Can you tell me what's in the image?
36-
Output: [{""MessageType"":""Text"", ""Result"":""It's an image of a panda driving a car in the sky, with the car flying high and the panda looking happy and excited.""}]
37-
38-
Input: Give me a picture with sky and bird.
39-
Output: [{""MessageType"":""Image"", ""Result"":""The sky is filled with colorful birds.""}]
31+
Output: {""MessageType"":""Text"", ""Result"":""The word \""animal\"" is a broad term that refers to living organisms that are not plants or fungi, and it encompasses a wide range of species with diverse characteristics. Therefore, it is not possible to calculate a mean for the term ""animal"" as it is not a numerical value or a quantitative measure.""}
4032
4133
Input: Give me an image shows the spring of China.
42-
Output: [{""MessageType"":""Image"", ""Result"":""Generate a high-quality and visually stunning image that depicts the beauty of spring in China, with a focus on blooming flowers, lush green landscapes, and perhaps a cultural or historical element such as a traditional Chinese garden or temple.""}]
34+
Output: {""MessageType"":""Image"", ""Result"":""Generate a high-quality and visually stunning image that depicts the beauty of spring in China, with a focus on blooming flowers, lush green landscapes, and perhaps a cultural or historical element such as a traditional Chinese garden or temple.""}
4335
4436
[done]
4537
46-
47-
The original Output is JSON format, I want to get an XML format result, do the parse first. Just left JSON information without any other 'appendToResult' information.
48-
4938
Now tell me the follow message's output:
50-
Input: {{$input}}
51-
Output: ";
39+
{{$input}}
40+
The Output is JSON format.";
5241

5342
public SenparcWeixinSkills(IKernel kernel)
5443
{

0 commit comments

Comments
 (0)