{"id":1056,"date":"2025-03-13T23:56:04","date_gmt":"2025-03-14T06:56:04","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/?p=1056"},"modified":"2025-03-13T23:56:04","modified_gmt":"2025-03-14T06:56:04","slug":"net-ai-%e6%a8%a1%e6%9d%bf%e7%8e%b0%e5%b7%b2%e6%8f%90%e4%be%9b%e9%a2%84%e8%a7%88%e7%89%88","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/net-ai-%e6%a8%a1%e6%9d%bf%e7%8e%b0%e5%b7%b2%e6%8f%90%e4%be%9b%e9%a2%84%e8%a7%88%e7%89%88\/","title":{"rendered":".NET AI \u6a21\u677f\u73b0\u5df2\u63d0\u4f9b\u9884\u89c8\u7248"},"content":{"rendered":"<p style=\"text-align: center;\"><em><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u672c\u6587\u7ffb\u8bd1\u81ea<a class=\"read-more\" href=\"https:\/\/devblogs.microsoft.com\/dotnet\/author\/jordanmatthiesen\" data-bi-area=\"body_author_top\" data-bi-id=\"post_page_body_author_top_name\" data-bi-name=\"Jordan Matthiesen\">Jordan Matthiesen<\/a>\u7684<a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/announcing-dotnet-ai-template-preview1\/\">.NET AI Template Now Available in Preview<\/a><\/span><\/em><\/p>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u60f3\u8981\u5f00\u59cb AI \u5f00\u53d1\uff0c\u5374\u4e0d\u786e\u5b9a\u4ece\u54ea\u91cc\u5165\u624b\uff1f\u6211\u7ed9\u60a8\u5e26\u6765\u4e86\u4e00\u4e2a\u597d\u6d88\u606f\u2014\u2014\u6211\u4eec\u5168\u65b0\u7684 AI \u804a\u5929 Web \u5e94\u7528\u6a21\u677f\u73b0\u5df2\u63d0\u4f9b\u9884\u89c8\u7248\uff01\u8fd9\u4e2a\u6a21\u677f\u662f\u6211\u4eec\u4e0d\u65ad\u52aa\u529b\u7684\u4e00\u90e8\u5206\uff0c\u65e8\u5728\u901a\u8fc7\u5728Visual Studio\uff0cVisual Studio Code \u548c .NET CLI \u4e2d\u63d0\u4f9b\u811a\u624b\u67b6\u548c\u6307\u5bfc\uff0c\u8ba9\u4f7f\u7528 .NET \u8fdb\u884c AI \u5f00\u53d1\u53d8\u5f97\u66f4\u5bb9\u6613\u4e0a\u624b\u3002\u00a0<\/span><\/p>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u8bf7\u6ce8\u610f\uff0c\u8be5\u6a21\u677f\u76ee\u524d\u4e3a\u9884\u89c8\u7248\uff0c\u672a\u6765\u7248\u672c\u53ef\u80fd\u4f1a\u6839\u636e\u60a8\u7684\u53cd\u9988\u548c AI \u7684\u5feb\u901f\u53d1\u5c55\u8fdb\u884c\u8c03\u6574\u3002\u00a0<\/span><\/p>\n<h2><span style=\"font-family: tahoma, arial, helvetica, sans-serif; font-size: 18pt;\"><b>\u7acb\u5373\u5b89\u88c5\u6a21\u677f<\/b>\u00a0<\/span><\/h2>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u5982\u679c\u60f3\u8981\u5f00\u59cb\u4f7f\u7528\u8be5\u6a21\u677f\u7684\u9996\u4e2a\u9884\u89c8\u7248\uff0c\u60a8\u9700\u8981\u5728\u7ec8\u7aef\u4e2d\u5b89\u88c5 Microsoft.Extensions.AI.Templates\u3002\u53ea\u9700\u8fd0\u884c\uff1a\u00a0<\/span><\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">dotnet new install Microsoft.Extensions.AI.Templates<\/code><\/pre>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u8be5\u6a21\u677f\u5373\u53ef\u5728 Visual Studio\uff0cVisual Studio Code\uff08\u9700\u5b89\u88c5 C# Dev Kit\uff09\u4e2d\u4f7f\u7528\uff0c\u6216\u8005\u60a8\u4e5f\u53ef\u4ee5\u5728\u5de5\u4f5c\u76ee\u5f55\u4e2d\u8fd0\u884c\u547d\u4ee4 <code>dotnet new aichatweb<\/code> \u6765\u521b\u5efa\u5b83\u3002\u00a0<\/span><\/p>\n<h2><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\"><b>\u5165\u95e8\u6307\u5357\uff1a.NET AI \u804a\u5929\u6a21\u677f<\/b>\u00a0<\/span><\/h2>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">.NET AI \u804a\u5929\u6a21\u677f\u65e8\u5728\u5e2e\u52a9\u60a8\u5feb\u901f\u6784\u5efa\u4e00\u4e2a\u57fa\u4e8e AI \u7684\u804a\u5929\u5e94\u7528\u6765\u4f7f\u7528\u81ea\u5b9a\u4e49\u6570\u636e\u8fdb\u884c\u5bf9\u8bdd\u3002\u6b64\u6b21\u9996\u4e2a\u7248\u672c\u6ce8\u91cd\u57fa\u4e8e Blazor \u7684 Web \u5e94\u7528\uff0c\u5e76\u4f7f\u7528 <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/introducing-microsoft-extensions-ai-preview\">Microsoft.Extensions.AI<\/a> \u548c <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/introducing-microsoft-extensions-vector-data\">Microsoft.Extensions.VectorData<\/a> \u62bd\u8c61\u5e93\u6784\u5efa\u3002\u8be5\u6a21\u677f\u91c7\u7528\u4e86\u5e38\u89c1\u7684\u68c0\u7d22\u589e\u5f3a\u751f\u6210\uff08RAG\uff09\u6a21\u5f0f\uff0c\u7528\u4e8e\u804a\u5929\u5e94\u7528\u5f00\u53d1\u3002\u00a0<\/span><\/p>\n<h3><span style=\"font-family: tahoma, arial, helvetica, sans-serif; font-size: 14pt;\"><b>\u5173\u952e\u529f\u80fd\u548c\u914d\u7f6e\u9009\u9879<\/b>\u00a0<\/span><\/h3>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"3\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"1\" data-aria-level=\"1\"><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\"><b>\u4e0e\u81ea\u5b9a\u4e49\u6570\u636e\u804a\u5929<\/b>\uff1a\u8be5\u6a21\u677f\u5141\u8bb8\u60a8\u521b\u5efa\u57fa\u4e8e\u804a\u5929\u7684 UI\uff0c\u5e76\u4f7f\u7528 RAG \u6a21\u5f0f\u4e0e\u793a\u4f8b PDF \u6216\u60a8\u7684\u81ea\u5b9a\u4e49\u6570\u636e\u8fdb\u884c\u4ea4\u4e92\u3002\u00a0<\/span><\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"3\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"2\" data-aria-level=\"1\"><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\"><b>\u672c\u5730\u4e0e Azure \u96c6\u6210<\/b>\uff1a\u652f\u6301\u672c\u5730\u5411\u91cf\u5b58\u50a8\u4ee5\u8fdb\u884c\u539f\u578b\u5f00\u53d1\uff0c\u540c\u65f6\u4e5f\u652f\u6301 Azure AI Search \u4ee5\u5b9e\u73b0\u66f4\u9ad8\u7ea7\u7684\u914d\u7f6e\u3002\u00a0<\/span><\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"3\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"3\" data-aria-level=\"1\"><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\"><b>\u53ef\u81ea\u5b9a\u4e49\u7684\u4ee3\u7801<\/b>\uff1a\u751f\u6210\u7684\u4ee3\u7801\u5305\u542b\u7528\u4e8e\u804a\u5929\u4ea4\u4e92\u3001\u5f15\u7528\u8ffd\u8e2a\u548c\u540e\u7eed\u5efa\u8bae\u7684 UI \u7ec4\u4ef6\uff0c\u60a8\u53ef\u4ee5\u6839\u636e\u9700\u8981\u81ea\u5b9a\u4e49\u6216\u79fb\u9664\u8fd9\u4e9b\u7ec4\u4ef6\u3002\u00a0<\/span><\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"3\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"4\" data-aria-level=\"1\"><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\"><b>\u6570\u636e\u63d0\u53d6<\/b>\uff1a\u6a21\u677f\u5305\u542b\u6570\u636e\u63d0\u53d6\u3001\u7f13\u5b58\u548c\u5904\u7406\u7684\u4ee3\u7801\uff0c\u4f7f\u60a8\u80fd\u591f\u5904\u7406\u5404\u79cd\u6570\u636e\u6e90\u548c\u683c\u5f0f\u3002\u00a0<\/span><\/li>\n<\/ul>\n<h3><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\"><b>\u5728 Visual Studio \u4e2d\u4f7f\u7528\u6a21\u677f<\/b>\u00a0<\/span><\/h3>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u901a\u8fc7\u547d\u4ee4\u884c\u5b89\u88c5\u6a21\u677f\u540e\uff0c\u60a8\u53ef\u4ee5\u5728 Visual Studio \u4e2d\u901a\u8fc7<b>\u6587\u4ef6<\/b> &gt; <b>\u65b0\u5efa<\/b><b> &gt; <\/b><b>\u9879\u76ee<\/b>\u83dc\u5355\u627e\u5230\u8be5\u6a21\u677f\u3002\u60a8\u53ef\u4ee5\u641c\u7d22 AI Chat\uff0c\u6216\u9009\u62e9AI\u9879\u76ee\u7c7b\u578b\u6765\u67e5\u627e\u8be5\u6a21\u677f\u3002\u00a0<\/span><\/p>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\" data-ccp-props=\"{}\"><a href=\"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-content\/uploads\/sites\/75\/2025\/03\/visual-studio-new-project.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1057\" src=\"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-content\/uploads\/sites\/75\/2025\/03\/visual-studio-new-project.png\" alt=\"Image visual studio new project\" width=\"890\" height=\"258\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-content\/uploads\/sites\/75\/2025\/03\/visual-studio-new-project.png 890w, https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-content\/uploads\/sites\/75\/2025\/03\/visual-studio-new-project-300x87.png 300w, https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-content\/uploads\/sites\/75\/2025\/03\/visual-studio-new-project-768x223.png 768w\" sizes=\"(max-width: 890px) 100vw, 890px\" \/><\/a><\/span><\/p>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u9009\u62e9\u9879\u76ee\u540d\u79f0\u548c\u5b58\u50a8\u4f4d\u7f6e\u540e\uff0c\u60a8\u53ef\u4ee5\u9009\u62e9\u4e00\u4e2a AI \u6a21\u578b\u63d0\u4f9b\u5546\u548c\u5411\u91cf\u5b58\u50a8\u6765\u5f00\u59cb\u4f7f\u7528\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u4f7f\u7528 GitHub Models \u642d\u914d\u672c\u5730\u5411\u91cf\u5b58\u50a8\uff0c\u8fd9\u662f\u6700\u7b80\u5355\u7684\u5165\u95e8\u65b9\u5f0f\uff0c\u51e0\u4e4e\u65e0\u9700\u989d\u5916\u8bbe\u7f6e\u3002<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-content\/uploads\/sites\/75\/2025\/03\/visual-studio-template-options.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1058\" src=\"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-content\/uploads\/sites\/75\/2025\/03\/visual-studio-template-options.png\" alt=\"Image visual studio template options\" width=\"601\" height=\"362\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-content\/uploads\/sites\/75\/2025\/03\/visual-studio-template-options.png 601w, https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-content\/uploads\/sites\/75\/2025\/03\/visual-studio-template-options-300x181.png 300w\" sizes=\"(max-width: 601px) 100vw, 601px\" \/><\/a><\/p>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u60a8\u53ef\u4ee5\u4ece <a href=\"https:\/\/aka.ms\/dotnet\/ai-templates\">.NET AI \u6a21\u677f\u6587\u6863<\/a>\u4e2d\u4e86\u89e3\u6bcf\u4e2a\u9009\u9879\u3002\u00a0<\/span><\/p>\n<h3><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\"><b>\u4f7f\u7528 Visual Studio Code \u548c C# <\/b><b>Dev Kit<\/b><\/span><\/h3>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u8981\u5728 Visual Studio Code \u4e2d\u4f7f\u7528\u6a21\u677f\uff0c\u8bf7\u5148\u5b89\u88c5 <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-dotnettools.csdevkit\">C# Dev Kit<\/a> \u6269\u5c55\u3002\u7136\u540e\uff0c\u4f7f\u7528 <b>.NET\uff1aNew Project\u2026<\/b> \u547d\u4ee4\u521b\u5efa\u65b0\u9879\u76ee\uff1a\u00a0<\/span><\/p>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\" data-ccp-props=\"{}\"><a href=\"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-content\/uploads\/sites\/75\/2025\/03\/AITemplatePreview-VSCode.gif\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1059\" src=\"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-content\/uploads\/sites\/75\/2025\/03\/AITemplatePreview-VSCode.gif\" alt=\"Image AITemplatePreview VSCode\" width=\"800\" height=\"450\" \/><\/a><\/span><\/p>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u8fd9\u5c06\u4f7f\u7528 GitHub Models \u6a21\u578b\u63d0\u4f9b\u5546\u548c\u672c\u5730\u5411\u91cf\u5b58\u50a8\u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\u3002\u60a8\u53ef\u4ee5\u4ece <a href=\"https:\/\/aka.ms\/dotnet\/ai-templates\">.NET AI \u6a21\u677f\u6587\u6863<\/a>\u4e2d\u4e86\u89e3\u66f4\u591a\u9009\u9879\u3002\u00a0<\/span><\/p>\n<h3><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\"><b>\u4f7f\u7528\u60a8\u81ea\u5df1\u7684\u6570\u636e\u8fdb\u884c\u5bf9\u8bdd<\/b><\/span><\/h3>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u6b64\u6a21\u677f\u5305\u542b\u4e24\u4e2a\u793a\u4f8b PDF \u6587\u4ef6\uff0c\u5e76\u63d0\u4f9b\u6570\u636e\u63d0\u53d6\u4ee3\u7801\u6765\u5904\u7406\u8fd9\u4e9b PDF\u3002\u6b64\u6570\u636e\u63d0\u53d6\u4ee3\u7801\u975e\u5e38\u7075\u6d3b\uff0c\u56e0\u6b64\u60a8\u53ef\u4ee5\u66ff\u6362\u793a\u4f8b PDF\u3002\u8981\u4f7f\u7528\u60a8\u81ea\u5df1\u7684\u6570\u636e\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff1a\u00a0<\/span><\/p>\n<ol>\n<li><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u5982\u679c\u9879\u76ee\u6b63\u5728\u8fd0\u884c\uff0c\u8bf7\u505c\u6b62\u5b83\u3002\u00a0<\/span><\/li>\n<li><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u4ece \/wwwroot\/Data \u6587\u4ef6\u5939\u4e2d\u79fb\u9664\u793a\u4f8b PDF \u6587\u4ef6\u3002\u00a0<\/span><\/li>\n<li><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u5c06\u60a8\u81ea\u5df1\u7684 PDF \u6587\u4ef6\u6dfb\u52a0\u5230 \/wwwroot\/Data \u6587\u4ef6\u5939\u3002\u00a0<\/span><\/li>\n<li><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u518d\u6b21\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u3002\u00a0<\/span><\/li>\n<\/ol>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u5728\u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u65f6\uff0c\u6570\u636e\u63d0\u53d6\u4ee3\u7801\uff08\u4f4d\u4e8e \/Services\/Ingestion\/DataIngestor.cs\uff09\u5c06\u6bd4\u8f83 Data \u6587\u4ef6\u5939\u7684\u5185\u5bb9\uff1b\u5b83\u4f1a\u4ece\u914d\u7f6e\u7684\u5411\u91cf\u5b58\u50a8\u4e2d\u5220\u9664\u65e7\u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u65b0\u6587\u4ef6\u3002\u6ce8\u610f\uff1a\u6839\u636e\u6587\u4ef6\u7684\u6570\u91cf\u548c\u5927\u5c0f\uff0c\u60a8\u53ef\u80fd\u4f1a\u9047\u5230\u914d\u7f6e\u7684 AI \u6a21\u578b\u63d0\u4f9b\u7a0b\u5e8f\u7684\u914d\u989d\u548c\u901f\u7387\u9650\u5236\u3002\u5f53\u8fbe\u5230\u9650\u5236\u65f6\uff0c\u60a8\u53ef\u80fd\u4f1a\u770b\u5230\u9519\u8bef\u6d88\u606f\uff0c\u6216\u5728\u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u65f6\u51fa\u73b0\u8f83\u957f\u7684\u5ef6\u8fdf\u3002\u6709\u5173\u6545\u969c\u6392\u9664\u7684\u5e2e\u52a9\uff0c\u8bf7\u53c2\u9605 <a href=\"https:\/\/aka.ms\/dotnet\/ai-templates\">AI \u6a21\u677f\u6587\u6863<\/a>\u3002\u00a0<\/span><\/p>\n<h3><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\"><b>\u6269\u5c55\u804a\u5929\u673a\u5668\u4eba\u7684\u884c\u4e3a<\/b>\u00a0<\/span><\/h3>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u8be5\u4ee3\u7801\u4f7f\u7528 Microsoft.Extensions.AI \u6784\u5efa\uff0c\u8fd9\u4f7f\u5f97\u63d2\u5165\u81ea\u5b9a\u4e49\u884c\u4e3a\u53d8\u5f97\u975e\u5e38\u7b80\u5355\u3002\u60a8\u53ef\u4ee5\u6388\u4e88\u804a\u5929\u673a\u5668\u4eba\u8c03\u7528\u4efb\u4f55 C# \u51fd\u6570\u7684\u6743\u9650\u3002\u8fd9\u53ef\u4ee5\u6269\u5c55\u5176\u529f\u80fd\uff0c\u5305\u62ec\u68c0\u7d22\u5176\u4ed6\u6570\u636e\u6216\u91c7\u53d6\u884c\u52a8\u3002\u00a0<\/span><\/p>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u4f5c\u4e3a\u4e00\u4e2a\u975e\u5e38\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u60a8\u53ef\u4ee5\u5c1d\u8bd5\u6388\u4e88\u5b83\u8bbf\u95ee\u201c\u5929\u6c14\u201d\u6570\u636e\u7684\u6743\u9650\u3002\u5728 Pages\/Chat\/Chat.razor \u4e2d\uff0c\u5728 @code \u5757\u4e2d\u5b9a\u4e49\u4e00\u4e2a C# \u51fd\u6570\uff1a\u00a0<\/span><\/p>\n<pre class=\"prettyprint language-cs language-csharp\"><code class=\"language-cs language-csharp\">private async Task&lt;string&gt; GetWeather([Description(\"The city, correctly capitalized\")] string city)\r\n{\r\n    string[] weatherValues = [\"Sunny\", \"Cloudy\", \"Rainy\", \"Snowy\", \"Balmy\", \"Bracing\"];\r\n    return city == \"London\" ? \"Drizzle\" : weatherValues[Random.Shared.Next(weatherValues.Length)];\r\n}<\/code><\/pre>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u7136\u540e\uff0c\u5728 OnInitialized \u65b9\u6cd5\u4e2d\uff0c\u66f4\u65b0 chatOptions.Tools \u4ee5\u5305\u542b\u60a8\u7684\u65b9\u6cd5\uff1a\u00a0<\/span><\/p>\n<pre class=\"prettyprint language-cs language-csharp\"><code class=\"language-cs language-csharp\">chatOptions.Tools =\r\n[\r\n    AIFunctionFactory.Create(SearchAsync),\r\n    AIFunctionFactory.Create(GetWeather)\r\n];<\/code><\/pre>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u73b0\u5728\u5c1d\u8bd5\u5728 GetWeather \u65b9\u6cd5\u4e2d\u8bbe\u7f6e\u65ad\u70b9\uff0c\u5e76\u5411\u804a\u5929\u673a\u5668\u4eba\u8be2\u95ee\u5929\u6c14\u3002\u60a8\u4f1a\u53d1\u73b0\u5b83\u4f1a\u8c03\u7528\u60a8\u7684\u65b9\u6cd5\uff0c\u5e76\u5728\u56de\u7b54\u4e2d\u4f7f\u7528\u7ed3\u679c\u3002\u00a0<\/span><\/p>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\" data-ccp-props=\"{&quot;335559739&quot;:0}\"><a href=\"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-content\/uploads\/sites\/75\/2025\/03\/weather-code-example.png\"><img decoding=\"async\" class=\"alignnone wp-image-1060\" src=\"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-content\/uploads\/sites\/75\/2025\/03\/weather-code-example.png\" alt=\"Image weather code example\" width=\"815\" height=\"602\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-content\/uploads\/sites\/75\/2025\/03\/weather-code-example.png 1040w, https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-content\/uploads\/sites\/75\/2025\/03\/weather-code-example-300x222.png 300w, https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-content\/uploads\/sites\/75\/2025\/03\/weather-code-example-1024x756.png 1024w, https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-content\/uploads\/sites\/75\/2025\/03\/weather-code-example-768x567.png 768w\" sizes=\"(max-width: 815px) 100vw, 815px\" \/><\/a><\/span><\/p>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u60a8\u53ef\u4ee5\u4f7f\u7528\u6b64\u65b9\u6cd5\u4ece\u5916\u90e8\u7cfb\u7edf\u68c0\u7d22\u4efb\u4f55\u4fe1\u606f\uff0c\u5305\u62ec\u901a\u8fc7\u5f02\u6b65\u8c03\u7528\u3002\u8bf7\u8bb0\u4f4f\uff0c\u4ece LLM \u4f20\u5165\u7684\u53c2\u6570\u5e94\u88ab\u89c6\u4e3a\u4e0d\u53ef\u4fe1\u7684\u8f93\u5165\u3002\u00a0<\/span><\/p>\n<h2 aria-level=\"2\"><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\"><b>\u672a\u6765\u5c55\u671b \u2013 \u5206\u4eab\u60a8\u7684\u60f3\u6cd5<\/b>\u00a0<\/span><\/h2>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u5728\u672a\u6765\u7684\u7248\u672c\u4e2d\uff0c\u6211\u4eec\u8ba1\u5212\u6269\u5c55\u6a21\u677f\u5e93\uff0c\u65b0\u589e AI \u63a7\u5236\u53f0\u6a21\u677f\u3001Minimal API \u6a21\u677f\uff0c\u652f\u6301 .NET Aspire\uff0c\u5e76\u5c06\u8fd9\u4e9b\u6a21\u677f\u9ed8\u8ba4\u5305\u542b\u5728 .NET SDK \u4e2d\u3002\u6211\u4eec\u8fd8\u5c06\u63a2\u7d22\u5bf9 Azure AI Foundry \u7684\u652f\u6301\uff0c\u5e76\u4e0e Semantic Kernel \u56e2\u961f\u5408\u4f5c\uff0c\u4e3a Semantic Kernel \u7528\u6237\u6269\u5c55\u6a21\u677f\u9009\u9879\u3002\u00a0<\/span><\/p>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">\u6211\u4eec\u5e0c\u671b\u542c\u53d6\u60a8\u7684\u53cd\u9988\uff0c\u5e2e\u52a9\u6539\u8fdb\u8fd9\u4e9b\u6a21\u677f\u3002\u8bf7<a href=\"https:\/\/aka.ms\/dotnet-chat-template-survey\">\u5206\u4eab\u60a8\u5173\u4e8e\u6a21\u677f\u7684\u770b\u6cd5<\/a>\u2014\u2014\u54ea\u4e9b\u65b9\u9762\u5bf9\u60a8\u6709\u7528\uff0c\u4ee5\u53ca\u60a8\u5e0c\u671b\u770b\u5230\u54ea\u4e9b\u6539\u53d8\uff01\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u7ffb\u8bd1\u81eaJordan Matthiesen\u7684.NET AI Template Now Available in Preview \u60f3\u8981\u5f00\u59cb AI \u5f00\u53d1\uff0c\u5374\u4e0d\u786e\u5b9a\u4ece\u54ea\u91cc\u5165\u624b\uff1f\u6211\u7ed9\u60a8\u5e26\u6765\u4e86\u4e00\u4e2a\u597d\u6d88\u606f\u2014\u2014\u6211\u4eec\u5168\u65b0\u7684 AI \u804a\u5929 Web \u5e94\u7528\u6a21\u677f\u73b0\u5df2\u63d0\u4f9b\u9884\u89c8\u7248\uff01\u8fd9\u4e2a\u6a21\u677f\u662f\u6211\u4eec\u4e0d\u65ad\u52aa\u529b\u7684\u4e00\u90e8\u5206\uff0c\u65e8\u5728\u901a\u8fc7\u5728Visual Studio\uff0cVisual Studio Code \u548c .NET CLI \u4e2d\u63d0\u4f9b\u811a\u624b\u67b6\u548c\u6307\u5bfc\uff0c\u8ba9\u4f7f\u7528 .NET \u8fdb\u884c AI \u5f00\u53d1\u53d8\u5f97\u66f4\u5bb9\u6613\u4e0a\u624b\u3002\u00a0 \u8bf7\u6ce8\u610f\uff0c\u8be5\u6a21\u677f\u76ee\u524d\u4e3a\u9884\u89c8\u7248\uff0c\u672a\u6765\u7248\u672c\u53ef\u80fd\u4f1a\u6839\u636e\u60a8\u7684\u53cd\u9988\u548c AI \u7684\u5feb\u901f\u53d1\u5c55\u8fdb\u884c\u8c03\u6574\u3002\u00a0 \u7acb\u5373\u5b89\u88c5\u6a21\u677f\u00a0 \u5982\u679c\u60f3\u8981\u5f00\u59cb\u4f7f\u7528\u8be5\u6a21\u677f\u7684\u9996\u4e2a\u9884\u89c8\u7248\uff0c\u60a8\u9700\u8981\u5728\u7ec8\u7aef\u4e2d\u5b89\u88c5 Microsoft.Extensions.AI.Templates\u3002\u53ea\u9700\u8fd0\u884c\uff1a\u00a0 dotnet new install Microsoft.Extensions.AI.Templates \u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u8be5\u6a21\u677f\u5373\u53ef\u5728 Visual Studio\uff0cVisual Studio Code\uff08\u9700\u5b89\u88c5 C# Dev Kit\uff09\u4e2d\u4f7f\u7528\uff0c\u6216\u8005\u60a8\u4e5f\u53ef\u4ee5\u5728\u5de5\u4f5c\u76ee\u5f55\u4e2d\u8fd0\u884c\u547d\u4ee4 dotnet new aichatweb \u6765\u521b\u5efa\u5b83\u3002\u00a0 \u5165\u95e8\u6307\u5357\uff1a.NET AI \u804a\u5929\u6a21\u677f\u00a0 .NET AI \u804a\u5929\u6a21\u677f\u65e8\u5728\u5e2e\u52a9\u60a8\u5feb\u901f\u6784\u5efa\u4e00\u4e2a\u57fa\u4e8e AI [&hellip;]<\/p>\n","protected":false},"author":177361,"featured_media":1062,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[59,1,62,63,64,65],"tags":[2,57,10,87],"class_list":["post-1056","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-net","category-dotnet-ch","category-blazor","category-c","category-visual-studio","category-visual-studio-code","tag-net","tag-ai","tag-c","tag-intelligentapp"],"acf":[],"blog_post_summary":"<p>\u672c\u6587\u7ffb\u8bd1\u81eaJordan Matthiesen\u7684.NET AI Template Now Available in Preview \u60f3\u8981\u5f00\u59cb AI \u5f00\u53d1\uff0c\u5374\u4e0d\u786e\u5b9a\u4ece\u54ea\u91cc\u5165\u624b\uff1f\u6211\u7ed9\u60a8\u5e26\u6765\u4e86\u4e00\u4e2a\u597d\u6d88\u606f\u2014\u2014\u6211\u4eec\u5168\u65b0\u7684 AI \u804a\u5929 Web \u5e94\u7528\u6a21\u677f\u73b0\u5df2\u63d0\u4f9b\u9884\u89c8\u7248\uff01\u8fd9\u4e2a\u6a21\u677f\u662f\u6211\u4eec\u4e0d\u65ad\u52aa\u529b\u7684\u4e00\u90e8\u5206\uff0c\u65e8\u5728\u901a\u8fc7\u5728Visual Studio\uff0cVisual Studio Code \u548c .NET CLI \u4e2d\u63d0\u4f9b\u811a\u624b\u67b6\u548c\u6307\u5bfc\uff0c\u8ba9\u4f7f\u7528 .NET \u8fdb\u884c AI \u5f00\u53d1\u53d8\u5f97\u66f4\u5bb9\u6613\u4e0a\u624b\u3002\u00a0 \u8bf7\u6ce8\u610f\uff0c\u8be5\u6a21\u677f\u76ee\u524d\u4e3a\u9884\u89c8\u7248\uff0c\u672a\u6765\u7248\u672c\u53ef\u80fd\u4f1a\u6839\u636e\u60a8\u7684\u53cd\u9988\u548c AI \u7684\u5feb\u901f\u53d1\u5c55\u8fdb\u884c\u8c03\u6574\u3002\u00a0 \u7acb\u5373\u5b89\u88c5\u6a21\u677f\u00a0 \u5982\u679c\u60f3\u8981\u5f00\u59cb\u4f7f\u7528\u8be5\u6a21\u677f\u7684\u9996\u4e2a\u9884\u89c8\u7248\uff0c\u60a8\u9700\u8981\u5728\u7ec8\u7aef\u4e2d\u5b89\u88c5 Microsoft.Extensions.AI.Templates\u3002\u53ea\u9700\u8fd0\u884c\uff1a\u00a0 dotnet new install Microsoft.Extensions.AI.Templates \u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u8be5\u6a21\u677f\u5373\u53ef\u5728 Visual Studio\uff0cVisual Studio Code\uff08\u9700\u5b89\u88c5 C# Dev Kit\uff09\u4e2d\u4f7f\u7528\uff0c\u6216\u8005\u60a8\u4e5f\u53ef\u4ee5\u5728\u5de5\u4f5c\u76ee\u5f55\u4e2d\u8fd0\u884c\u547d\u4ee4 dotnet new aichatweb \u6765\u521b\u5efa\u5b83\u3002\u00a0 \u5165\u95e8\u6307\u5357\uff1a.NET AI \u804a\u5929\u6a21\u677f\u00a0 .NET AI \u804a\u5929\u6a21\u677f\u65e8\u5728\u5e2e\u52a9\u60a8\u5feb\u901f\u6784\u5efa\u4e00\u4e2a\u57fa\u4e8e AI [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/posts\/1056","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/users\/177361"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/comments?post=1056"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/posts\/1056\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/media\/1062"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/media?parent=1056"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/categories?post=1056"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/tags?post=1056"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}