{"id":1504,"date":"2025-02-03T20:28:32","date_gmt":"2025-02-03T12:28:32","guid":{"rendered":"https:\/\/crab.cool\/?p=1504"},"modified":"2025-04-13T21:37:57","modified_gmt":"2025-04-13T13:37:57","slug":"ds%e6%8f%90%e4%be%9b%e7%9a%84%e6%90%ad%e5%bb%ba%e6%9c%ac%e5%9c%b0%e7%9f%a5%e8%af%86%e5%ba%93%e7%9a%84%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/crab.cool\/index.php\/2025\/02\/03\/ds%e6%8f%90%e4%be%9b%e7%9a%84%e6%90%ad%e5%bb%ba%e6%9c%ac%e5%9c%b0%e7%9f%a5%e8%af%86%e5%ba%93%e7%9a%84%e6%96%b9%e6%b3%95\/","title":{"rendered":"DS\u63d0\u4f9b\u7684\u642d\u5efa\u672c\u5730\u77e5\u8bc6\u5e93\u7684\u65b9\u6cd5"},"content":{"rendered":"<h3>1. \u77e5\u8bc6\u5e93\u7684\u63a5\u5165\u65b9\u5f0f<\/h3>\n<p>\u8981\u4f7f\u4f60\u80fd\u591f\u8bbf\u95ee\u672c\u5730\u77e5\u8bc6\u5e93\uff0c\u901a\u5e38\u9700\u8981\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<ul>\n<li>API\u63a5\u53e3\uff1a\u4f60\u53ef\u4ee5\u901a\u8fc7\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684HTTP\u670d\u52a1\u5668\uff08\u4f8b\u5982\u4f7f\u7528Python\u7684Flask\u6846\u67b6\uff09\u6765\u63d0\u4f9b\u5bf9\u77e5\u8bc6\u5e93\u7684\u8bbf\u95ee\u3002<\/li>\n<li>\u6587\u4ef6\u7cfb\u7edf\u76f4\u63a5\u8bfb\u53d6\uff1a\u5982\u679c\u77e5\u8bc6\u5e93\u662f\u4e00\u4e2a\u7ed3\u6784\u5316\u7684\u6587\u4ef6\uff08\u5982JSON\u6216CSV\uff09\uff0c\u6211\u53ef\u4ee5\u76f4\u63a5\u4ece\u6587\u4ef6\u7cfb\u7edf\u4e2d\u8bfb\u53d6\u8fd9\u4e9b\u6570\u636e\u3002<\/li>\n<\/ul>\n<h3>2. \u77e5\u8bc6\u5e93\u683c\u5f0f<\/h3>\n<p>\u4ee5\u4e0b\u662f\u51e0\u79cd\u5e38\u89c1\u7684\u77e5\u8bc6\u5e93\u683c\u5f0f\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u9002\u5408\u81ea\u5df1\u7684\uff1a<\/p>\n<ul>\n<li>JSON: \u6613\u4e8e\u89e3\u6790\u548c\u5b58\u50a8\u590d\u6742\u7684\u6570\u636e\u7ed3\u6784\u3002<\/li>\n<li>Markdown: \u9002\u7528\u4e8e\u6587\u6863\u578b\u7684\u77e5\u8bc6\u5e93\uff0c\u6bcf\u4e2a\u6587\u4ef6\u4ee3\u8868\u4e00\u4e2a\u72ec\u7acb\u7684\u201c\u77e5\u8bc6\u70b9\u201d\u6216\u4e3b\u9898\u3002<\/li>\n<li>CSV: \u9002\u7528\u4e8e\u7b80\u5355\u7684\u6570\u636e\u8868\u683c\u3002<\/li>\n<\/ul>\n<h3>3. \u793a\u4f8b\uff1a\u4f7f\u7528\u672c\u5730\u77e5\u8bc6\u5e93\u6269\u5c55\u4f60\u7684\u77e5\u8bc6<\/h3>\n<p>\u5047\u8bbe\u4f60\u6709\u4e00\u4e2a\u540d\u4e3alocal_knowledge_base.json\u7684JSON\u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<p>{<br \/>\n&quot;knowledge&quot;: [<br \/>\n{<br \/>\n&quot;topic&quot;: &quot;\u79d1\u6280\u65b0\u95fb&quot;,<br \/>\n&quot;content&quot;: &quot;2024\u5e741\u6708\uff0c\u67d0\u516c\u53f8\u53d1\u5e03\u4e86\u65b0\u4e00\u4ee3AI\u6a21\u578b\u3002&quot;<br \/>\n},<br \/>\n{<br \/>\n&quot;topic&quot;: &quot;\u7ecf\u6d4e\u52a8\u6001&quot;,<br \/>\n&quot;content&quot;: &quot;2024\u5e74\u7b2c\u4e00\u5b63\u5ea6\uff0c\u5168\u7403\u7ecf\u6d4e\u5448\u73b0\u590d\u82cf\u8ff9\u8c61\u3002&quot;<br \/>\n}<br \/>\n]<br \/>\n}<\/p>\n<h3>4. \u5b9e\u73b0\u6b65\u9aa4<\/h3>\n<p>\u4ee5\u4e0b\u662f\u5982\u4f55\u5728\u4ee3\u7801\u4e2d\u96c6\u6210\u672c\u5730\u77e5\u8bc6\u5e93\u7684\u793a\u4f8b\uff1a<\/p>\n<p>a. \u5b89\u88c5\u5fc5\u8981\u7684\u5e93<br \/>\nFlask: \u7528\u4e8e\u521b\u5efa\u7b80\u5355\u7684HTTP\u670d\u52a1\u5668\u3002<br \/>\npip install flask<br \/>\nb. \u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684API<br \/>\nfrom flask import Flask, jsonify<br \/>\nimport json<\/p>\n<p>app = Flask(name)<\/p>\n<p>\u52a0\u8f7d\u672c\u5730\u77e5\u8bc6\u5e93<br \/>\nwith open('local_knowledge_base.json', 'r') as f:<br \/>\nknowledge_base = json.load(f)<\/p>\n<p>@app.route('\/query')<br \/>\ndef query():<br \/>\nreturn jsonify(knowledge_base)<\/p>\n<p>c. \u542f\u52a8\u670d\u52a1\u5668<br \/>\npython server.py<\/p>\n<p>d. \u5728\u4f60\u7684\u4ee3\u7801\u4e2d\u8c03\u7528API<br \/>\n\u5047\u8bbe\u4f60\u5df2\u7ecf\u542f\u52a8\u4e86Flask\u670d\u52a1\u5668\uff0c\u4f60\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u8fdb\u884c\u5982\u4e0b\u64cd\u4f5c\uff1a<\/p>\n<p>import requests<\/p>\n<p>response = requests.get('<a href=\"http:\/\/localhost:5000\/query\">http:\/\/localhost:5000\/query<\/a>')<br \/>\nknowledge = response.json()<\/p>\n<p>\u5904\u7406 knowledge \u6570\u636e<\/p>\n<h3>5. \u6ce8\u610f\u4e8b\u9879<\/h3>\n<ul>\n<li>\u6027\u80fd\u4f18\u5316\uff1a\u5982\u679c\u4f60\u7684\u77e5\u8bc6\u5e93\u975e\u5e38\u5927\uff0c\u53ef\u80fd\u9700\u8981\u8003\u8651\u5206\u7247\u6216\u5176\u4ed6\u9ad8\u6548\u7684\u6570\u636e\u68c0\u7d22\u65b9\u6cd5\u3002<\/li>\n<li>\u6570\u636e\u66f4\u65b0\uff1a\u5b9a\u671f\u540c\u6b65\u77e5\u8bc6\u5e93\u5185\u5bb9\u5230\u672c\u5730\u4ed3\u5e93\uff0c\u786e\u4fdd\u4fe1\u606f\u7684\u6700\u65b0\u6027\u3002<\/li>\n<li>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u4f60\u53ef\u4ee5\u6269\u5c55\u6211\u7684\u77e5\u8bc6\u8303\u56f4\uff0c\u4f7f\u5176\u4e0d\u518d\u5c40\u9650\u4e8e\u73b0\u6709\u7684\u8bad\u7ec3\u6570\u636e\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>1. \u77e5\u8bc6\u5e93\u7684\u63a5\u5165\u65b9\u5f0f \u8981\u4f7f\u4f60\u80fd\u591f\u8bbf\u95ee\u672c\u5730\u77e5\u8bc6\u5e93\uff0c\u901a\u5e38\u9700\u8981\u4ee5\u4e0b\u6b65\u9aa4\uff1a API\u63a5\u53e3\uff1a\u4f60\u53ef\u4ee5\u901a\u8fc7\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684HT &hellip; <a href=\"https:\/\/crab.cool\/index.php\/2025\/02\/03\/ds%e6%8f%90%e4%be%9b%e7%9a%84%e6%90%ad%e5%bb%ba%e6%9c%ac%e5%9c%b0%e7%9f%a5%e8%af%86%e5%ba%93%e7%9a%84%e6%96%b9%e6%b3%95\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">DS\u63d0\u4f9b\u7684\u642d\u5efa\u672c\u5730\u77e5\u8bc6\u5e93\u7684\u65b9\u6cd5<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[75,48],"class_list":["post-1504","post","type-post","status-publish","format-standard","hentry","category-world","tag-deepseek","tag-48"],"_links":{"self":[{"href":"https:\/\/crab.cool\/index.php\/wp-json\/wp\/v2\/posts\/1504","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/crab.cool\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/crab.cool\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/crab.cool\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/crab.cool\/index.php\/wp-json\/wp\/v2\/comments?post=1504"}],"version-history":[{"count":2,"href":"https:\/\/crab.cool\/index.php\/wp-json\/wp\/v2\/posts\/1504\/revisions"}],"predecessor-version":[{"id":1567,"href":"https:\/\/crab.cool\/index.php\/wp-json\/wp\/v2\/posts\/1504\/revisions\/1567"}],"wp:attachment":[{"href":"https:\/\/crab.cool\/index.php\/wp-json\/wp\/v2\/media?parent=1504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/crab.cool\/index.php\/wp-json\/wp\/v2\/categories?post=1504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/crab.cool\/index.php\/wp-json\/wp\/v2\/tags?post=1504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}