{"id":90972,"date":"2026-08-06T13:32:48","date_gmt":"2026-08-06T05:32:48","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/90972.html"},"modified":"2026-08-06T13:32:48","modified_gmt":"2026-08-06T05:32:48","slug":"ai%e9%a1%b9%e7%9b%ae%e4%bb%8e%e5%85%a5%e9%97%a8%e5%88%b0%e4%b8%8a%e7%ba%bf28-%e5%90%8c%e6%a0%b7%e7%94%a8gpt%e4%b8%ba%e4%bb%80%e4%b9%88%e5%88%ab%e4%ba%ba%e6%af%94%e6%88%91%e5%86%99%e5%be%97%e5%a5%bd","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/90972.html","title":{"rendered":"AI\u9879\u76ee\u4ece\u5165\u95e8\u5230\u4e0a\u7ebf28-\u540c\u6837\u7528GPT\u4e3a\u4ec0\u4e48\u522b\u4eba\u6bd4\u6211\u5199\u5f97\u597d\uff1fPrompt Engineering\u7cfb\u7edf\u65b9\u6cd5\u8bba"},"content":{"rendered":"<h2 id=\"\">\u76ee\u5f55<\/h2>\n<p id=\"%E4%B8%80%E3%80%81Prompt%20Engineering%E5%9B%9B%E5%B1%82%E4%BD%93%E7%B3%BB-toc\" style=\"margin-left:40px\">\u4e00\u3001Prompt Engineering\u56db\u5c42\u4f53\u7cfb<\/p>\n<p id=\"%E7%AC%AC%E4%B8%80%E5%B1%82%EF%BC%9A%E6%98%8E%E7%A1%AE%E6%8C%87%E4%BB%A4%E2%80%94%E2%80%94%E6%8A%8A%E8%AF%9D%E8%AF%B4%E6%B8%85%E6%A5%9A-toc\" style=\"margin-left:80px\">\u7b2c\u4e00\u5c42&#xff1a;\u660e\u786e\u6307\u4ee4\u2014\u2014\u628a\u8bdd\u8bf4\u6e05\u695a<\/p>\n<p id=\"%E7%AC%AC%E4%BA%8C%E5%B1%82%EF%BC%9A%E6%8F%90%E4%BE%9B%E4%B8%8A%E4%B8%8B%E6%96%87%E2%80%94%E2%80%94%E7%BB%99AI%E5%AE%89%E8%A3%85%22%E8%AE%B0%E5%BF%86%E8%8A%AF%E7%89%87%22-toc\" style=\"margin-left:80px\">\u7b2c\u4e8c\u5c42&#xff1a;\u63d0\u4f9b\u4e0a\u4e0b\u6587\u2014\u2014\u7ed9AI\u5b89\u88c5&#034;\u8bb0\u5fc6\u82af\u7247&#034;<\/p>\n<p id=\"%E7%AC%AC%E4%B8%89%E5%B1%82%EF%BC%9A%E6%80%9D%E7%BB%B4%E9%93%BE(CoT)%E2%80%94%E2%80%94%E6%95%99AI%E4%B8%80%E6%AD%A5%E4%B8%80%E6%AD%A5%E6%83%B3-toc\" style=\"margin-left:80px\">\u7b2c\u4e09\u5c42&#xff1a;\u601d\u7ef4\u94fe(CoT)\u2014\u2014\u6559AI\u4e00\u6b65\u4e00\u6b65\u60f3<\/p>\n<p id=\"%E7%AC%AC%E5%9B%9B%E5%B1%82%EF%BC%9A%E8%87%AA%E6%88%91%E5%8F%8D%E6%80%9D%2B%E8%BE%93%E5%87%BA%E6%A0%A1%E9%AA%8C%E2%80%94%E2%80%94%E8%AE%A9AI%E8%87%AA%E5%B7%B1%E6%89%BE%E9%94%99%E8%AF%AF-toc\" style=\"margin-left:80px\">\u7b2c\u56db\u5c42&#xff1a;\u81ea\u6211\u53cd\u601d&#043;\u8f93\u51fa\u6821\u9a8c\u2014\u2014\u8ba9AI\u81ea\u5df1\u627e\u9519\u8bef<\/p>\n<p id=\"%E4%BA%8C%E3%80%81Prompt%E6%A8%A1%E6%9D%BF%E4%BD%93%E7%B3%BB%E8%AE%BE%E8%AE%A1-toc\" style=\"margin-left:40px\">\u4e8c\u3001Prompt\u6a21\u677f\u4f53\u7cfb\u8bbe\u8ba1<\/p>\n<p id=\"%E4%B8%89%E3%80%81%E7%BB%93%E6%9E%84%E5%8C%96%E8%BE%93%E5%87%BA%E6%8E%A7%E5%88%B6-toc\" style=\"margin-left:40px\">\u4e09\u3001\u7ed3\u6784\u5316\u8f93\u51fa\u63a7\u5236<\/p>\n<p id=\"%E5%9B%9B%E3%80%81Few-shot%E7%A4%BA%E4%BE%8B%E9%80%89%E6%8B%A9%E7%AD%96%E7%95%A5-toc\" style=\"margin-left:40px\">\u56db\u3001Few-shot\u793a\u4f8b\u9009\u62e9\u7b56\u7565<\/p>\n<p id=\"%E4%BA%94%E3%80%81Prompt%E7%89%88%E6%9C%AC%E7%AE%A1%E7%90%86-toc\" style=\"margin-left:40px\">\u4e94\u3001Prompt\u7248\u672c\u7ba1\u7406<\/p>\n<p id=\"%E5%85%AD%E3%80%81A%2FB%E6%B5%8B%E8%AF%95%EF%BC%9APrompt%E7%9A%84%22%E7%81%B0%E5%BA%A6%E5%8F%91%E5%B8%83%22-toc\" style=\"margin-left:40px\">\u516d\u3001A\/B\u6d4b\u8bd5&#xff1a;Prompt\u7684&#034;\u7070\u5ea6\u53d1\u5e03&#034;<\/p>\n<p id=\"%E4%B8%83%E3%80%81%E6%88%90%E6%9C%AC%E4%B8%8E%E8%B4%A8%E9%87%8F%E7%9A%84%E6%9D%83%E8%A1%A1-toc\" style=\"margin-left:40px\">\u4e03\u3001\u6210\u672c\u4e0e\u8d28\u91cf\u7684\u6743\u8861<\/p>\n<hr \/>\n<h3 id=\"%E5%BC%80%E7%AF%87%EF%BC%9A%E4%BD%A0%E5%92%8C%E5%A4%A7%E7%A5%9E%E7%9A%84%E5%B7%AE%E8%B7%9D%EF%BC%8C%E5%B0%B1%E5%B7%AE%E4%B8%80%E4%B8%AAPrompt\">\u5f00\u7bc7&#xff1a;\u4f60\u548c\u5927\u795e\u7684\u5dee\u8ddd&#xff0c;\u5c31\u5dee\u4e00\u4e2aPrompt<\/h3>\n<p>\u540c\u6837\u63a5GPT-4\u7684API&#xff0c;\u540c\u4e8b\u7684\u8f93\u51fa\u50cf\u838e\u58eb\u6bd4\u4e9a&#xff0c;\u4f60\u7684\u8f93\u51fa\u50cf\u521a\u5b66\u4f1a\u6253\u5b57\u7684\u5c0f\u5b66\u751f\u3002 \u95ee\u9898\u4e0d&#xff08;\u5168&#xff09;\u5728\u6a21\u578b&#xff0c;\u800c\u5728\u4f60\u600e\u4e48\u8ddf\u5b83\u8bf4\u8bdd\u3002Prompt Engineering\u4e0d\u662f\u7384\u5b66&#xff0c;\u662f\u4e00\u95e8\u6b63\u7ecf\u7684\u7cfb\u7edf\u5de5\u7a0b\u3002<\/p>\n<p>\u4e00\u4e2aPrompt\u8c03\u4e00\u5929&#xff0c;\u4ea7\u51fa\u591a\u51fa\u4e00\u4e2a\u6708\u5de5\u8d44\u2014\u2014\u8fd9\u4e8b\u513f\u6211\u5e72\u8fc7&#xff0c;\u4f60\u4e5f\u80fd\u5e72\u3002<\/p>\n<p>\u4eca\u5929\u8fd9\u7bc7\u6587\u7ae0&#xff0c;\u6211\u4ece&#034;\u628a\u8bdd\u8bf4\u6e05\u695a&#034;\u5230&#034;\u8ba9AI\u81ea\u5df1\u53cd\u601d\u81ea\u5df1&#034;&#xff0c;\u7528\u4e00\u5957\u56db\u5c42\u65b9\u6cd5\u8bba &#043; \u53ef\u843d\u5730\u7684\u4ee3\u7801&#xff0c;\u5e26\u4f60\u4ecePrompt\u5c0f\u767d\u5230\u80fd\u9762\u8bd5\u522b\u4ebaPrompt\u7684\u6c34\u5e73\u3002<\/p>\n<hr \/>\n<h3 id=\"%E4%B8%80%E3%80%81Prompt%20Engineering%E5%9B%9B%E5%B1%82%E4%BD%93%E7%B3%BB\">\u4e00\u3001Prompt Engineering\u56db\u5c42\u4f53\u7cfb<\/h3>\n<p>\u522b\u6025\u7740\u770b\u6a21\u677f&#xff0c;\u5148\u641e\u61c2\u8fd9\u5f20\u56fe\u3002Prompt\u80fd\u529b\u7684\u63d0\u5347\u4e0d\u662f&#034;\u591a\u52a0\u70b9\u63d0\u793a\u8bcd&#034;&#xff0c;\u800c\u662f\u4e00\u5c42\u4e00\u5c42\u5f80\u4e0a\u8d70&#xff1a;<\/p>\n<p>graph TD<br \/>\n    L1[&#034;&#x1f7e2; \u7b2c\u4e00\u5c42&#xff1a;\u660e\u786e\u6307\u4ee4&lt;br\/&gt;Tell it WHAT to do&#034;]<br \/>\n    L2[&#034;&#x1f7e1; \u7b2c\u4e8c\u5c42&#xff1a;\u63d0\u4f9b\u4e0a\u4e0b\u6587&lt;br\/&gt;Tell it WHO it is &amp; WHY&#034;]<br \/>\n    L3[&#034;&#x1f7e0; \u7b2c\u4e09\u5c42&#xff1a;\u601d\u7ef4\u94fe(CoT)&lt;br\/&gt;Tell it HOW to think&#034;]<br \/>\n    L4[&#034;&#x1f534; \u7b2c\u56db\u5c42&#xff1a;\u81ea\u6211\u53cd\u601d&#043;\u6821\u9a8c&lt;br\/&gt;Let it check ITSELF&#034;]<\/p>\n<p>    L1 &#8211;&gt; L2 &#8211;&gt; L3 &#8211;&gt; L4<\/p>\n<p>    L1 -.- E1[&#034;\u6548\u679c&#xff1a;\u52c9\u5f3a\u80fd\u7528&#xff0c;\u7ecf\u5e38\u8dd1\u504f&#034;]<br \/>\n    L2 -.- E2[&#034;\u6548\u679c&#xff1a;\u98ce\u683c\u7edf\u4e00&#xff0c;\u51cf\u5c11\u5e7b\u89c9&#034;]<br \/>\n    L3 -.- E3[&#034;\u6548\u679c&#xff1a;\u63a8\u7406\u51c6\u786e\u7387\u663e\u8457\u63d0\u5347&#034;]<br \/>\n    L4 -.- E4[&#034;\u6548\u679c&#xff1a;\u751f\u4ea7\u7ea7\u53ef\u9760&#xff0c;\u81ea\u7ea0\u9519&#034;]<\/p>\n<p>    style L1 fill:#90EE90,stroke:#333<br \/>\n    style L2 fill:#FFD700,stroke:#333<br \/>\n    style L3 fill:#FFA500,stroke:#333<br \/>\n    style L4 fill:#FF6347,stroke:#333<\/p>\n<p>\u5212\u91cd\u70b9&#xff1a; \u5927\u90e8\u5206\u4eba\u7684Prompt\u5361\u5728L1\u548cL2\u4e4b\u95f4\u3002\u82b1\u4e00\u5929\u5b66\u4e86&#034;\u4f60\u662fxx\u4e13\u5bb6&#034;\u5c31\u4ee5\u4e3a\u81ea\u5df1Pro\u4e86&#xff0c;\u5176\u5b9e\u521a\u5165\u95e8\u3002<\/p>\n<hr \/>\n<h4 id=\"%E7%AC%AC%E4%B8%80%E5%B1%82%EF%BC%9A%E6%98%8E%E7%A1%AE%E6%8C%87%E4%BB%A4%E2%80%94%E2%80%94%E6%8A%8A%E8%AF%9D%E8%AF%B4%E6%B8%85%E6%A5%9A\">\u7b2c\u4e00\u5c42&#xff1a;\u660e\u786e\u6307\u4ee4\u2014\u2014\u628a\u8bdd\u8bf4\u6e05\u695a<\/h4>\n<p>\u8fd9\u4e00\u5c42\u6700\u7b80\u5355\u4e5f\u6700\u5bb9\u6613\u72af\u9519\u3002\u4e0d\u4fe1&#xff1f;\u6765\u770b\u4e09\u7ec4\u5bf9\u6bd4&#xff1a;<\/p>\n<p># \u274c \u70c2Prompt&#xff1a;\u6a21\u7cca\u5f97\u50cf\u4f60\u5988\u8ba9\u4f60&#034;\u53bb\u4e70\u70b9\u4e1c\u897f&#034;<br \/>\nbad_prompt &#061; &#034;\u5199\u4e00\u4e2aPython\u51fd\u6570\u5904\u7406\u6570\u636e&#034;<\/p>\n<p># \u2705 \u597dPrompt&#xff1a;\u7cbe\u786e\u5f97\u50cf\u5916\u5356\u5907\u6ce8&#034;\u4e0d\u52a0\u9999\u83dc\u4e0d\u653e\u8471\u5c11\u8fa3&#034;<br \/>\ngood_prompt &#061; &#034;&#034;&#034;<br \/>\n\u7f16\u5199\u4e00\u4e2aPython\u51fd\u6570 &#096;def clean_data(df: pd.DataFrame) -&gt; pd.DataFrame&#096;&#xff1a;<br \/>\n&#8211; \u5220\u9664\u6240\u6709\u5305\u542bNaN\u7684\u884c<br \/>\n&#8211; \u5c06\u65e5\u671f\u5217&#034;date&#034;\u8f6c\u4e3adatetime\u683c\u5f0f<br \/>\n&#8211; \u5bf9\u6570\u503c\u5217\u505aZ-score\u6807\u51c6\u5316&#xff08;mean&#061;0, std&#061;1&#xff09;<br \/>\n&#8211; \u8fd4\u56de\u5904\u7406\u540e\u7684DataFrame<br \/>\n&#8211; \u6dfb\u52a0docstring\u548c\u7c7b\u578b\u6ce8\u89e3<br \/>\n&#034;&#034;&#034;<\/p>\n<p>\u4f60\u770b&#xff0c;\u597d\u7684Prompt\u5c31\u662f\u5728\u5199&#034;\u6280\u672f\u9700\u6c42\u6587\u6863&#034;\u3002\u51e0\u4e2a\u5173\u952e\u8981\u7d20&#xff1a;<\/p>\n<p>\u26a0\ufe0f \u907f\u57511&#xff1a;\u7528&#034;\u4e0d\u8981&#034;\u4e0d\u5982\u7528&#034;\u8981&#034; \u4eba\u7c7b\u5bf9\u5426\u5b9a\u53e5\u654f\u611f&#xff08;\u4e0d\u8981\u78b0\u706b&#x1f525;&#xff09;&#xff0c;LLM\u5bf9\u5426\u5b9a\u6307\u4ee4\u7684\u7406\u89e3\u5dee\u5f88\u591a\u3002\u5199&#034;\u8f93\u51faJSON\u683c\u5f0f&#034;\u6bd4&#034;\u4e0d\u8981\u8f93\u51famarkdown&#034;\u6548\u679c\u597d10\u500d\u3002\u539f\u56e0&#xff1f;\u6ce8\u610f\u529b\u673a\u5236\u91cc\u7684\u8d1f\u5411token\u6743\u91cd\u8fdc\u4f4e\u4e8e\u6b63\u5411\u2014\u2014\u8bf4\u4eba\u8bdd\u5c31\u662f&#xff1a;AI\u662f&#034;\u6309\u4f60\u8bf4\u7684\u505a&#034;\u800c\u4e0d\u662f&#034;\u6309\u4f60\u4e0d\u8bf4\u7684\u505a&#034;\u3002<\/p>\n<p># \u274c \u5426\u5b9a\u5f0f\u6307\u4ee4\u2014\u2014AI\u53ef\u80fd\u5ffd\u7565&#034;\u4e0d\u8981&#034;\u4e8c\u5b57<br \/>\nbad &#061; &#034;\u4e0d\u8981\u4f7f\u7528markdown\u683c\u5f0f&#xff0c;\u4e0d\u8981\u6dfb\u52a0\u591a\u4f59\u89e3\u91ca&#034;<\/p>\n<p># \u2705 \u80af\u5b9a\u5f0f\u6307\u4ee4\u2014\u2014\u544a\u8bc9\u5b83\u8981\u4ec0\u4e48<br \/>\ngood &#061; &#034;\u4ec5\u8f93\u51fa\u7eafJSON\u5b57\u7b26\u4e32&#xff0c;\u952e\u540d\u4f7f\u7528snake_case\u3002\u4e0d\u8981\u9644\u5e26\u4efb\u4f55\u89e3\u91ca\u6587\u672c\u3002&#034;<\/p>\n<hr \/>\n<h4 id=\"%E7%AC%AC%E4%BA%8C%E5%B1%82%EF%BC%9A%E6%8F%90%E4%BE%9B%E4%B8%8A%E4%B8%8B%E6%96%87%E2%80%94%E2%80%94%E7%BB%99AI%E5%AE%89%E8%A3%85%22%E8%AE%B0%E5%BF%86%E8%8A%AF%E7%89%87%22\">\u7b2c\u4e8c\u5c42&#xff1a;\u63d0\u4f9b\u4e0a\u4e0b\u6587\u2014\u2014\u7ed9AI\u5b89\u88c5&#034;\u8bb0\u5fc6\u82af\u7247&#034;<\/h4>\n<p>\u8fd9\u4e00\u5c42\u662f\u8d28\u7684\u98de\u8dc3\u3002\u4e0a\u4e0b\u6587 &#061; \u89d2\u8272 &#043; \u80cc\u666f\u4fe1\u606f &#043; \u8f93\u51fa\u53d7\u4f17\u3002<\/p>\n<p># L2\u7ea7\u522bPrompt\u6a21\u677f<br \/>\nprompt_with_context &#061; &#034;&#034;&#034;<br \/>\n\u3010\u89d2\u8272\u3011\u4f60\u662f\u4e00\u4f4d\u62e5\u670910\u5e74\u7ecf\u9a8c\u7684Python\u540e\u7aef\u67b6\u6784\u5e08&#xff0c;\u64c5\u957f\u5fae\u670d\u52a1\u8bbe\u8ba1\u548c\u9ad8\u5e76\u53d1\u4f18\u5316\u3002<\/p>\n<p>\u3010\u80cc\u666f\u3011\u6211\u4eec\u6709\u4e00\u4e2a\u7535\u5546\u8ba2\u5355\u7cfb\u7edf&#xff0c;\u65e5\u5747\u8ba2\u5355\u91cf50\u4e07\u3002\u76ee\u524d\u8ba2\u5355\u67e5\u8be2\u63a5\u53e3P99\u5ef6\u8fdf<br \/>\n\u8fbe\u5230\u4e862.3\u79d2&#xff0c;\u9700\u8981\u4f18\u5316\u5230200ms\u4ee5\u5185\u3002<\/p>\n<p>\u3010\u4efb\u52a1\u3011\u5206\u6790\u53ef\u80fd\u7684\u6027\u80fd\u74f6\u9888&#xff0c;\u7ed9\u51fa3\u4e2a\u4f18\u5316\u65b9\u6848&#xff0c;\u6bcf\u4e2a\u65b9\u6848\u5305\u542b&#xff1a;<br \/>\n&#8211; \u65b9\u6848\u63cf\u8ff0&#xff08;50\u5b57\u4ee5\u5185&#xff09;<br \/>\n&#8211; \u9884\u8ba1\u5ef6\u8fdf\u964d\u4f4e\u5e45\u5ea6<br \/>\n&#8211; \u5b9e\u73b0\u590d\u6742\u5ea6&#xff08;\u9ad8\/\u4e2d\/\u4f4e&#xff09;<br \/>\n&#8211; \u6f5c\u5728\u98ce\u9669<\/p>\n<p>\u3010\u53d7\u4f17\u3011\u8f93\u51fa\u7ed9\u6280\u672f\u7ecf\u7406\u9605\u8bfb&#xff0c;\u8981\u6c42\u6280\u672f\u51c6\u786e\u4f46\u4e0d\u5931\u53ef\u8bfb\u6027\u3002<br \/>\n&#034;&#034;&#034;<\/p>\n<p>&#x1f4a1; \u6548\u7387\u6280\u5de71&#xff1a;\u89d2\u8272\u8bbe\u5b9a\u7701\u638980%\u7684\u683c\u5f0f\u8c03\u6574 \u4e0e\u5176\u519910\u884c&#034;\u4f60\u7684\u8f93\u51fa\u5e94\u8be5\u7528\u4ec0\u4e48\u683c\u5f0f&#034;&#xff0c;\u4e0d\u5982\u4e00\u53e5&#034;\u4f60\u662f\u4e00\u4f4d\u8d44\u6df1\u6280\u672f\u535a\u5ba2\u4f5c\u8005&#034;\u2014\u2014\u6a21\u578b\u81ea\u5df1\u77e5\u9053\u535a\u5ba2\u8be5\u957f\u4ec0\u4e48\u6837\u3002\u8fd9\u53eb\u5185\u5316\u77e5\u8bc6\u89e6\u53d1&#xff08;Internalized Knowledge Trigger&#xff09;&#xff0c;GPT\u7cfb\u5217\u5728\u89d2\u8272\u8bbe\u5b9a\u540e\u4f1a\u81ea\u52a8\u6fc0\u6d3b\u5bf9\u5e94\u7684\u5199\u4f5c\u98ce\u683c\u795e\u7ecf\u5143\u3002<\/p>\n<hr \/>\n<h4 id=\"%E7%AC%AC%E4%B8%89%E5%B1%82%EF%BC%9A%E6%80%9D%E7%BB%B4%E9%93%BE(CoT)%E2%80%94%E2%80%94%E6%95%99AI%E4%B8%80%E6%AD%A5%E4%B8%80%E6%AD%A5%E6%83%B3\">\u7b2c\u4e09\u5c42&#xff1a;\u601d\u7ef4\u94fe(CoT)\u2014\u2014\u6559AI\u4e00\u6b65\u4e00\u6b65\u60f3<\/h4>\n<p>\u5f88\u591a\u4eba\u95ee&#xff1a;\u201c\u4e3a\u4ec0\u4e48\u52a0\u4e86\u2019Let\u2019s think step by step\u2019\u6548\u679c\u5c31\u53d8\u597d&#xff1f;\u201d<\/p>\n<p>\u56e0\u4e3aLLM\u672c\u8d28\u4e0a\u662f\u6982\u7387\u9884\u6d4b\u4e0b\u4e00\u4e2atoken\u7684\u673a\u5668\u3002\u4e0d\u7ed9\u63a8\u7406\u8def\u5f84&#xff0c;\u5b83\u5c31&#034;\u731c&#034;\u7b54\u6848&#xff1b;\u7ed9\u4e86\u8def\u5f84&#xff0c;\u5b83\u5c31&#034;\u7b97&#034;\u7b54\u6848\u3002<\/p>\n<p>graph LR<br \/>\n    A[&#034;\u95ee\u9898\u8f93\u5165&#034;] &#8211;&gt; B[&#034;\u274c \u65e0CoT&lt;br\/&gt;\u76f4\u63a5\u8e66\u7b54\u6848&#034;]<br \/>\n    A &#8211;&gt; C[&#034;\u2705 \u6709CoT&lt;br\/&gt;Step 1: \u7406\u89e3\u95ee\u9898&#034;]<br \/>\n    C &#8211;&gt; D[&#034;Step 2: \u62c6\u89e3\u5b50\u95ee\u9898&#034;]<br \/>\n    D &#8211;&gt; E[&#034;Step 3: \u9010\u6b65\u63a8\u7406&#034;]<br \/>\n    E &#8211;&gt; F[&#034;Step 4: \u6574\u5408\u7b54\u6848&#034;]<br \/>\n    F &#8211;&gt; G[&#034;\u8f93\u51fa\u6700\u7ec8\u7ed3\u679c&#034;]<\/p>\n<p>    B -.- B1[&#034;\u6b63\u786e\u7b54\u6848\u6982\u7387: 60%&#034;]<br \/>\n    G -.- G1[&#034;\u6b63\u786e\u7b54\u6848\u6982\u7387: 90%&#043;&#034;]<\/p>\n<p>    style B fill:#FFB6C1<br \/>\n    style G fill:#90EE90<\/p>\n<p>\u6765\u770b\u4ee3\u7801\u5b9e\u73b0\u4e00\u4e2a\u5b8c\u6574\u7684CoT Prompt\u6a21\u677f&#xff1a;<\/p>\n<p>def build_cot_prompt(question: str, domain: str &#061; &#034;general&#034;) -&gt; str:<br \/>\n    &#034;&#034;&#034;<br \/>\n    \u6784\u5efa\u601d\u7ef4\u94fePrompt\u6a21\u677f<br \/>\n    &#034;&#034;&#034;<br \/>\n    cot_templates &#061; {<br \/>\n        &#034;code&#034;: &#034;&#034;&#034;<br \/>\n\u3010\u4efb\u52a1\u3011{question}<\/p>\n<p>\u8bf7\u6309\u4ee5\u4e0b\u6b65\u9aa4\u9010\u6b65\u63a8\u7406&#xff1a;<\/p>\n<p>\u7b2c1\u6b65 &#8211; \u9700\u6c42\u5206\u6790&#xff1a;\u660e\u786e\u8f93\u5165\u8f93\u51fa\u662f\u4ec0\u4e48&#xff1f;\u8fb9\u754c\u6761\u4ef6\u6709\u54ea\u4e9b&#xff1f;<br \/>\n\u7b2c2\u6b65 &#8211; \u7b97\u6cd5\u9009\u62e9&#xff1a;\u54ea\u79cd\u6570\u636e\u7ed3\u6784\/\u7b97\u6cd5\u6700\u4f18&#xff1f;\u65f6\u95f4\u590d\u6742\u5ea6\u662f\u591a\u5c11&#xff1f;<br \/>\n\u7b2c3\u6b65 &#8211; \u4f2a\u4ee3\u7801&#xff1a;\u5199\u51fa\u6838\u5fc3\u903b\u8f91\u7684\u4f2a\u4ee3\u7801<br \/>\n\u7b2c4\u6b65 &#8211; \u7f16\u7801\u5b9e\u73b0&#xff1a;\u7ed9\u51fa\u53ef\u8fd0\u884c\u7684Python\u4ee3\u7801<br \/>\n\u7b2c5\u6b65 &#8211; \u6d4b\u8bd5\u7528\u4f8b&#xff1a;\u63d0\u4f9b3\u4e2a\u6d4b\u8bd5\u7528\u4f8b\u53ca\u5176\u671f\u671b\u8f93\u51fa<br \/>\n\u7b2c6\u6b65 &#8211; \u590d\u6742\u5ea6\u5206\u6790&#xff1a;\u65f6\u95f4\u548c\u7a7a\u95f4\u590d\u6742\u5ea6<\/p>\n<p>\u26a0\ufe0f \u6bcf\u4e00\u6b65\u90fd\u5fc5\u987b\u8f93\u51fa\u663e\u5f0f\u6807\u8bb0&#xff0c;\u683c\u5f0f\u4e3a\u300c\u7b2cX\u6b65&#xff1a;\u300d&#xff0c;\u4e0d\u53ef\u8df3\u8fc7\u4efb\u4f55\u4e00\u6b65\u3002<br \/>\n&#034;&#034;&#034;,<br \/>\n        &#034;analysis&#034;: &#034;&#034;&#034;<br \/>\n\u3010\u4efb\u52a1\u3011{question}<\/p>\n<p>\u8bf7\u6309\u4ee5\u4e0b\u6846\u67b6\u5206\u6790&#xff1a;<\/p>\n<p>1. \u80cc\u666f\u68b3\u7406&#xff1a;\u8fd9\u4ef6\u4e8b\u7684\u80cc\u666f\u548c\u4e0a\u4e0b\u6587\u662f\u4ec0\u4e48&#xff1f;<br \/>\n2. \u5173\u952e\u56e0\u7d20&#xff1a;\u5f71\u54cd\u7ed3\u679c\u7684\u6838\u5fc3\u53d8\u91cf\u6709\u54ea\u4e9b&#xff1f;<br \/>\n3. \u591a\u89d2\u5ea6\u5206\u6790&#xff1a;\u81f3\u5c11\u4ece3\u4e2a\u4e0d\u540c\u89d2\u5ea6\u5206\u6790<br \/>\n4. \u5229\u5f0a\u6743\u8861&#xff1a;\u5217\u51fa\u6bcf\u4e2a\u65b9\u6848\u7684\u4f18\u7f3a\u70b9<br \/>\n5. \u7ed3\u8bba\u5efa\u8bae&#xff1a;\u7ed9\u51fa\u6700\u7ec8\u5efa\u8bae\u5e76\u89e3\u91ca\u7406\u7531<br \/>\n&#034;&#034;&#034;<br \/>\n    }<br \/>\n    template &#061; cot_templates.get(domain, cot_templates[&#034;analysis&#034;])<br \/>\n    return template.format(question&#061;question)<\/p>\n<p># \u4f7f\u7528\u793a\u4f8b<br \/>\nquestion &#061; &#034;\u8bbe\u8ba1\u4e00\u4e2a\u5206\u5e03\u5f0f\u9650\u6d41\u5668&#xff0c;\u8981\u6c42\u652f\u6301\u6ed1\u52a8\u7a97\u53e3\u7b97\u6cd5&#034;<br \/>\ncot_prompt &#061; build_cot_prompt(question, domain&#061;&#034;code&#034;)<br \/>\nprint(cot_prompt)<\/p>\n<p>\u26a0\ufe0f \u907f\u57512&#xff1a;CoT\u4e0d\u662f\u8d8a\u957f\u8d8a\u597d\u2014\u2014&#034;\u8fc7\u5ea6\u63a8\u7406&#034;\u9677\u9631 \u6211\u89c1\u8fc7\u6709\u4eba\u7ed9\u7b80\u5355\u4efb\u52a1&#xff08;\u5982&#034;\u7ffb\u8bd1\u4e00\u53e5\u8bdd&#034;&#xff09;\u51998\u6b65CoT\u3002\u7ed3\u679c\u5462&#xff1f;\u6a21\u578b\u5f00\u59cb\u8111\u8865\u4e0d\u5b58\u5728\u7684\u95ee\u9898&#xff0c;\u7b54\u6848\u53cd\u800c\u53d8\u5dee\u4e86\u3002CoT\u7684\u6536\u76ca\u66f2\u7ebf\u662f\u5012U\u578b\u7684\u2014\u2014\u7b80\u5355\u4efb\u52a1\u7528L1\/L2\u5c31\u591f\u4e86&#xff0c;\u590d\u6742\u63a8\u7406&#xff08;\u6570\u5b66\u3001\u4ee3\u7801\u3001\u903b\u8f91\u5206\u6790&#xff09;\u624d\u4e0aCoT\u3002<\/p>\n<p>&#x1f4a1; \u6548\u7387\u6280\u5de72&#xff1a;\u52a8\u6001\u9009\u62e9\u63a8\u7406\u6df1\u5ea6 \u7528\u4e00\u4e2a\u5206\u7c7b\u5668\u5224\u65ad\u4efb\u52a1\u590d\u6742\u5ea6&#xff0c;\u518d\u51b3\u5b9a\u7528\u51e0\u5c42Prompt&#xff1a;<\/p>\n<p>def select_prompt_level(task: str) -&gt; int:<br \/>\n    &#034;&#034;&#034;\u6839\u636e\u4efb\u52a1\u590d\u6742\u5ea6\u81ea\u52a8\u9009\u62e9Prompt\u5c42\u7ea7&#034;&#034;&#034;<br \/>\n    complex_keywords &#061; [<br \/>\n        &#034;\u8bbe\u8ba1&#034;, &#034;\u4f18\u5316&#034;, &#034;\u5bf9\u6bd4\u5206\u6790&#034;, &#034;debug&#034;, &#034;\u67b6\u6784&#034;,<br \/>\n        &#034;\u7b97\u6cd5&#034;, &#034;\u63a8\u7406&#034;, &#034;\u591a\u6b65\u9aa4&#034;, &#034;review&#034;, &#034;\u6743\u8861&#034;<br \/>\n    ]<br \/>\n    simple_keywords &#061; [<br \/>\n        &#034;\u7ffb\u8bd1&#034;, &#034;\u603b\u7ed3&#034;, &#034;\u63d0\u53d6&#034;, &#034;\u683c\u5f0f\u5316&#034;, &#034;\u91cd\u5199&#034;,<br \/>\n        &#034;\u7f29\u5199&#034;, &#034;\u6807\u7b7e&#034;, &#034;\u5206\u7c7b&#034;<br \/>\n    ]<\/p>\n<p>    task_lower &#061; task.lower()<\/p>\n<p>    if any(kw in task_lower for kw in complex_keywords):<br \/>\n        return 4  # L4&#xff1a;\u5b8c\u6574CoT&#043;\u81ea\u6211\u53cd\u601d<br \/>\n    elif any(kw in task_lower for kw in simple_keywords):<br \/>\n        return 2  # L2&#xff1a;\u4e0a\u4e0b\u6587\u5c31\u591f\u4e86<br \/>\n    else:<br \/>\n        return 3  # L3&#xff1a;\u6807\u51c6CoT<\/p>\n<hr \/>\n<h4 id=\"%E7%AC%AC%E5%9B%9B%E5%B1%82%EF%BC%9A%E8%87%AA%E6%88%91%E5%8F%8D%E6%80%9D%2B%E8%BE%93%E5%87%BA%E6%A0%A1%E9%AA%8C%E2%80%94%E2%80%94%E8%AE%A9AI%E8%87%AA%E5%B7%B1%E6%89%BE%E9%94%99%E8%AF%AF\">\u7b2c\u56db\u5c42&#xff1a;\u81ea\u6211\u53cd\u601d&#043;\u8f93\u51fa\u6821\u9a8c\u2014\u2014\u8ba9AI\u81ea\u5df1\u627e\u9519\u8bef<\/h4>\n<p>L4\u662f\u751f\u4ea7\u73af\u5883\u7684\u5206\u6c34\u5cad\u3002\u6838\u5fc3\u903b\u8f91&#xff1a;\u8ba9\u6a21\u578b\u751f\u6210 \u2192 \u8ba9\u6a21\u578b\u81ea\u5df1\u8bc4\u5ba1 \u2192 \u8ba9\u6a21\u578b\u4fee\u6b63\u3002<\/p>\n<p>class SelfReflectivePrompt:<br \/>\n    &#034;&#034;&#034;L4\u81ea\u53cd\u601dPrompt\u6846\u67b6&#034;&#034;&#034;<\/p>\n<p>    def __init__(self, model_func):<br \/>\n        self.model_func &#061; model_func  # \u4f60\u7684LLM\u8c03\u7528\u51fd\u6570<\/p>\n<p>    def generate(self, task: str) -&gt; dict:<br \/>\n        # Phase 1: \u521d\u59cb\u751f\u6210<br \/>\n        gen_prompt &#061; f&#034;&#034;&#034;<br \/>\n{task}<\/p>\n<p>\u8981\u6c42&#xff1a;<br \/>\n&#8211; \u8f93\u51fa\u5b8c\u6574\u7b54\u6848<br \/>\n&#8211; \u5728\u6bcf\u4e2a\u5173\u952e\u5224\u65ad\u5904\u7528\u300c\u3010\u5173\u952e\u5224\u65ad\u3011\u300d\u6807\u8bb0<br \/>\n&#8211; \u5728\u6bcf\u4e2a\u5047\u8bbe\u5904\u7528\u300c\u3010\u5047\u8bbe\u3011\u300d\u6807\u8bb0\u4f60\u7684\u524d\u63d0<br \/>\n&#034;&#034;&#034;<br \/>\n        initial_output &#061; self.model_func(gen_prompt)<\/p>\n<p>        # Phase 2: \u81ea\u6211\u8bc4\u5ba1<br \/>\n        review_prompt &#061; f&#034;&#034;&#034;<br \/>\n\u8bf7\u4e25\u683c\u5ba1\u67e5\u4ee5\u4e0b\u8f93\u51fa&#xff0c;\u627e\u51fa\u6240\u6709\u95ee\u9898&#xff1a;<\/p>\n<p>\u3010\u539f\u59cb\u8f93\u51fa\u3011<br \/>\n{initial_output}<\/p>\n<p>\u3010\u5ba1\u67e5\u6807\u51c6\u3011<br \/>\n1. \u4e8b\u5b9e\u6027\u9519\u8bef&#xff1a;\u6709\u6ca1\u6709\u4e0e\u516c\u8ba4\u77e5\u8bc6\u77db\u76fe\u7684\u5730\u65b9&#xff1f;<br \/>\n2. \u903b\u8f91\u6f0f\u6d1e&#xff1a;\u63a8\u7406\u94fe\u6761\u6709\u6ca1\u6709\u8df3\u8dc3\u6216\u77db\u76fe&#xff1f;<br \/>\n3. \u5b8c\u6574\u6027&#xff1a;\u6709\u6ca1\u6709\u9057\u6f0f\u5173\u952e\u4fe1\u606f&#xff1f;<br \/>\n4. \u8fb9\u754c\u6761\u4ef6&#xff1a;\u6781\u7aef\u60c5\u51b5\u662f\u5426\u5904\u7406&#xff1f;<\/p>\n<p>\u8bf7\u5217\u51fa\u6240\u6709\u300c\u53d1\u73b0\u7684\u95ee\u9898\u300d&#xff0c;\u6bcf\u6761\u683c\u5f0f&#xff1a;<br \/>\n&#8211; [\u4e25\u91cd\u7a0b\u5ea6: \u9ad8\/\u4e2d\/\u4f4e] \u95ee\u9898\u63cf\u8ff0 \u2192 \u5efa\u8bae\u4fee\u6b63<br \/>\n&#034;&#034;&#034;<br \/>\n        review &#061; self.model_func(review_prompt)<\/p>\n<p>        # Phase 3: \u57fa\u4e8e\u8bc4\u5ba1\u4fee\u6b63<br \/>\n        fix_prompt &#061; f&#034;&#034;&#034;<br \/>\n\u6839\u636e\u4ee5\u4e0b\u8bc4\u5ba1\u610f\u89c1\u4fee\u6b63\u4f60\u7684\u539f\u59cb\u8f93\u51fa&#xff1a;<\/p>\n<p>\u3010\u539f\u59cb\u8f93\u51fa\u3011<br \/>\n{initial_output}<\/p>\n<p>\u3010\u8bc4\u5ba1\u610f\u89c1\u3011<br \/>\n{review}<\/p>\n<p>\u3010\u4fee\u6b63\u8981\u6c42\u3011<br \/>\n&#8211; \u9010\u6761\u5904\u7406\u6240\u6709\u8bc4\u5ba1\u610f\u89c1<br \/>\n&#8211; \u8f93\u51fa\u5b8c\u6574\u7684\u4fee\u6b63\u540e\u7248\u672c<br \/>\n&#8211; \u5728\u6587\u672b\u5217\u51fa\u300c\u4fee\u6b63\u6e05\u5355\u300d<br \/>\n&#034;&#034;&#034;<br \/>\n        final_output &#061; self.model_func(fix_prompt)<\/p>\n<p>        return {<br \/>\n            &#034;initial&#034;: initial_output,<br \/>\n            &#034;review&#034;: review,<br \/>\n            &#034;final&#034;: final_output<br \/>\n        }<\/p>\n<p>L4\u7684\u4ee3\u4ef7\u662f\u663e\u800c\u6613\u89c1\u7684\u2014\u2014\u4e00\u6b21\u751f\u6210\u53d8\u6210\u4e09\u6b21\u8c03\u7528&#xff0c;token\u6d88\u8017\u7ffb3\u500d\u3002\u4f46\u5982\u679c\u4f60\u5728\u505a\u4e00\u4e2a\u6bcf\u5929\u8dd110\u4e07\u6b21\u7684\u6838\u5fc3\u4e1a\u52a1\u903b\u8f91&#xff0c;\u8fd93\u500d\u6210\u672c\u6362\u6765\u7684\u662f\u4ece&#034;90%\u51c6\u786e\u7387&#034;\u5230&#034;99.5%\u51c6\u786e\u7387&#034;\u7684\u63d0\u5347\u2014\u2014\u503c\u4e0d\u503c&#xff0c;\u4f60\u7b97\u4e00\u4e0b\u51fa\u9519\u7684\u5ba2\u8bc9\u6210\u672c\u5c31\u77e5\u9053\u4e86\u3002<\/p>\n<p>\u26a0\ufe0f \u907f\u57513&#xff1a;\u81ea\u8bc4\u5ba1\u4e0d\u7b49\u4e8e&#034;\u81ea\u55e8&#034;\u2014\u2014\u6a21\u578b\u5f88\u96be\u53d1\u73b0\u81ea\u5df1\u7684\u7cfb\u7edf\u6027\u504f\u89c1 \u6362\u4e2a\u6bd4\u55bb\u4f60\u5c31\u61c2\u4e86&#xff1a;\u8ba9\u4e00\u4e2a\u5e7f\u4e1c\u4eba\u8bc4\u5ba1\u81ea\u5df1\u5199\u7684&#034;\u6b63\u5b97\u5ddd\u83dc\u83dc\u8c31&#034;&#xff0c;\u9760\u8c31\u5417&#xff1f;\u6240\u4ee5L4\u7684\u6b63\u786e\u6253\u5f00\u65b9\u5f0f\u662f&#xff1a;\u7528\u4e0d\u540c\u6a21\u578b\u505a\u8bc4\u5ba1&#xff08;\u5982\u7528Claude\u8bc4\u5ba1GPT\u7684\u8f93\u51fa&#xff0c;\u6216\u7528GPT-4\u8bc4\u5ba1GPT-3.5\u7684\u8f93\u51fa&#xff09;&#xff0c;\u8fd9\u53eb&#034;\u4ea4\u53c9\u9a8c\u8bc1&#034;\u3002<\/p>\n<p>def cross_model_review(generate_model, review_model, task: str) -&gt; dict:<br \/>\n    &#034;&#034;&#034;\u7528\u4e0d\u540c\u6a21\u578b\u505a\u4ea4\u53c9\u8bc4\u5ba1&#034;&#034;&#034;<br \/>\n    output &#061; generate_model(task)<br \/>\n    review &#061; review_model(f&#034;&#034;&#034;<br \/>\n\u8bf7\u4f5c\u4e3a\u72ec\u7acb\u8bc4\u5ba1\u5458&#xff0c;\u5ba1\u67e5\u4ee5\u4e0bAI\u8f93\u51fa&#xff1a;<br \/>\n\u3010\u8f93\u51fa\u3011<br \/>\n{output}<br \/>\n\u3010\u8bc4\u5ba1\u8981\u70b9\u3011<br \/>\n\u9010\u6761\u6307\u51fa\u6240\u6709\u95ee\u9898&#xff0c;\u4e0d\u8981\u987e\u53ca&#034;\u540c\u884c\u9762\u5b50&#034;\u3002<br \/>\n    &#034;&#034;&#034;)<br \/>\n    return {&#034;output&#034;: output, &#034;review&#034;: review}<\/p>\n<hr \/>\n<h3 id=\"%E4%BA%8C%E3%80%81Prompt%E6%A8%A1%E6%9D%BF%E4%BD%93%E7%B3%BB%E8%AE%BE%E8%AE%A1\">\u4e8c\u3001Prompt\u6a21\u677f\u4f53\u7cfb\u8bbe\u8ba1<\/h3>\n<p>\u641e\u61c2\u56db\u5c42\u4e4b\u540e&#xff0c;\u6765\u770b\u600e\u4e48\u628a\u8fd9\u4e9b\u4e1c\u897f\u5de5\u7a0b\u5316\u3002\u6211\u8e29\u4e86\u534a\u5e74\u5751\u603b\u7ed3\u51fa\u7684Prompt\u6a21\u677f\u4e94\u8981\u7d20&#xff1a;<\/p>\n<p>graph TD<br \/>\n    T[&#034;&#x1f4cb; Prompt\u6a21\u677f\u4e94\u8981\u7d20&#034;]<br \/>\n    T &#8211;&gt; R[&#034;&#x1f3ad; \u89d2\u8272(Role)&lt;br\/&gt;\u4f60\u662f\u4ec0\u4e48\u8eab\u4efd&#xff1f;&#034;]<br \/>\n    T &#8211;&gt; TK[&#034;&#x1f4dd; \u4efb\u52a1(Task)&lt;br\/&gt;\u5177\u4f53\u8981\u505a\u4ec0\u4e48&#xff1f;&#034;]<br \/>\n    T &#8211;&gt; F[&#034;&#x1f4d0; \u683c\u5f0f(Format)&lt;br\/&gt;\u8f93\u51fa\u957f\u4ec0\u4e48\u6837&#xff1f;&#034;]<br \/>\n    T &#8211;&gt; C[&#034;&#x1f512; \u7ea6\u675f(Constraints)&lt;br\/&gt;\u7edd\u5bf9\u4e0d\u80fd\u5e72\u4ec0\u4e48&#xff1f;&#034;]<br \/>\n    T &#8211;&gt; E[&#034;&#x1f3af; \u793a\u4f8b(Examples)&lt;br\/&gt;\u505a\u5f97\u597d\u662f\u4ec0\u4e48\u6837&#xff1f;&#034;]<\/p>\n<p>    R -.- R1[&#034;\u6fc0\u6d3b\u9886\u57df\u77e5\u8bc6&#034;]<br \/>\n    TK -.- TK1[&#034;\u754c\u5b9a\u4ea7\u51fa\u8fb9\u754c&#034;]<br \/>\n    F -.- F1[&#034;\u63a7\u5236\u8f93\u51fa\u7ed3\u6784&#034;]<br \/>\n    C -.- C1[&#034;\u9632\u6b62\u8dd1\u504f&#034;]<br \/>\n    E -.- E1[&#034;Few-shot\u5bf9\u9f50&#034;]<\/p>\n<p>    style T fill:#4A90D9,color:#fff<\/p>\n<p>\u76f4\u63a5\u4e0a\u53ef\u7528\u7684Prompt\u6a21\u677f\u7ba1\u7406\u7c7b&#xff1a;<\/p>\n<p>from dataclasses import dataclass, field<br \/>\nfrom typing import Optional<br \/>\nimport json<\/p>\n<p>&#064;dataclass<br \/>\nclass PromptTemplate:<br \/>\n    &#034;&#034;&#034;Prompt\u6a21\u677f\u6570\u636e\u7c7b&#034;&#034;&#034;<br \/>\n    name: str<br \/>\n    role: str<br \/>\n    task: str<br \/>\n    format_spec: str<br \/>\n    constraints: list[str] &#061; field(default_factory&#061;list)<br \/>\n    examples: list[dict] &#061; field(default_factory&#061;list)<br \/>\n    version: str &#061; &#034;1.0.0&#034;<\/p>\n<p>    def build(self, **kwargs) -&gt; str:<br \/>\n        &#034;&#034;&#034;\u6784\u5efa\u5b8c\u6574Prompt&#034;&#034;&#034;<br \/>\n        parts &#061; []<\/p>\n<p>        if self.role:<br \/>\n            parts.append(f&#034;\u3010\u89d2\u8272\u3011{self.role}&#034;)<\/p>\n<p>        task_text &#061; self.task.format(**kwargs) if kwargs else self.task<br \/>\n        parts.append(f&#034;\u3010\u4efb\u52a1\u3011{task_text}&#034;)<\/p>\n<p>        if self.format_spec:<br \/>\n            parts.append(f&#034;\u3010\u8f93\u51fa\u683c\u5f0f\u3011{self.format_spec}&#034;)<\/p>\n<p>        if self.constraints:<br \/>\n            constraints_text &#061; &#034;\\\\n&#034;.join(f&#034;- {c}&#034; for c in self.constraints)<br \/>\n            parts.append(f&#034;\u3010\u7ea6\u675f\u6761\u4ef6\u3011\\\\n{constraints_text}&#034;)<\/p>\n<p>        if self.examples:<br \/>\n            examples_text &#061; &#034;&#034;<br \/>\n            for i, ex in enumerate(self.examples, 1):<br \/>\n                examples_text &#043;&#061; f&#034;\\\\n\u793a\u4f8b{i}&#xff1a;\\\\n\u8f93\u5165&#xff1a;{ex[&#039;input&#039;]}\\\\n\u8f93\u51fa&#xff1a;{ex[&#039;output&#039;]}\\\\n&#034;<br \/>\n            parts.append(f&#034;\u3010\u53c2\u8003\u793a\u4f8b\u3011{examples_text}&#034;)<\/p>\n<p>        return &#034;\\\\n\\\\n&#034;.join(parts)<\/p>\n<p># &#061;&#061;&#061;&#061;&#061; \u5b9e\u9645\u4f7f\u7528 &#061;&#061;&#061;&#061;&#061;<br \/>\ncode_review_template &#061; PromptTemplate(<br \/>\n    name&#061;&#034;\u4ee3\u7801\u5ba1\u67e5\u6a21\u677f&#034;,<br \/>\n    role&#061;&#034;\u4f60\u662f\u4e00\u4f4d\u8d44\u6df1Python\u4ee3\u7801\u5ba1\u67e5\u4e13\u5bb6&#xff0c;\u7cbe\u901aPEP 8\u89c4\u8303\u548c\u8bbe\u8ba1\u6a21\u5f0f&#034;,<br \/>\n    task&#061;&#034;\u5ba1\u67e5\u4ee5\u4e0bPython\u4ee3\u7801&#xff0c;\u7ed9\u51fa\u8be6\u7ec6\u7684\u6539\u8fdb\u5efa\u8bae&#xff1a;\\\\n&#096;&#096;&#096;python\\\\n{code}\\\\n&#096;&#096;&#096;&#034;,<br \/>\n    format_spec&#061;&#034;&#034;&#034;<br \/>\n\u8f93\u51faJSON\u683c\u5f0f&#xff1a;<br \/>\n{<br \/>\n  &#034;overall_score&#034;: 0-100,<br \/>\n  &#034;issues&#034;: [<br \/>\n    {&#034;severity&#034;: &#034;\u9ad8\/\u4e2d\/\u4f4e&#034;, &#034;line&#034;: \u884c\u53f7, &#034;description&#034;: &#034;\u95ee\u9898\u63cf\u8ff0&#034;,<br \/>\n     &#034;suggestion&#034;: &#034;\u6539\u8fdb\u5efa\u8bae&#034;, &#034;rule&#034;: &#034;\u8fdd\u53cd\u7684\u89c4\u8303&#034;}<br \/>\n  ],<br \/>\n  &#034;strengths&#034;: [&#034;\u4f18\u70b91&#034;, &#034;\u4f18\u70b92&#034;],<br \/>\n  &#034;refactored_code&#034;: &#034;\u91cd\u6784\u540e\u7684\u4ee3\u7801\u5b57\u7b26\u4e32&#034;<br \/>\n}<br \/>\n&#034;&#034;&#034;,<br \/>\n    constraints&#061;[<br \/>\n        &#034;\u4e0d\u4fee\u6539\u4ee3\u7801\u7684\u4e1a\u52a1\u903b\u8f91&#034;,<br \/>\n        &#034;\u6bcf\u4e2aissue\u5fc5\u987b\u5f15\u7528\u5177\u4f53\u7684PEP\u6216\u8bbe\u8ba1\u6a21\u5f0f&#034;,<br \/>\n        &#034;\u91cd\u6784\u4ee3\u7801\u5fc5\u987b\u53ef\u8fd0\u884c&#034;,<br \/>\n        &#034;\u4e0d\u8981\u8f93\u51faJSON\u4e4b\u5916\u7684\u4efb\u4f55\u6587\u672c&#034;<br \/>\n    ],<br \/>\n    examples&#061;[{<br \/>\n        &#034;input&#034;: &#034;def f(x): return x*2&#034;,<br \/>\n        &#034;output&#034;: &#039;{&#034;overall_score&#034;: 45, &#034;issues&#034;: [&#8230;]}&#039;<br \/>\n    }]<br \/>\n)<\/p>\n<p># \u6784\u5efaPrompt<br \/>\ncode &#061; &#034;def calc(a,b):\\\\n    return a&#043;b&#034;<br \/>\nfinal_prompt &#061; code_review_template.build(code&#061;code)<br \/>\nprint(final_prompt)<\/p>\n<p>&#x1f4a1; \u6548\u7387\u6280\u5de73&#xff1a;\u6a21\u677f\u7ee7\u627f\u2014\u2014\u5b50\u6a21\u677f\u8986\u76d6\u7236\u6a21\u677f\u7684\u7ea6\u675f \u4f60\u4f1a\u53d1\u73b0\u4e0d\u540c\u9879\u76ee\u7684\u5ba1\u67e5\u6807\u51c6\u4e0d\u4e00\u6837\u3002\u522b\u590d\u5236\u7c98\u8d34&#xff0c;\u7528\u7ee7\u627f&#xff1a;<\/p>\n<p>class PromptTemplateLibrary:<br \/>\n    &#034;&#034;&#034;Prompt\u6a21\u677f\u5e93&#xff0c;\u652f\u6301\u7ee7\u627f\u548c\u7248\u672c\u7ba1\u7406&#034;&#034;&#034;<\/p>\n<p>    def __init__(self):<br \/>\n        self._templates: dict[str, PromptTemplate] &#061; {}<\/p>\n<p>    def register(self, template: PromptTemplate):<br \/>\n        self._templates[template.name] &#061; template<\/p>\n<p>    def inherit(self, base_name: str, new_name: str,<br \/>\n                overrides: dict) -&gt; PromptTemplate:<br \/>\n        &#034;&#034;&#034;\u57fa\u4e8e\u5df2\u6709\u6a21\u677f\u521b\u5efa\u53d8\u4f53&#034;&#034;&#034;<br \/>\n        base &#061; self._templates[base_name]<br \/>\n        new_data &#061; {<br \/>\n            &#034;name&#034;: new_name,<br \/>\n            &#034;role&#034;: base.role,<br \/>\n            &#034;task&#034;: base.task,<br \/>\n            &#034;format_spec&#034;: base.format_spec,<br \/>\n            &#034;constraints&#034;: list(base.constraints),<br \/>\n            &#034;examples&#034;: list(base.examples),<br \/>\n            &#034;version&#034;: f&#034;{base.version}&#043;{overrides.get(&#039;version_suffix&#039;, &#039;variant&#039;)}&#034;<br \/>\n        }<br \/>\n        new_data.update({k: v for k, v in overrides.items()<br \/>\n                        if k !&#061; &#039;version_suffix&#039;})<br \/>\n        new_template &#061; PromptTemplate(**new_data)<br \/>\n        self.register(new_template)<br \/>\n        return new_template<\/p>\n<p># \u4f7f\u7528\u793a\u4f8b<br \/>\nlib &#061; PromptTemplateLibrary()<br \/>\nlib.register(code_review_template)<\/p>\n<p>security_review &#061; lib.inherit(<br \/>\n    &#034;\u4ee3\u7801\u5ba1\u67e5\u6a21\u677f&#034;,<br \/>\n    &#034;\u5b89\u5168\u5ba1\u67e5\u6a21\u677f&#034;,<br \/>\n    {<br \/>\n        &#034;role&#034;: &#034;\u4f60\u662f\u4e00\u4f4d\u5e94\u7528\u5b89\u5168\u4e13\u5bb6&#xff0c;\u7cbe\u901aOWASP Top 10\u548cCWE&#034;,<br \/>\n        &#034;constraints&#034;: [<br \/>\n            &#034;\u91cd\u70b9\u5173\u6ce8SQL\u6ce8\u5165\u3001XSS\u3001CSRF\u7b49\u5b89\u5168\u6f0f\u6d1e&#034;,<br \/>\n            &#034;\u6bcf\u4e2a\u6f0f\u6d1e\u5fc5\u987b\u7ed9\u51faCWE\u7f16\u53f7&#034;,<br \/>\n            &#034;\u63d0\u4f9b\u5177\u4f53\u4fee\u590d\u4ee3\u7801&#034;<br \/>\n        ]<br \/>\n    }<br \/>\n)<\/p>\n<hr \/>\n<h3 id=\"%E4%B8%89%E3%80%81%E7%BB%93%E6%9E%84%E5%8C%96%E8%BE%93%E5%87%BA%E6%8E%A7%E5%88%B6\">\u4e09\u3001\u7ed3\u6784\u5316\u8f93\u51fa\u63a7\u5236<\/h3>\n<p>\u201c\u7ed9\u6211\u8f93\u51faJSON&#034;\u548c&#034;\u7ed9\u6211\u8f93\u51fa\u7b26\u5408\u8fd9\u4e2aJSON Schema\u7684JSON\u201d\u2014\u2014\u6548\u679c\u5929\u5dee\u5730\u522b\u3002<\/p>\n<p>import json<br \/>\nfrom pydantic import BaseModel, Field<br \/>\nfrom typing import Optional<\/p>\n<p>class ProductReview(BaseModel):<br \/>\n    &#034;&#034;&#034;\u7ed3\u6784\u5316\u8f93\u51fa\u7684Pydantic\u6a21\u578b&#034;&#034;&#034;<br \/>\n    product_name: str &#061; Field(description&#061;&#034;\u5546\u54c1\u540d\u79f0&#034;)<br \/>\n    sentiment: str &#061; Field(description&#061;&#034;\u60c5\u611f\u503e\u5411&#034;, pattern&#061;&#034;^(\u6b63\u9762|\u8d1f\u9762|\u4e2d\u6027)$&#034;)<br \/>\n    score: float &#061; Field(description&#061;&#034;\u8bc4\u5206&#034;, ge&#061;0, le&#061;5)<br \/>\n    key_points: list[str] &#061; Field(description&#061;&#034;\u5173\u952e\u8bc4\u4ef7\u8981\u70b9&#034;, min_items&#061;1)<br \/>\n    summary: str &#061; Field(description&#061;&#034;\u4e00\u53e5\u8bdd\u603b\u7ed3&#034;, max_length&#061;100)<br \/>\n    category: Optional[str] &#061; Field(None, description&#061;&#034;\u5546\u54c1\u5206\u7c7b&#034;)<\/p>\n<p>def build_structured_prompt(task: str, schema_model) -&gt; str:<br \/>\n    &#034;&#034;&#034;<br \/>\n    \u6784\u5efa\u5e26JSON Schema\u7ea6\u675f\u7684Prompt<br \/>\n    \u6838\u5fc3\u601d\u8def&#xff1a;\u628aPydantic Schema\u8f6c\u6210\u81ea\u7136\u8bed\u8a00\u7ea6\u675f &#043; JSON\u6a21\u677f<br \/>\n    &#034;&#034;&#034;<br \/>\n    schema &#061; schema_model.model_json_schema()<br \/>\n    properties &#061; schema.get(&#034;properties&#034;, {})<\/p>\n<p>    # \u751f\u6210\u5b57\u6bb5\u8bf4\u660e<br \/>\n    field_descriptions &#061; []<br \/>\n    for field_name, field_info in properties.items():<br \/>\n        desc &#061; field_info.get(&#034;description&#034;, &#034;&#034;)<br \/>\n        field_type &#061; field_info.get(&#034;type&#034;, &#034;string&#034;)<br \/>\n        required &#061; field_name in schema.get(&#034;required&#034;, [])<\/p>\n<p>        # Pattern\u7ea6\u675f<br \/>\n        pattern_str &#061; &#034;&#034;<br \/>\n        if &#034;pattern&#034; in field_info:<br \/>\n            pattern_str &#061; f&#034; (\u5fc5\u987b\u5339\u914d: {field_info[&#039;pattern&#039;]})&#034;<\/p>\n<p>        # \u6570\u503c\u7ea6\u675f<br \/>\n        range_str &#061; &#034;&#034;<br \/>\n        if &#034;minimum&#034; in field_info:<br \/>\n            range_str &#043;&#061; f&#034; &gt;&#061; {field_info[&#039;minimum&#039;]}&#034;<br \/>\n        if &#034;maximum&#034; in field_info:<br \/>\n            range_str &#043;&#061; f&#034; &lt;&#061; {field_info[&#039;maximum&#039;]}&#034;<\/p>\n<p>        req_mark &#061; &#034;\u3010\u5fc5\u586b\u3011&#034; if required else &#034;\u3010\u53ef\u9009\u3011&#034;<br \/>\n        field_descriptions.append(<br \/>\n            f&#034;  &#8211; {req_mark} {field_name} ({field_type}{range_str}): {desc}{pattern_str}&#034;<br \/>\n        )<\/p>\n<p>    prompt &#061; f&#034;&#034;&#034;<br \/>\n{task}<\/p>\n<p>\u4e25\u683c\u6309\u4ee5\u4e0bJSON Schema\u8f93\u51fa&#xff0c;\u4e0d\u8981\u6dfb\u52a0\u4efb\u4f55\u89e3\u91ca\u6587\u5b57&#xff1a;<\/p>\n<p>{json.dumps(schema, ensure_ascii&#061;False, indent&#061;2)}<\/p>\n<p>\u5b57\u6bb5\u7ea6\u675f\u8bf4\u660e&#xff1a;<br \/>\n{&#034;&#034;.join(field_descriptions)}<\/p>\n<p>\u26a0\ufe0f \u8f93\u51fa\u5fc5\u987b\u662f\u7eafJSON&#xff0c;\u80fd\u88ab json.loads() \u76f4\u63a5\u89e3\u6790\u3002<br \/>\n&#034;&#034;&#034;<br \/>\n    return prompt<\/p>\n<p># \u4f7f\u7528<br \/>\ntask &#061; &#034;\u5206\u6790\u4ee5\u4e0b\u5546\u54c1\u8bc4\u8bba\u7684\u60c5\u611f&#xff1a;&#039;\u8fd9\u4e2a\u624b\u673a\u62cd\u7167\u771f\u4e0d\u9519&#xff0c;\u4f46\u7535\u6c60\u7eed\u822a\u592a\u5dee\u4e86&#039;&#034;<br \/>\nstructured_prompt &#061; build_structured_prompt(task, ProductReview)<br \/>\nprint(structured_prompt)<\/p>\n<p>XML\u6807\u7b7e\u662f\u53e6\u4e00\u4e2a\u5f3a\u5927\u7684\u7ea6\u675f\u5de5\u5177\u2014\u2014LLM\u5bf9XML\u7ed3\u6784\u7684\u7406\u89e3\u51fa\u5947\u5730\u597d&#xff1a;<\/p>\n<p>def xml_constrained_prompt(text: str) -&gt; str:<br \/>\n    &#034;&#034;&#034;\u4f7f\u7528XML\u6807\u7b7e\u5f3a\u5236\u7ea6\u675f\u8f93\u51fa\u683c\u5f0f&#034;&#034;&#034;<br \/>\n    return f&#034;&#034;&#034;<br \/>\n\u5206\u6790\u4ee5\u4e0b\u6587\u672c\u7684\u60c5\u611f\u3001\u4e3b\u9898\u548c\u6458\u8981\u3002<\/p>\n<p>&lt;text&gt;<br \/>\n{text}<br \/>\n&lt;\/text&gt;<\/p>\n<p>\u4e25\u683c\u6309\u4ee5\u4e0bXML\u683c\u5f0f\u8f93\u51fa&#xff0c;\u4e0d\u8981\u6709\u4efb\u4f55\u989d\u5916\u5185\u5bb9&#xff1a;<\/p>\n<p>&lt;analysis&gt;<br \/>\n  &lt;sentiment&gt;\u6b63\u9762\/\u8d1f\u9762\/\u4e2d\u6027&lt;\/sentiment&gt;<br \/>\n  &lt;confidence&gt;0\u52301\u4e4b\u95f4\u7684\u5c0f\u6570&lt;\/confidence&gt;<br \/>\n  &lt;topics&gt;<br \/>\n    &lt;topic&gt;\u4e3b\u98981&lt;\/topic&gt;<br \/>\n    &lt;topic&gt;\u4e3b\u98982&lt;\/topic&gt;<br \/>\n  &lt;\/topics&gt;<br \/>\n  &lt;summary&gt;\u4e0d\u8d85\u8fc750\u5b57\u7684\u6458\u8981&lt;\/summary&gt;<br \/>\n&lt;\/analysis&gt;<\/p>\n<p>\u6ce8\u610f&#xff1a;XML\u6807\u7b7e\u5fc5\u987b\u5b8c\u6574\u95ed\u5408&#xff0c;\u4e0d\u8981\u9057\u6f0f\u4efb\u4f55\u6807\u7b7e\u3002<br \/>\n&#034;&#034;&#034;<\/p>\n<hr \/>\n<h3 id=\"%E5%9B%9B%E3%80%81Few-shot%E7%A4%BA%E4%BE%8B%E9%80%89%E6%8B%A9%E7%AD%96%E7%95%A5\">\u56db\u3001Few-shot\u793a\u4f8b\u9009\u62e9\u7b56\u7565<\/h3>\n<p>Few-shot\u4e0d\u662f\u968f\u4fbf\u6254\u51e0\u4e2a\u4f8b\u5b50\u3002\u4f8b\u5b50\u9009\u9519\u4e86&#xff0c;\u6548\u679c\u8fd8\u4e0d\u5982Zero-shot\u3002<\/p>\n<p>\u5173\u952e\u95ee\u9898&#xff1a;\u4f60\u624b\u5934100\u4e2a\u793a\u4f8b&#xff0c;\u9009\u54ea3\u4e2a\u653e\u8fdbPrompt&#xff1f; \u7b54\u6848\u662f&#xff1a;\u9009\u548c\u5f53\u524d\u8f93\u5165\u8bed\u4e49\u6700\u76f8\u4f3c\u7684\u3002<\/p>\n<p>import numpy as np<br \/>\nfrom sklearn.metrics.pairwise import cosine_similarity<br \/>\nfrom typing import Optional<\/p>\n<p>class FewShotSelector:<br \/>\n    &#034;&#034;&#034;<br \/>\n    Few-shot\u793a\u4f8b\u9009\u62e9\u5668<br \/>\n    \u7b56\u7565&#xff1a;\u57fa\u4e8eembedding\u7684\u8bed\u4e49\u76f8\u4f3c\u5ea6\u81ea\u52a8\u9009\u62e9\u6700\u4f73\u793a\u4f8b<br \/>\n    &#034;&#034;&#034;<\/p>\n<p>    def __init__(self, examples: list[dict],<br \/>\n                 embedding_func: Optional[callable] &#061; None):<br \/>\n        &#034;&#034;&#034;<br \/>\n        Args:<br \/>\n            examples: [{&#034;input&#034;: &#034;&#8230;&#034;, &#034;output&#034;: &#034;&#8230;&#034;}]<br \/>\n            embedding_func: \u6587\u672c \u2192 \u5411\u91cf\u7684\u51fd\u6570<br \/>\n        &#034;&#034;&#034;<br \/>\n        self.examples &#061; examples<br \/>\n        self._embed &#061; embedding_func or self._default_embed<br \/>\n        self._example_embeddings &#061; None<br \/>\n        self._precompute()<\/p>\n<p>    def _default_embed(self, text: str) -&gt; np.ndarray:<br \/>\n        &#034;&#034;&#034;<br \/>\n        \u9ed8\u8ba4embedding\u65b9\u6cd5&#xff08;\u751f\u4ea7\u73af\u5883\u8bf7\u66ff\u6362\u4e3aOpenAI API\u8c03\u7528&#xff09;<br \/>\n        \u8fd9\u91cc\u7528\u7b80\u5355\u7684\u5b57\u7b26\u7ea7TF\u4f5c\u4e3a\u6f14\u793a<br \/>\n        &#034;&#034;&#034;<br \/>\n        # \u5b9e\u9645\u4f7f\u7528\u65f6\u66ff\u6362\u4e3a&#xff1a;<br \/>\n        # response &#061; openai.Embedding.create(<br \/>\n        #     model&#061;&#034;text-embedding-3-small&#034;, input&#061;text<br \/>\n        # )<br \/>\n        # return np.array(response.data[0].embedding)<\/p>\n<p>        # \u6f14\u793a\u7528&#xff1a;\u7b80\u5355\u7684bag-of-chars<br \/>\n        chars &#061; set(&#039;abcdefghijklmnopqrstuvwxyz &#039;)<br \/>\n        vector &#061; np.zeros(len(chars))<br \/>\n        text_lower &#061; text.lower()<br \/>\n        for i, c in enumerate(chars):<br \/>\n            vector[i] &#061; text_lower.count(c) \/ max(len(text_lower), 1)<br \/>\n        return vector<\/p>\n<p>    def _precompute(self):<br \/>\n        &#034;&#034;&#034;\u9884\u8ba1\u7b97\u6240\u6709\u793a\u4f8b\u7684embedding&#034;&#034;&#034;<br \/>\n        self._example_embeddings &#061; np.array([<br \/>\n            self._embed(ex[&#034;input&#034;]) for ex in self.examples<br \/>\n        ])<\/p>\n<p>    def select(self, query: str, k: int &#061; 3,<br \/>\n               diversity_weight: float &#061; 0.2) -&gt; list[dict]:<br \/>\n        &#034;&#034;&#034;<br \/>\n        \u9009\u62e9k\u4e2a\u6700\u4f73\u793a\u4f8b<\/p>\n<p>        Args:<br \/>\n            query: \u5f53\u524d\u8f93\u5165<br \/>\n            k: \u9009\u62e9\u6570\u91cf<br \/>\n            diversity_weight: \u591a\u6837\u6027\u6743\u91cd&#xff08;0&#061;\u7eaf\u76f8\u4f3c\u5ea6&#xff0c;1&#061;\u7eaf\u591a\u6837\u6027&#xff09;<br \/>\n        &#034;&#034;&#034;<br \/>\n        query_embedding &#061; self._embed(query).reshape(1, -1)<br \/>\n        similarities &#061; cosine_similarity(<br \/>\n            query_embedding, self._example_embeddings<br \/>\n        )[0]<\/p>\n<p>        # MMR (Maximal Marginal Relevance) \u5e73\u8861\u76f8\u4f3c\u5ea6\u548c\u591a\u6837\u6027<br \/>\n        selected_indices &#061; []<br \/>\n        remaining &#061; list(range(len(self.examples)))<\/p>\n<p>        for _ in range(min(k, len(self.examples))):<br \/>\n            if not selected_indices:<br \/>\n                # \u7b2c\u4e00\u4e2a\u9009\u6700\u76f8\u4f3c\u7684<br \/>\n                best_idx &#061; remaining[int(np.argmax(similarities[remaining]))]<br \/>\n            else:<br \/>\n                # \u540e\u7eed\u7528MMR\u516c\u5f0f&#xff1a;\u03bb*\u76f8\u4f3c\u5ea6 &#8211; (1-\u03bb)*\u5df2\u9009\u793a\u4f8b\u6700\u5927\u76f8\u4f3c\u5ea6<br \/>\n                mmr_scores &#061; []<br \/>\n                for idx in remaining:<br \/>\n                    relevance &#061; similarities[idx]<br \/>\n                    diversity &#061; max(<br \/>\n                        cosine_similarity(<br \/>\n                            self._example_embeddings[idx].reshape(1, -1),<br \/>\n                            self._example_embeddings[selected_indices]<br \/>\n                        )[0]<br \/>\n                    ) if selected_indices else 0<br \/>\n                    mmr &#061; (1 &#8211; diversity_weight) * relevance &#8211; diversity_weight * diversity<br \/>\n                    mmr_scores.append(mmr)<br \/>\n                best_idx &#061; remaining[int(np.argmax(mmr_scores))]<\/p>\n<p>            selected_indices.append(best_idx)<br \/>\n            remaining.remove(best_idx)<\/p>\n<p>        return [self.examples[i] for i in selected_indices]<\/p>\n<p># &#061;&#061;&#061;&#061;&#061; \u4f7f\u7528\u6f14\u793a &#061;&#061;&#061;&#061;&#061;<br \/>\nexamples &#061; [<br \/>\n    {&#034;input&#034;: &#034;\u8fd9\u4e2a\u9910\u5385\u670d\u52a1\u6001\u5ea6\u5f88\u5dee&#034;, &#034;output&#034;: &#034;\u8d1f\u9762&#034;},<br \/>\n    {&#034;input&#034;: &#034;\u83dc\u54c1\u5473\u9053\u975e\u5e38\u68d2&#xff01;&#034;, &#034;output&#034;: &#034;\u6b63\u9762&#034;},<br \/>\n    {&#034;input&#034;: &#034;\u73af\u5883\u4e00\u822c&#xff0c;\u4ef7\u683c\u8fd8\u884c&#034;, &#034;output&#034;: &#034;\u4e2d\u6027&#034;},<br \/>\n    {&#034;input&#034;: &#034;\u592a\u96be\u5403\u4e86&#xff0c;\u518d\u4e5f\u4e0d\u4f1a\u6765\u4e86&#034;, &#034;output&#034;: &#034;\u8d1f\u9762&#034;},<br \/>\n    {&#034;input&#034;: &#034;\u6027\u4ef7\u6bd4\u8d85\u9ad8&#xff0c;\u63a8\u8350&#xff01;&#034;, &#034;output&#034;: &#034;\u6b63\u9762&#034;},<br \/>\n    {&#034;input&#034;: &#034;\u5916\u5356\u9001\u5f97\u5f88\u5feb\u4f46\u6709\u70b9\u51c9\u4e86&#034;, &#034;output&#034;: &#034;\u4e2d\u6027&#034;},<br \/>\n]<\/p>\n<p>selector &#061; FewShotSelector(examples)<br \/>\nselected &#061; selector.select(&#034;\u8fd9\u5bb6\u5e97\u53e3\u5473\u7edd\u4e86&#xff0c;\u4e0b\u6b21\u8fd8\u6765&#034;, k&#061;2)<br \/>\nfor i, ex in enumerate(selected, 1):<br \/>\n    print(f&#034;\u793a\u4f8b{i}: {ex[&#039;input&#039;]} \u2192 {ex[&#039;output&#039;]}&#034;)<\/p>\n<hr \/>\n<h3 id=\"%E4%BA%94%E3%80%81Prompt%E7%89%88%E6%9C%AC%E7%AE%A1%E7%90%86\">\u4e94\u3001Prompt\u7248\u672c\u7ba1\u7406<\/h3>\n<p>Prompt\u662f\u548c\u4ee3\u7801\u4e00\u6837\u91cd\u8981\u7684\u8d44\u4ea7\u3002\u4e0d\u7ba1\u7406Prompt\u7248\u672c &#061; \u4e0d\u7ba1\u7406\u4ee3\u7801\u7248\u672c &#061; \u7b49\u7740\u51fa\u4e8b\u6545\u3002<\/p>\n<p>&#034;&#034;&#034;<br \/>\nPrompt\u7248\u672c\u7ba1\u7406\u7cfb\u7edf<br \/>\n\u76ee\u5f55\u7ed3\u6784&#xff1a;<br \/>\nprompts\/<br \/>\n\u251c\u2500\u2500 code_review\/<br \/>\n\u2502   \u251c\u2500\u2500 v1.0.0.yaml<br \/>\n\u2502   \u251c\u2500\u2500 v1.1.0.yaml<br \/>\n\u2502   \u2514\u2500\u2500 v2.0.0.yaml  \u2190 \u5f53\u524d\u751f\u4ea7\u7248\u672c<br \/>\n\u251c\u2500\u2500 text_analysis\/<br \/>\n\u2502   \u2514\u2500\u2500 v1.0.0.yaml<br \/>\n\u2514\u2500\u2500 changelog.md<br \/>\n&#034;&#034;&#034;<\/p>\n<p>import yaml<br \/>\nimport hashlib<br \/>\nfrom datetime import datetime<br \/>\nfrom pathlib import Path<\/p>\n<p>class PromptVersionManager:<br \/>\n    &#034;&#034;&#034;\u57fa\u4e8e\u6587\u4ef6\u7cfb\u7edf\u7684Prompt\u7248\u672c\u7ba1\u7406&#034;&#034;&#034;<\/p>\n<p>    def __init__(self, base_path: str &#061; &#034;.\/prompts&#034;):<br \/>\n        self.base_path &#061; Path(base_path)<br \/>\n        self.base_path.mkdir(parents&#061;True, exist_ok&#061;True)<\/p>\n<p>    def save(self, template: PromptTemplate, author: str &#061; &#034;system&#034;,<br \/>\n             changelog: str &#061; &#034;&#034;) -&gt; str:<br \/>\n        &#034;&#034;&#034;\u4fdd\u5b58\u65b0\u7248\u672cPrompt&#xff0c;\u81ea\u52a8\u751f\u6210\u7248\u672c\u53f7&#034;&#034;&#034;<br \/>\n        prompt_dir &#061; self.base_path \/ template.name<br \/>\n        prompt_dir.mkdir(exist_ok&#061;True)<\/p>\n<p>        # \u81ea\u52a8\u9012\u589e\u7248\u672c\u53f7<br \/>\n        existing &#061; sorted(prompt_dir.glob(&#034;v*.yaml&#034;))<br \/>\n        if existing:<br \/>\n            last_ver &#061; existing[-1].stem.lstrip(&#034;v&#034;)<br \/>\n            major, minor, patch &#061; map(int, last_ver.split(&#034;.&#034;))<br \/>\n            new_version &#061; f&#034;v{major}.{minor}.{patch &#043; 1}&#034;<br \/>\n        else:<br \/>\n            new_version &#061; &#034;v0.1.0&#034;<\/p>\n<p>        # \u5e8f\u5217\u5316Prompt\u6a21\u677f<br \/>\n        data &#061; {<br \/>\n            &#034;name&#034;: template.name,<br \/>\n            &#034;version&#034;: new_version,<br \/>\n            &#034;role&#034;: template.role,<br \/>\n            &#034;task&#034;: template.task,<br \/>\n            &#034;format_spec&#034;: template.format_spec,<br \/>\n            &#034;constraints&#034;: template.constraints,<br \/>\n            &#034;examples&#034;: template.examples,<br \/>\n            &#034;metadata&#034;: {<br \/>\n                &#034;author&#034;: author,<br \/>\n                &#034;created_at&#034;: datetime.now().isoformat(),<br \/>\n                &#034;content_hash&#034;: hashlib.sha256(<br \/>\n                    template.task.encode()<br \/>\n                ).hexdigest()[:8],<br \/>\n                &#034;changelog&#034;: changelog<br \/>\n            }<br \/>\n        }<\/p>\n<p>        filepath &#061; prompt_dir \/ f&#034;{new_version}.yaml&#034;<br \/>\n        with open(filepath, &#034;w&#034;, encoding&#061;&#034;utf-8&#034;) as f:<br \/>\n            yaml.dump(data, f, allow_unicode&#061;True, sort_keys&#061;False)<\/p>\n<p>        # \u66f4\u65b0changelog<br \/>\n        self._update_changelog(template.name, new_version, changelog)<\/p>\n<p>        return new_version<\/p>\n<p>    def load(self, name: str, version: str &#061; &#034;latest&#034;) -&gt; PromptTemplate:<br \/>\n        &#034;&#034;&#034;\u52a0\u8f7d\u6307\u5b9a\u7248\u672c\u7684Prompt&#034;&#034;&#034;<br \/>\n        prompt_dir &#061; self.base_path \/ name<\/p>\n<p>        if version &#061;&#061; &#034;latest&#034;:<br \/>\n            versions &#061; sorted(prompt_dir.glob(&#034;v*.yaml&#034;))<br \/>\n            if not versions:<br \/>\n                raise FileNotFoundError(f&#034;No versions for: {name}&#034;)<br \/>\n            filepath &#061; versions[-1]<br \/>\n        else:<br \/>\n            filepath &#061; prompt_dir \/ f&#034;{version}.yaml&#034;<\/p>\n<p>        with open(filepath, &#034;r&#034;, encoding&#061;&#034;utf-8&#034;) as f:<br \/>\n            data &#061; yaml.safe_load(f)<\/p>\n<p>        return PromptTemplate(<br \/>\n            name&#061;data[&#034;name&#034;],<br \/>\n            role&#061;data.get(&#034;role&#034;, &#034;&#034;),<br \/>\n            task&#061;data[&#034;task&#034;],<br \/>\n            format_spec&#061;data.get(&#034;format_spec&#034;, &#034;&#034;),<br \/>\n            constraints&#061;data.get(&#034;constraints&#034;, []),<br \/>\n            examples&#061;data.get(&#034;examples&#034;, []),<br \/>\n            version&#061;data[&#034;version&#034;]<br \/>\n        )<\/p>\n<p>    def diff(self, name: str, v1: str, v2: str) -&gt; str:<br \/>\n        &#034;&#034;&#034;\u5bf9\u6bd4\u4e24\u4e2a\u7248\u672c\u5dee\u5f02&#034;&#034;&#034;<br \/>\n        t1 &#061; self.load(name, v1)<br \/>\n        t2 &#061; self.load(name, v2)<\/p>\n<p>        diff_lines &#061; [f&#034;# Diff: {name} {v1} \u2192 {v2}&#034;]<\/p>\n<p>        if t1.task !&#061; t2.task:<br \/>\n            diff_lines.append(&#034;\\\\n## \u4efb\u52a1\u53d8\u66f4&#034;)<br \/>\n            diff_lines.append(f&#034;- {t1.task[:50]}&#8230;&#034;)<br \/>\n            diff_lines.append(f&#034;&#043; {t2.task[:50]}&#8230;&#034;)<\/p>\n<p>        if t1.constraints !&#061; t2.constraints:<br \/>\n            diff_lines.append(&#034;\\\\n## \u7ea6\u675f\u53d8\u66f4&#034;)<br \/>\n            removed &#061; set(t1.constraints) &#8211; set(t2.constraints)<br \/>\n            added &#061; set(t2.constraints) &#8211; set(t1.constraints)<br \/>\n            for r in removed:<br \/>\n                diff_lines.append(f&#034;- [\u5220\u9664] {r}&#034;)<br \/>\n            for a in added:<br \/>\n                diff_lines.append(f&#034;&#043; [\u65b0\u589e] {a}&#034;)<\/p>\n<p>        return &#034;\\\\n&#034;.join(diff_lines)<\/p>\n<p>    def _update_changelog(self, name: str, version: str, message: str):<br \/>\n        changelog_path &#061; self.base_path \/ &#034;changelog.md&#034;<br \/>\n        with open(changelog_path, &#034;a&#034;, encoding&#061;&#034;utf-8&#034;) as f:<br \/>\n            f.write(<br \/>\n                f&#034;\\\\n## [{version}] {name} &#8211; &#034;<br \/>\n                f&#034;{datetime.now().strftime(&#039;%Y-%m-%d&#039;)}\\\\n&#034;<br \/>\n                f&#034;{message}\\\\n&#034;<br \/>\n            )<\/p>\n<p>\u914d\u4e0agit&#xff0c;\u8fd9\u5c31\u662f\u4e00\u5957\u5b8c\u6574\u7684Prompt CI\/CD\u3002\u6bcf\u6b21\u6539Prompt\u90fd\u8d70MR \u2192 Review \u2192 \u5408\u5e76 \u2192 \u90e8\u7f72\u7684\u6807\u51c6\u6d41\u7a0b\u3002Prompt\u4e0a\u7ebf\u540e\u6548\u679c\u53d8\u5dee&#xff1f;git revert \u56de\u6eda\u5230\u4e0a\u4e00\u4e2a\u7248\u672c&#xff0c;\u8ddf\u56de\u6eda\u4ee3\u7801\u4e00\u6837\u7b80\u5355\u3002<\/p>\n<hr \/>\n<h3 id=\"%E5%85%AD%E3%80%81A%2FB%E6%B5%8B%E8%AF%95%EF%BC%9APrompt%E7%9A%84%22%E7%81%B0%E5%BA%A6%E5%8F%91%E5%B8%83%22\">\u516d\u3001A\/B\u6d4b\u8bd5&#xff1a;Prompt\u7684&#034;\u7070\u5ea6\u53d1\u5e03&#034;<\/h3>\n<p>\u4f60\u600e\u4e48\u77e5\u9053\u65b0Prompt\u771f\u7684\u6bd4\u65e7\u7684\u597d&#xff1f;\u51ed\u611f\u89c9\u5417&#xff1f;\u4e0d\u884c\u2014\u2014\u5f97\u8dd1\u5b9e\u9a8c\u3002<\/p>\n<p>import time<br \/>\nfrom collections import defaultdict<br \/>\nfrom statistics import mean, stdev<\/p>\n<p>class PromptABTest:<br \/>\n    &#034;&#034;&#034;Prompt A\/B\u6d4b\u8bd5\u6846\u67b6&#034;&#034;&#034;<\/p>\n<p>    def __init__(self, model_func):<br \/>\n        self.model_func &#061; model_func<br \/>\n        self.results: dict[str, list[dict]] &#061; defaultdict(list)<\/p>\n<p>    def run(self, variant: str, prompt: str,<br \/>\n            test_cases: list[dict], metrics: list[str] &#061; None):<br \/>\n        &#034;&#034;&#034;<br \/>\n        \u8fd0\u884c\u6d4b\u8bd5<\/p>\n<p>        Args:<br \/>\n            variant: &#034;A&#034; \u6216 &#034;B&#034;<br \/>\n            prompt: Prompt\u6a21\u677f&#xff08;\u542b{input}\u5360\u4f4d\u7b26&#xff09;<br \/>\n            test_cases: [{&#034;input&#034;: &#8230;, &#034;expected&#034;: &#8230;}]<br \/>\n            metrics: \u9700\u8981\u8ba1\u7b97\u7684\u6307\u6807\u5217\u8868<br \/>\n        &#034;&#034;&#034;<br \/>\n        for case in test_cases:<br \/>\n            start &#061; time.time()<br \/>\n            full_prompt &#061; prompt.format(input&#061;case[&#034;input&#034;])<br \/>\n            output &#061; self.model_func(full_prompt)<br \/>\n            elapsed &#061; time.time() &#8211; start<\/p>\n<p>            self.results[variant].append({<br \/>\n                &#034;input&#034;: case[&#034;input&#034;],<br \/>\n                &#034;expected&#034;: case.get(&#034;expected&#034;, &#034;&#034;),<br \/>\n                &#034;output&#034;: output,<br \/>\n                &#034;latency&#034;: elapsed<br \/>\n            })<\/p>\n<p>    def compare(self, metrics: dict &#061; None) -&gt; dict:<br \/>\n        &#034;&#034;&#034;\u5bf9\u6bd4A\/B\u4e24\u7ec4\u7684\u5dee\u5f02&#034;&#034;&#034;<br \/>\n        if metrics is None:<br \/>\n            metrics &#061; {&#034;latency&#034;: lambda r: r[&#034;latency&#034;]}<\/p>\n<p>        comparison &#061; {}<br \/>\n        for metric_name, metric_fn in metrics.items():<br \/>\n            vals_a &#061; [metric_fn(r) for r in self.results[&#034;A&#034;]]<br \/>\n            vals_b &#061; [metric_fn(r) for r in self.results[&#034;B&#034;]]<\/p>\n<p>            comparison[metric_name] &#061; {<br \/>\n                &#034;A_mean&#034;: mean(vals_a),<br \/>\n                &#034;B_mean&#034;: mean(vals_b),<br \/>\n                &#034;A_std&#034;: stdev(vals_a) if len(vals_a) &gt; 1 else 0,<br \/>\n                &#034;B_std&#034;: stdev(vals_b) if len(vals_b) &gt; 1 else 0,<br \/>\n                &#034;delta&#034;: mean(vals_b) &#8211; mean(vals_a),<br \/>\n                &#034;delta_pct&#034;: (mean(vals_b) &#8211; mean(vals_a))<br \/>\n                             \/ mean(vals_a) * 100 if mean(vals_a) !&#061; 0 else 0<br \/>\n            }<\/p>\n<p>        return comparison<\/p>\n<p># &#061;&#061;&#061;&#061;&#061; \u4f7f\u7528\u793a\u4f8b &#061;&#061;&#061;&#061;&#061;<br \/>\ndef mock_model(prompt: str) -&gt; str:<br \/>\n    &#034;&#034;&#034;\u6a21\u62df\u6a21\u578b\u8c03\u7528&#xff08;\u66ff\u6362\u4e3a\u771f\u5b9e\u7684API\u8c03\u7528&#xff09;&#034;&#034;&#034;<br \/>\n    import random<br \/>\n    return f&#034;Mock output for: {prompt[:30]}&#8230; (score: {random.randint(60,100)})&#034;<\/p>\n<p>ab_test &#061; PromptABTest(mock_model)<\/p>\n<p>test_cases &#061; [<br \/>\n    {&#034;input&#034;: &#034;\u8fd9\u4e2a\u4ea7\u54c1\u600e\u4e48\u9000\u6362\u8d27&#xff1f;&#034;, &#034;expected&#034;: &#034;\u5305\u542b\u9000\u6362\u8d27\u6d41\u7a0b&#034;},<br \/>\n    {&#034;input&#034;: &#034;\u7269\u6d41\u5230\u54ea\u91cc\u4e86&#xff1f;&#034;, &#034;expected&#034;: &#034;\u5305\u542b\u7269\u6d41\u67e5\u8be2\u65b9\u5f0f&#034;},<br \/>\n    {&#034;input&#034;: &#034;\u4e0b\u5355\u540e\u591a\u4e45\u53d1\u8d27&#xff1f;&#034;, &#034;expected&#034;: &#034;\u5305\u542b\u53d1\u8d27\u65f6\u95f4\u627f\u8bfa&#034;},<br \/>\n]<\/p>\n<p># \u7248\u672cA&#xff1a;\u7b80\u5355Prompt<br \/>\nab_test.run(&#034;A&#034;, &#034;\u56de\u7b54\u95ee\u9898&#xff1a;{input}&#034;, test_cases)<\/p>\n<p># \u7248\u672cB&#xff1a;\u7ed3\u6784\u5316Prompt<br \/>\nab_test.run(&#034;B&#034;, &#034;&#034;&#034;<br \/>\n\u4f60\u662f\u4e13\u4e1a\u5ba2\u670d\u3002\u8bf7\u6309\u4ee5\u4e0b\u683c\u5f0f\u56de\u7b54&#xff1a;<br \/>\n\u95ee\u9898&#xff1a;{input}<br \/>\n\u7b54\u6848&#xff08;50\u5b57\u4ee5\u5185&#xff09;&#xff1a;<br \/>\n&#034;&#034;&#034;, test_cases)<\/p>\n<p>result &#061; ab_test.compare()<br \/>\nprint(f&#034;A\/B\u6d4b\u8bd5\u7ed3\u679c&#xff1a;\\\\n{json.dumps(result, ensure_ascii&#061;False, indent&#061;2)}&#034;)<\/p>\n<p>\u771f\u6b63\u7684A\/B\u6d4b\u8bd5\u6ca1\u90a3\u4e48\u7b80\u5355\u2014\u2014\u4f60\u9700\u8981\u5b9a\u4e49&#034;\u597d&#034;\u7684\u6807\u51c6\u3002\u7535\u5546\u5ba2\u670d\u573a\u666f\u91cc&#xff0c;\u201c\u597d&#034;\u53ef\u80fd\u662f&#034;\u7528\u6237\u4e0d\u518d\u8ffd\u95ee\u201d&#xff1b;\u4ee3\u7801\u751f\u6210\u573a\u666f\u91cc&#xff0c;\u201c\u597d&#034;\u53ef\u80fd\u662f&#034;\u4e00\u6b21\u8fc7\u7f16\u8bd1\u201d\u3002\u5148\u5b9a\u4e49\u6307\u6807&#xff0c;\u518d\u8dd1\u5b9e\u9a8c&#xff0c;\u5426\u5219\u6570\u636e\u6beb\u65e0\u610f\u4e49\u3002<\/p>\n<hr \/>\n<h3 id=\"%E4%B8%83%E3%80%81%E6%88%90%E6%9C%AC%E4%B8%8E%E8%B4%A8%E9%87%8F%E7%9A%84%E6%9D%83%E8%A1%A1\">\u4e03\u3001\u6210\u672c\u4e0e\u8d28\u91cf\u7684\u6743\u8861<\/h3>\n<p>\u8fd9\u662f\u8001\u677f\u6700\u5173\u5fc3\u4f46\u4f60\u6700\u5bb9\u6613\u5ffd\u7565\u7684\u95ee\u9898\u3002<\/p>\n<p>graph TD<br \/>\n    Q[&#034;\u8f93\u5165\u4efb\u52a1&#034;] &#8211;&gt; C{&#034;\u590d\u6742\u5ea6\u5206\u7c7b\u5668&#034;}<\/p>\n<p>    C &#8211;&gt;|&#034;\u7b80\u5355\u4efb\u52a1&lt;br\/&gt;(\u7ffb\u8bd1\/\u63d0\u53d6\/\u5206\u7c7b)&#034;| S[&#034;Short Prompt&lt;br\/&gt;L1-L2 \u7ea7\u522b&lt;br\/&gt;Token: ~500&#034;]<br \/>\n    C &#8211;&gt;|&#034;\u4e2d\u7b49\u4efb\u52a1&lt;br\/&gt;(\u603b\u7ed3\/\u6539\u5199)&#034;| M[&#034;Medium Prompt&lt;br\/&gt;L2-L3 \u7ea7\u522b&lt;br\/&gt;Token: ~1500&#034;]<br \/>\n    C &#8211;&gt;|&#034;\u590d\u6742\u4efb\u52a1&lt;br\/&gt;(\u63a8\u7406\/\u4ee3\u7801\/\u5206\u6790)&#034;| L[&#034;Long Prompt&lt;br\/&gt;L3-L4 \u7ea7\u522b&lt;br\/&gt;Token: ~4000&#034;]<\/p>\n<p>    S &#8211;&gt; S_C[&#034;\u5355\u6b21\u8c03\u7528&lt;br\/&gt;&#x1f4b0; \u6210\u672c: $0.002&#034;]<br \/>\n    M &#8211;&gt; M_C[&#034;2-3\u6b21\u8c03\u7528&lt;br\/&gt;&#x1f4b0; \u6210\u672c: $0.01&#034;]<br \/>\n    L &#8211;&gt; L_C[&#034;3-5\u6b21\u8c03\u7528&#043;\u8bc4\u5ba1&lt;br\/&gt;&#x1f4b0; \u6210\u672c: $0.05&#034;]<\/p>\n<p>    style S fill:#90EE90<br \/>\n    style M fill:#FFD700<br \/>\n    style L fill:#FF6347<\/p>\n<p>\u6838\u5fc3\u51b3\u7b56\u6846\u67b6\u2014\u2014\u6309\u4efb\u52a1\u4ef7\u503c\u5339\u914dPrompt\u7ea7\u522b&#xff1a;<\/p>\n<p>from enum import Enum<\/p>\n<p>class TaskTier(Enum):<br \/>\n    &#034;&#034;&#034;\u4efb\u52a1\u7ea7\u522b\u2014\u2014\u51b3\u5b9a\u4e86\u4f60\u613f\u610f\u82b1\u591a\u5c11\u94b1&#034;&#034;&#034;<br \/>\n    COST_SENSITIVE &#061; 1   # \u9ad8\u9891\u3001\u4f4e\u4ef7\u503c&#xff08;\u5982\u6279\u91cf\u5206\u7c7b&#xff09;<br \/>\n    STANDARD &#061; 2         # \u5e38\u89c4\u4e1a\u52a1<br \/>\n    QUALITY_CRITICAL &#061; 3 # \u6838\u5fc3\u4e1a\u52a1\u3001\u4e0d\u53ef\u51fa\u9519<\/p>\n<p>class CostQualityOptimizer:<br \/>\n    &#034;&#034;&#034;\u6210\u672c-\u8d28\u91cf\u51b3\u7b56\u5668&#034;&#034;&#034;<\/p>\n<p>    # \u5404\u7ea7\u522b\u7684Prompt\u914d\u7f6e<br \/>\n    TIER_CONFIG &#061; {<br \/>\n        TaskTier.COST_SENSITIVE: {<br \/>\n            &#034;max_tokens&#034;: 500,<br \/>\n            &#034;cot_enabled&#034;: False,<br \/>\n            &#034;self_reflection&#034;: False,<br \/>\n            &#034;model&#034;: &#034;gpt-3.5-turbo&#034;,<br \/>\n            &#034;estimated_cost_per_1k&#034;: 0.001<br \/>\n        },<br \/>\n        TaskTier.STANDARD: {<br \/>\n            &#034;max_tokens&#034;: 1500,<br \/>\n            &#034;cot_enabled&#034;: True,<br \/>\n            &#034;self_reflection&#034;: False,<br \/>\n            &#034;model&#034;: &#034;gpt-4o-mini&#034;,<br \/>\n            &#034;estimated_cost_per_1k&#034;: 0.003<br \/>\n        },<br \/>\n        TaskTier.QUALITY_CRITICAL: {<br \/>\n            &#034;max_tokens&#034;: 4000,<br \/>\n            &#034;cot_enabled&#034;: True,<br \/>\n            &#034;self_reflection&#034;: True,<br \/>\n            &#034;model&#034;: &#034;gpt-4o&#034;,<br \/>\n            &#034;estimated_cost_per_1k&#034;: 0.03<br \/>\n        }<br \/>\n    }<\/p>\n<p>    &#064;classmethod<br \/>\n    def optimize(cls, task: str, tier: TaskTier,<br \/>\n                 expected_calls_per_day: int &#061; 1000) -&gt; dict:<br \/>\n        &#034;&#034;&#034;<br \/>\n        \u6839\u636e\u4efb\u52a1\u7ea7\u522b\u9009\u62e9\u6700\u4f18Prompt\u7b56\u7565<\/p>\n<p>        Returns:<br \/>\n            {<br \/>\n                &#034;strategy&#034;: Prompt\u7b56\u7565\u8bf4\u660e,<br \/>\n                &#034;estimated_daily_cost&#034;: \u9884\u4f30\u65e5\u6210\u672c,<br \/>\n                &#034;prompt_template&#034;: \u63a8\u8350\u7684Prompt\u6a21\u677f<br \/>\n            }<br \/>\n        &#034;&#034;&#034;<br \/>\n        config &#061; cls.TIER_CONFIG[tier]<br \/>\n        tokens_per_call &#061; config[&#034;max_tokens&#034;]<br \/>\n        cost_per_call &#061; (tokens_per_call \/ 1000) * config[&#034;estimated_cost_per_1k&#034;]<\/p>\n<p>        # \u81ea\u53cd\u601d\u989d\u5916\u6210\u672c<br \/>\n        if config[&#034;self_reflection&#034;]:<br \/>\n            cost_per_call *&#061; 3  # \u751f\u6210&#043;\u8bc4\u5ba1&#043;\u4fee\u6b63<\/p>\n<p>        daily_cost &#061; cost_per_call * expected_calls_per_day<\/p>\n<p>        return {<br \/>\n            &#034;tier&#034;: tier.name,<br \/>\n            &#034;model&#034;: config[&#034;model&#034;],<br \/>\n            &#034;cot&#034;: config[&#034;cot_enabled&#034;],<br \/>\n            &#034;self_reflection&#034;: config[&#034;self_reflection&#034;],<br \/>\n            &#034;max_tokens_per_call&#034;: tokens_per_call,<br \/>\n            &#034;cost_per_call&#034;: round(cost_per_call, 5),<br \/>\n            &#034;estimated_daily_cost&#034;: round(daily_cost, 2),<br \/>\n            &#034;estimated_monthly_cost&#034;: round(daily_cost * 30, 2),<br \/>\n            &#034;strategy&#034;: cls._build_strategy_text(config)<br \/>\n        }<\/p>\n<p>    &#064;classmethod<br \/>\n    def _build_strategy_text(cls, config: dict) -&gt; str:<br \/>\n        parts &#061; []<br \/>\n        parts.append(f&#034;\u6a21\u578b: {config[&#039;model&#039;]}&#034;)<br \/>\n        parts.append(<br \/>\n            &#034;CoT: &#034; &#043; (&#034;\u542f\u7528&#034; if config[&#039;cot_enabled&#039;] else &#034;\u7981\u7528&#034;))<br \/>\n        parts.append(<br \/>\n            &#034;\u81ea\u53cd\u601d: &#034; &#043; (&#034;\u542f\u7528&#034; if config[&#039;self_reflection&#039;] else &#034;\u7981\u7528&#034;))<br \/>\n        return &#034; | &#034;.join(parts)<\/p>\n<p># &#061;&#061;&#061;&#061;&#061; \u5b9e\u9645\u51b3\u7b56\u793a\u4f8b &#061;&#061;&#061;&#061;&#061;<br \/>\n# \u573a\u666f&#xff1a;\u6bcf\u65e510\u4e07\u6761\u5546\u54c1\u8bc4\u8bba\u60c5\u611f\u5206\u7c7b<br \/>\nresult &#061; CostQualityOptimizer.optimize(<br \/>\n    task&#061;&#034;\u5546\u54c1\u8bc4\u8bba\u60c5\u611f\u5206\u7c7b&#034;,<br \/>\n    tier&#061;TaskTier.COST_SENSITIVE,<br \/>\n    expected_calls_per_day&#061;100000<br \/>\n)<br \/>\nprint(f&#034;&#034;&#034;<br \/>\n\u6210\u672c\u5206\u6790&#xff1a;<br \/>\n&#8211; \u7b56\u7565&#xff1a;{result[&#039;strategy&#039;]}<br \/>\n&#8211; \u5355\u6b21\u8c03\u7528\u6210\u672c&#xff1a;${result[&#039;cost_per_call&#039;]}<br \/>\n&#8211; \u9884\u4f30\u65e5\u6210\u672c&#xff1a;${result[&#039;estimated_daily_cost&#039;]}<br \/>\n&#8211; \u9884\u4f30\u6708\u6210\u672c&#xff1a;${result[&#039;estimated_monthly_cost&#039;]}<\/p>\n<p>&#x1f4a1; \u5efa\u8bae&#xff1a;10\u4e07\u6761\/\u5929\u7684\u6279\u91cf\u5206\u7c7b&#xff0c;\u7528GPT-3.5-turbo &#043; L1\u7ea7\u522bPrompt\u5c31\u591f\u4e86\u3002<br \/>\n\u5982\u679c\u6362\u6210GPT-4o &#043; \u5b8c\u6574CoT &#043; \u81ea\u53cd\u601d&#xff0c;\u6708\u6210\u672c\u4ece$3,000\u98d9\u5347\u5230$90,000\u3002<br \/>\n\u8d28\u91cf\u63d0\u53475%&#xff0c;\u6210\u672c\u589e\u52a030\u500d\u2014\u2014\u503c\u4e0d\u503c&#xff1f;\u4f60\u81ea\u5df1\u5224\u65ad\u3002<br \/>\n&#034;&#034;&#034;)<\/p>\n<hr \/>\n<h3 id=\"%E5%86%99%E5%9C%A8%E6%9C%80%E5%90%8E\">\u5199\u5728\u6700\u540e<\/h3>\n<p>\u56de\u987e\u4e00\u4e0b&#xff0c;\u6211\u4eec\u4ece&#034;\u628a\u8bdd\u8bf4\u6e05\u695a&#034;\u8d70\u5230&#034;\u8ba9AI\u81ea\u5df1\u5ba1\u81ea\u5df1&#034;&#xff0c;\u8fd9\u662f\u6211\u4ece\u51e0\u5341\u4e2a\u9879\u76ee\u91cc\u8e29\u5751\u8e29\u51fa\u6765\u7684\u4f53\u7cfb\u3002\u4f46\u8fd9\u5957\u4f53\u7cfb\u6700\u597d\u7684\u5b66\u4e60\u65b9\u5f0f\u4e0d\u662f\u8bfb\u5b8c\u8fd9\u7bc7\u6587\u7ae0\u2014\u2014\u800c\u662f\u6253\u5f00Colab&#xff0c;\u62ff\u4e00\u4e2a\u4f60\u5de5\u4f5c\u4e2d\u7684\u771f\u5b9e\u4efb\u52a1&#xff0c;\u4eceL1\u5f00\u59cb\u4e00\u5c42\u4e00\u5c42\u5f80\u4e0a\u52a0&#xff0c;\u5bf9\u6bd4\u6bcf\u4e00\u5c42\u7684\u8f93\u51fa\u8d28\u91cf\u53d8\u5316\u3002<\/p>\n<p>\u4f60\u4eb2\u773c\u770b\u5230\u7684\u53d8\u5316&#xff0c;\u6bd4\u8bfb\u5341\u7bc7\u6587\u7ae0\u90fd\u6df1\u523b\u3002<\/p>\n<hr \/>\n<h3 id=\"%E5%A3%B0%E6%98%8E\">\u58f0\u660e<\/h3>\n<p>AI\u4e13\u4e1a\u4ea4\u6d41&#xff0c;\u4fe1\u606f\u5171\u4eab&#xff0c;\u4e0d\u6784\u6210\u6295\u8d44\u5efa\u8bae\u3002\u6587\u4e2d\u4ee3\u7801\u5747\u4e3a\u793a\u4f8b&#xff0c;\u4f7f\u7528\u524d\u8bf7\u5145\u5206\u6d4b\u8bd5\u3002 \u7b14\u8005\u4e0e\u6587\u4e2d\u63d0\u5230\u7684OpenAI\u3001Anthropic\u7b49\u516c\u53f8\u65e0\u5229\u76ca\u5173\u7cfb\u3002<\/p>\n<hr \/>\n<h3 id=\"%E7%A6%8F%E5%88%A9%E6%97%B6%E9%97%B4\">\u798f\u5229\u65f6\u95f4<\/h3>\n<p>\u5173\u6ce8\u6211&#xff0c;\u540e\u53f0\u56de\u590d \u201cPrompt\u201d&#xff0c;\u514d\u8d39\u83b7\u53d6&#xff1a;<\/p>\n<ul>\n<li>\u672c\u6587\u5168\u90e8\u4ee3\u7801\u7684\u5b8c\u6574Python\u6587\u4ef6<\/li>\n<li>50&#043;\u5e38\u7528Prompt\u6a21\u677f&#xff08;\u4e2d\u82f1\u6587&#xff09;<\/li>\n<li>Prompt\u7248\u672c\u7ba1\u7406\u5de5\u5177\u4e00\u952e\u90e8\u7f72\u811a\u672c<\/li>\n<\/ul>\n<hr \/>\n<h3 id=\"%E7%B3%BB%E5%88%97%E9%A2%84%E5%91%8A\">\u7cfb\u5217\u9884\u544a<\/h3>\n<p>\u4e0b\u4e00\u7bc7&#xff1a;\u300aAI\u9879\u76ee\u8bc4\u4f30\u2014\u2014\u4ece\u51c6\u786e\u7387\u5230\u7528\u6237\u6ee1\u610f\u5ea6\u7684\u591a\u7ef4\u5ea6\u5ea6\u91cf\u300b<\/p>\n<p>\u522b\u518d\u7528&#034;\u51c6\u786e\u7387&#034;\u7cca\u5f04\u8001\u677f\u4e86\u3002\u4f60\u4f1a\u53d1\u73b0&#xff1a;<\/p>\n<ul>\n<li>\u51c6\u786e\u738798%\u7684\u6a21\u578b&#xff0c;\u7528\u6237\u4f53\u9a8c\u53cd\u800c\u6bd495%\u7684\u66f4\u5dee&#xff1f;&#xff08;\u56e0\u4e3a\u8fc7\u5ea6\u4fdd\u5b88&#xff09;<\/li>\n<li>ROUGE\/BLEU\u8fd9\u4e9b&#034;\u7ecf\u5178&#034;\u6307\u6807&#xff0c;\u5728LLM\u65f6\u4ee3\u5df2\u7ecf\u8fc7\u65f6\u4e86<\/li>\n<li>\u5982\u4f55\u7528LLM-as-Judge\u81ea\u52a8\u8bc4\u4f30\u8f93\u51fa\u8d28\u91cf&#xff1f;\u6bd4\u4eba\u5de5\u6807\u6ce8\u4fbf\u5b9c100\u500d<\/li>\n<li>\u4e0a\u7ebf\u540e\u76d1\u63a7&#xff1a;\u522b\u7b49\u7528\u6237\u6295\u8bc9\u624d\u77e5\u9053\u6a21\u578b\u53d8\u5dee\u4e86<\/li>\n<\/ul>\n<p>\u4e0b\u4e00\u7bc7\u89c1\u3002<\/p>\n<hr \/>\n<p>\u6807\u7b7e&#xff1a; Prompt Engineering\u3001LLM\u3001\u601d\u7ef4\u94fe\u3001Few-shot\u3001\u6a21\u677f\u8bbe\u8ba1\u3001AI\u5f00\u53d1\u3001GPT<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u5f55<br \/>\n\u4e00\u3001Prompt Engineering\u56db\u5c42\u4f53\u7cfb<br \/>\n\u7b2c\u4e00\u5c42&#xff1a;\u660e\u786e\u6307\u4ee4\u2014\u2014\u628a\u8bdd\u8bf4\u6e05\u695a<br \/>\n\u7b2c\u4e8c\u5c42&#xff1a;\u63d0\u4f9b\u4e0a\u4e0b\u6587\u2014\u2014\u7ed9AI\u5b89\u88c5\\&#8221;\u8bb0\u5fc6\u82af\u7247\\&#8221;<br \/>\n\u7b2c\u4e09\u5c42&#xff1a;\u601d\u7ef4\u94fe(CoT)\u2014\u2014\u6559AI\u4e00\u6b65\u4e00\u6b65\u60f3<br \/>\n\u7b2c\u56db\u5c42&#xff1a;\u81ea\u6211\u53cd\u601d\u8f93\u51fa\u6821\u9a8c\u2014\u2014\u8ba9AI\u81ea\u5df1\u627e\u9519\u8bef<br \/>\n\u4e8c\u3001Prompt\u6a21\u677f\u4f53\u7cfb\u8bbe\u8ba1<br \/>\n\u4e09\u3001\u7ed3\u6784\u5316\u8f93\u51fa\u63a7\u5236<br \/>\n\u56db\u3001Few-shot\u793a\u4f8b\u9009\u62e9\u7b56\u7565<br \/>\n\u4e94\u3001Prompt\u7248\u672c\u7ba1\u7406<br \/>\n\u516d\u3001A\/B\u6d4b\u8bd5&#xff1a;Prompt\u7684\\&#8221;\u7070\u5ea6\u53d1\u5e03\\&#8221;<br \/>\n\u4e03\u3001\u6210\u672c<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[8158,10369,75,2946,50],"topic":[],"class_list":["post-90972","post","type-post","status-publish","format-standard","hentry","category-server","tag-ai","tag-10369","tag-llm","tag-prompt","tag-50"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>AI\u9879\u76ee\u4ece\u5165\u95e8\u5230\u4e0a\u7ebf28-\u540c\u6837\u7528GPT\u4e3a\u4ec0\u4e48\u522b\u4eba\u6bd4\u6211\u5199\u5f97\u597d\uff1fPrompt Engineering\u7cfb\u7edf\u65b9\u6cd5\u8bba - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/90972.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AI\u9879\u76ee\u4ece\u5165\u95e8\u5230\u4e0a\u7ebf28-\u540c\u6837\u7528GPT\u4e3a\u4ec0\u4e48\u522b\u4eba\u6bd4\u6211\u5199\u5f97\u597d\uff1fPrompt Engineering\u7cfb\u7edf\u65b9\u6cd5\u8bba - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u76ee\u5f55 \u4e00\u3001Prompt Engineering\u56db\u5c42\u4f53\u7cfb \u7b2c\u4e00\u5c42&#xff1a;\u660e\u786e\u6307\u4ee4\u2014\u2014\u628a\u8bdd\u8bf4\u6e05\u695a \u7b2c\u4e8c\u5c42&#xff1a;\u63d0\u4f9b\u4e0a\u4e0b\u6587\u2014\u2014\u7ed9AI\u5b89\u88c5&quot;\u8bb0\u5fc6\u82af\u7247&quot; \u7b2c\u4e09\u5c42&#xff1a;\u601d\u7ef4\u94fe(CoT)\u2014\u2014\u6559AI\u4e00\u6b65\u4e00\u6b65\u60f3 \u7b2c\u56db\u5c42&#xff1a;\u81ea\u6211\u53cd\u601d\u8f93\u51fa\u6821\u9a8c\u2014\u2014\u8ba9AI\u81ea\u5df1\u627e\u9519\u8bef \u4e8c\u3001Prompt\u6a21\u677f\u4f53\u7cfb\u8bbe\u8ba1 \u4e09\u3001\u7ed3\u6784\u5316\u8f93\u51fa\u63a7\u5236 \u56db\u3001Few-shot\u793a\u4f8b\u9009\u62e9\u7b56\u7565 \u4e94\u3001Prompt\u7248\u672c\u7ba1\u7406 \u516d\u3001A\/B\u6d4b\u8bd5&#xff1a;Prompt\u7684&quot;\u7070\u5ea6\u53d1\u5e03&quot; \u4e03\u3001\u6210\u672c\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/90972.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-06T05:32:48+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/90972.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/90972.html\",\"name\":\"AI\u9879\u76ee\u4ece\u5165\u95e8\u5230\u4e0a\u7ebf28-\u540c\u6837\u7528GPT\u4e3a\u4ec0\u4e48\u522b\u4eba\u6bd4\u6211\u5199\u5f97\u597d\uff1fPrompt Engineering\u7cfb\u7edf\u65b9\u6cd5\u8bba - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-06T05:32:48+00:00\",\"dateModified\":\"2026-08-06T05:32:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/90972.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/90972.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/90972.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"AI\u9879\u76ee\u4ece\u5165\u95e8\u5230\u4e0a\u7ebf28-\u540c\u6837\u7528GPT\u4e3a\u4ec0\u4e48\u522b\u4eba\u6bd4\u6211\u5199\u5f97\u597d\uff1fPrompt Engineering\u7cfb\u7edf\u65b9\u6cd5\u8bba\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"AI\u9879\u76ee\u4ece\u5165\u95e8\u5230\u4e0a\u7ebf28-\u540c\u6837\u7528GPT\u4e3a\u4ec0\u4e48\u522b\u4eba\u6bd4\u6211\u5199\u5f97\u597d\uff1fPrompt Engineering\u7cfb\u7edf\u65b9\u6cd5\u8bba - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/90972.html","og_locale":"zh_CN","og_type":"article","og_title":"AI\u9879\u76ee\u4ece\u5165\u95e8\u5230\u4e0a\u7ebf28-\u540c\u6837\u7528GPT\u4e3a\u4ec0\u4e48\u522b\u4eba\u6bd4\u6211\u5199\u5f97\u597d\uff1fPrompt Engineering\u7cfb\u7edf\u65b9\u6cd5\u8bba - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u76ee\u5f55 \u4e00\u3001Prompt Engineering\u56db\u5c42\u4f53\u7cfb \u7b2c\u4e00\u5c42&#xff1a;\u660e\u786e\u6307\u4ee4\u2014\u2014\u628a\u8bdd\u8bf4\u6e05\u695a \u7b2c\u4e8c\u5c42&#xff1a;\u63d0\u4f9b\u4e0a\u4e0b\u6587\u2014\u2014\u7ed9AI\u5b89\u88c5\"\u8bb0\u5fc6\u82af\u7247\" \u7b2c\u4e09\u5c42&#xff1a;\u601d\u7ef4\u94fe(CoT)\u2014\u2014\u6559AI\u4e00\u6b65\u4e00\u6b65\u60f3 \u7b2c\u56db\u5c42&#xff1a;\u81ea\u6211\u53cd\u601d\u8f93\u51fa\u6821\u9a8c\u2014\u2014\u8ba9AI\u81ea\u5df1\u627e\u9519\u8bef \u4e8c\u3001Prompt\u6a21\u677f\u4f53\u7cfb\u8bbe\u8ba1 \u4e09\u3001\u7ed3\u6784\u5316\u8f93\u51fa\u63a7\u5236 \u56db\u3001Few-shot\u793a\u4f8b\u9009\u62e9\u7b56\u7565 \u4e94\u3001Prompt\u7248\u672c\u7ba1\u7406 \u516d\u3001A\/B\u6d4b\u8bd5&#xff1a;Prompt\u7684\"\u7070\u5ea6\u53d1\u5e03\" \u4e03\u3001\u6210\u672c","og_url":"https:\/\/www.wsisp.com\/helps\/90972.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-06T05:32:48+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"15 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/90972.html","url":"https:\/\/www.wsisp.com\/helps\/90972.html","name":"AI\u9879\u76ee\u4ece\u5165\u95e8\u5230\u4e0a\u7ebf28-\u540c\u6837\u7528GPT\u4e3a\u4ec0\u4e48\u522b\u4eba\u6bd4\u6211\u5199\u5f97\u597d\uff1fPrompt Engineering\u7cfb\u7edf\u65b9\u6cd5\u8bba - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-06T05:32:48+00:00","dateModified":"2026-08-06T05:32:48+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/90972.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/90972.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/90972.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"AI\u9879\u76ee\u4ece\u5165\u95e8\u5230\u4e0a\u7ebf28-\u540c\u6837\u7528GPT\u4e3a\u4ec0\u4e48\u522b\u4eba\u6bd4\u6211\u5199\u5f97\u597d\uff1fPrompt Engineering\u7cfb\u7edf\u65b9\u6cd5\u8bba"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/90972","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=90972"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/90972\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=90972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=90972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=90972"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=90972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}