diff --git a/Samples with AI/readme.md b/Samples with AI/readme.md new file mode 100644 index 0000000000..2f1abeb46f --- /dev/null +++ b/Samples with AI/readme.md @@ -0,0 +1,24 @@ +# Senparc.Weixin.Samples powered by AI + +## 说明 + +当前文档用于说明 Senparc.Weixin SDK 结合 AI 的各项能力。 + +当前项目正在构建完善中,预计在 2024 年 7 月 1 日左右正式上线。 + +内容将涵盖: + +1. [ ] 微信公众号 Chat 机器人(文字) +2. [ ] 微信公众号 Chat 机器人(图片) +3. [ ] 微信公众号 Chat 机器人(多模态混合) +4. [ ] 微信公众号带搜索功能的 Chat 机器人 +5. [ ] 企业微信集成 Agent(智能体)机器人 +6. [ ] 使用 RAG 构建知识库问答 + +> 更多示例欢迎发 issue 或群内留言! + +## 代码位置 + +AI 功能将整合在 [/Samples/All/net8-mvc](../Samples/All/net8-mvc/Senparc.Weixin.Sample.Net8/) 集成案例中。 + +更多说明将在对应功能上线后在本文档中补充。 \ No newline at end of file diff --git a/Samples/All/net8-mvc/Senparc.Weixin.Sample.Net8.sln b/Samples/All/net8-mvc/Senparc.Weixin.Sample.Net8.sln index 00223254b5..27f316c0c7 100644 --- a/Samples/All/net8-mvc/Senparc.Weixin.Sample.Net8.sln +++ b/Samples/All/net8-mvc/Senparc.Weixin.Sample.Net8.sln @@ -3,13 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31521.260 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{E72ACEC5-2011-41C7-9A48-34F073D1AEE2}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "01 Libraries", "01 Libraries", "{E72ACEC5-2011-41C7-9A48-34F073D1AEE2}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples.net8", "Samples.net8", "{35139CB3-610E-4922-98AD-08A5D12BFC35}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "03 Samples.net8", "03 Samples.net8", "{35139CB3-610E-4922-98AD-08A5D12BFC35}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{FC72CA5A-5DE9-4902-A5AA-00344FA68B37}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docker", "Docker", "{DCF86D54-CF96-4C69-9385-7AA62B399104}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "02 Tests", "02 Tests", "{FC72CA5A-5DE9-4902-A5AA-00344FA68B37}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Cache", "Cache", "{FDC9A3F1-A2EC-4E44-9093-BE0EE1C17093}" EndProject @@ -76,13 +74,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Senparc.Weixin.TenPayV3.Tes EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Senparc.Weixin.Sample.MP.net8", "..\..\MP\Senparc.Weixin.Sample.MP\Senparc.Weixin.Sample.MP.net8.csproj", "{81A078A9-97D1-446D-88ED-87F4BB484D91}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "不同模块 Samples", "不同模块 Samples", "{34CFB1D8-6025-4E93-A67F-D94DD3B9198F}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3.2 不同微信模块 Samples", "3.2 不同微信模块 Samples", "{34CFB1D8-6025-4E93-A67F-D94DD3B9198F}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "完整 Sample(进阶)", "完整 Sample(进阶)", "{1B168C93-E3E3-4939-8EDC-19CE4E041874}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3.1 完整 Sample(进阶)", "3.1 完整 Sample(进阶)", "{1B168C93-E3E3-4939-8EDC-19CE4E041874}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Senparc.Weixin.Sample.Shared", "..\..\Shared\Senparc.Weixin.Sample.Shared\Senparc.Weixin.Sample.Shared.shproj", "{9FE36012-8B32-488E-96AD-BA7CEDAEEAB8}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common Files", "Common Files", "{20CDE085-A7B1-447E-8875-981D8C3DF535}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "04 Common Files", "04 Common Files", "{20CDE085-A7B1-447E-8875-981D8C3DF535}" ProjectSection(SolutionItems) = preProject Common Files\site.css = Common Files\site.css EndProjectSection @@ -97,6 +95,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Senparc.Weixin.Sample.TenPa EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Senparc.Weixin.Sample.Shared", "..\Senparc.Weixin.Sample.Shared\Senparc.Weixin.Sample.Shared.shproj", "{81A03BCD-B887-4A40-8867-FF6B8D61CFC3}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3.3 人工智能(AI)", "3.3 人工智能(AI)", "{AB1460AF-4BE8-4CC2-AF3B-3473B5A41778}" + ProjectSection(SolutionItems) = preProject + ..\..\..\Samples with AI\readme.md = ..\..\..\Samples with AI\readme.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -691,6 +694,7 @@ Global {94C58964-01E0-4AA0-AF98-5851208D9755} = {34CFB1D8-6025-4E93-A67F-D94DD3B9198F} {D70B89B9-27BC-45DD-A908-4282F101B409} = {34CFB1D8-6025-4E93-A67F-D94DD3B9198F} {81A03BCD-B887-4A40-8867-FF6B8D61CFC3} = {1B168C93-E3E3-4939-8EDC-19CE4E041874} + {AB1460AF-4BE8-4CC2-AF3B-3473B5A41778} = {35139CB3-610E-4922-98AD-08A5D12BFC35} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DC7AD3EC-AB37-497E-925B-DCD5129FE6D3} diff --git a/Samples/MP/readme.md b/Samples/MP/readme.md index 28bf5f76d6..604358fd5a 100644 --- a/Samples/MP/readme.md +++ b/Samples/MP/readme.md @@ -6,8 +6,8 @@ ## 打开全量 Sample 项目 -当前您仍然可以使用 [全量 Sample](../All/net6-mvc/) 解决方案打开,并将 Senparc.Weixin.Sample.MP 项目设为启动项目。 +当前您仍然可以使用 [全量 Sample](../All/net8-mvc/) 解决方案打开,并将 Senparc.Weixin.Sample.MP 项目设为启动项目。 ## 引用源码调试 -当前项目默认使用 Nuget 包引用,如果您想直接引用源码调试,可以打开 [全量 Sample](../All/net6-mvc/),并编辑当前项目 .csproj 文件,根据注释,删除 Nuget 包引用代码,并启用源码项目引用。 +当前项目默认使用 Nuget 包引用,如果您想直接引用源码调试,可以打开 [全量 Sample](../All/net8-mvc/),并编辑当前项目 .csproj 文件,根据注释,删除 Nuget 包引用代码,并启用源码项目引用。 diff --git a/Samples/readme.md b/Samples/readme.md index 11812d23d3..9c27cac9cc 100644 --- a/Samples/readme.md +++ b/Samples/readme.md @@ -1,6 +1,6 @@ # Senparc.Weixin SDK Sample -本文件夹内项目,用于演示各模块的使用。 +本文件夹内项目,用于演示微信各平台模块的使用。 > 注意:每个模块中会包含多项功能,请根据实际需要选用。 diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work.Test/AdvancedAPIs/Webhook/WebhookApiTests.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work.Test/AdvancedAPIs/Webhook/WebhookApiTests.cs index 107466fbdc..a8822bdabb 100644 --- a/src/Senparc.Weixin.Work/Senparc.Weixin.Work.Test/AdvancedAPIs/Webhook/WebhookApiTests.cs +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work.Test/AdvancedAPIs/Webhook/WebhookApiTests.cs @@ -1,23 +1,29 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Senparc.Weixin.Work.AdvancedAPIs.Webhook; +using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Text; +using static System.Net.WebRequestMethods; +using Senparc.WeixinTests; +using System.Threading.Tasks; -namespace Senparc.Weixin.Work.Test.vs2017.AdvancedAPIs.Webhook +namespace Senparc.Weixin.Work.AdvancedAPIs.Webhook.Tests { - [TestClass] - public class WebhookApiTests + [TestClass()] + public class WebhookApiTests:BaseTest { - const string key = "[your key]"; - [TestMethod] - public void SendTestTest() + [TestMethod()] + public async Task SendTextAsyncTest() { try { - Work.AdvancedAPIs.Webhook.WebhookApi.SendText(key, "测试消息"); + var key = "Your Key"; + var result =await Work.AdvancedAPIs.Webhook.WebhookApi.SendTextAsync(key, "测试消息"); + Console.WriteLine(result); } - catch + catch (Exception ex) { + Console.WriteLine(ex); Assert.Fail(); } } diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/Webhook/WebhookApi.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/Webhook/WebhookApi.cs index 9aab6e01c0..5cfcd65a76 100644 --- a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/Webhook/WebhookApi.cs +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/Webhook/WebhookApi.cs @@ -37,6 +37,7 @@ namespace Senparc.Weixin.Work.AdvancedAPIs.Webhook public static class WebhookApi { private static string _urlFormat = Config.ApiWorkHost + "/cgi-bin/webhook/send?key={0}"; + #region 同步方法 /// /// 群机器人发送文本信息方法