{"id":21978,"date":"2024-09-04T13:55:55","date_gmt":"2024-09-04T05:55:55","guid":{"rendered":"https:\/\/aif.amtbbs.org\/?p=21978"},"modified":"2024-09-04T13:55:55","modified_gmt":"2024-09-04T05:55:55","slug":"%e8%b6%85%e8%b6%8a%e9%9d%99%e6%80%81%e7%ae%a1%e9%81%93%ef%bc%9a%e4%bd%bf%e7%94%a8llamaindex%e5%a2%9e%e5%bc%ba%e4%ba%ba%e5%b7%a5%e6%99%ba%e8%83%bd%e4%bb%a3%e7%90%86","status":"publish","type":"post","link":"https:\/\/aif.amtbbs.org\/index.php\/2024\/09\/04\/21978\/","title":{"rendered":"\u8d85\u8d8a\u9759\u6001\u7ba1\u9053\uff1a\u4f7f\u7528LlamaIndex\u589e\u5f3a\u4eba\u5de5\u667a\u80fd\u4ee3\u7406"},"content":{"rendered":"<p style=\"font-weight: 400;\">\u672c\u6587\u4f7f\u7528LlamaIndex\u7684\u67e5\u8be2\u5f15\u64ce\u5de5\u5177\u548c\u51fd\u6570\u5de5\u5177\u6784\u5efa\u4eba\u5de5\u667a\u80fd\u4ee3\u7406\uff0c\u5e76\u6f14\u793a\u5982\u4f55\u6709\u6548\u5730\u96c6\u6210\u548c\u5229\u7528\u8fd9\u4e9b\u5de5\u5177\u3002<\/p>\n<p><img data-dominant-color=\"396696\" data-has-transparency=\"false\" style=\"--dominant-color: #396696;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent alignnone size-full wp-image-21980\" src=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/09\/a4ad82636615c4191c69011370d6f488ca5f9d-1-300x157-1.png\" width=\"300\" height=\"157\" alt=\"\" srcset=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/09\/a4ad82636615c4191c69011370d6f488ca5f9d-1-300x157-1.png 300w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/09\/a4ad82636615c4191c69011370d6f488ca5f9d-1-300x157-1-150x79.png 150w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>\u57fa\u672c\u7684\u68c0\u7d22\u589e\u5f3a\u751f\u6210(RAG)\u6570\u636e\u7ba1\u9053\u901a\u5e38\u4f9d\u8d56\u4e8e\u786c\u7f16\u7801\u7684\u6b65\u9aa4\uff0c\u6bcf\u6b21\u8fd0\u884c\u65f6\u90fd\u9075\u5faa\u9884\u5b9a\u4e49\u7684\u8def\u5f84\u3002\u8fd9\u4e9b\u7cfb\u7edf\u6ca1\u6709\u5b9e\u65f6\u51b3\u7b56\uff0c\u4e5f\u4e0d\u4f1a\u6839\u636e\u8f93\u5165\u6570\u636e\u52a8\u6001\u8c03\u6574\u52a8\u4f5c\u3002\u8fd9\u79cd\u9650\u5236\u4f1a\u964d\u4f4e\u5728\u590d\u6742\u6216\u4e0d\u65ad\u53d8\u5316\u7684\u73af\u5883\u4e2d\u7684\u7075\u6d3b\u6027\u548c\u54cd\u5e94\u6027\uff0c\u51f8\u663e\u4e86\u4f20\u7edfRAG\u7cfb\u7edf\u7684\u4e00\u4e2a\u4e3b\u8981\u5f31\u70b9\u3002<\/p>\n<p>LlamaIndex\u901a\u8fc7\u5f15\u5165\u4ee3\u7406\u89e3\u51b3\u4e86\u8fd9\u4e2a\u9650\u5236\u3002\u4ee3\u7406\u8d85\u8d8a\u4e86\u67e5\u8be2\u5f15\u64ce\uff0c\u56e0\u4e3a\u5b83\u4eec\u4e0d\u4ec5\u53ef\u4ee5\u4ece\u9759\u6001\u6570\u636e\u6e90\u201c\u8bfb\u53d6\u201d\u6570\u636e\uff0c\u8fd8\u53ef\u4ee5\u52a8\u6001\u5730\u6444\u53d6\u548c\u4fee\u6539\u6765\u81ea\u5404\u79cd\u5de5\u5177\u7684\u6570\u636e\u3002\u8fd9\u4e9b\u4ee3\u7406\u7531LLM\u63d0\u4f9b\u652f\u6301\uff0c\u901a\u8fc7\u4ece\u63d0\u4f9b\u7684\u5de5\u5177\u96c6\u4e2d\u9009\u62e9\u6700\u5408\u9002\u7684\u5de5\u5177\u6765\u6267\u884c\u4e00\u7cfb\u5217\u64cd\u4f5c\uff0c\u4ee5\u5b8c\u6210\u6307\u5b9a\u7684\u4efb\u52a1\u3002\u8fd9\u4e9b\u5de5\u5177\u53ef\u4ee5\u50cf\u57fa\u672c\u529f\u80fd\u4e00\u6837\u7b80\u5355\uff0c\u4e5f\u53ef\u4ee5\u50cf\u5168\u9762\u7684LlamaIndex\u67e5\u8be2\u5f15\u64ce\u4e00\u6837\u590d\u6742\u3002\u4ed6\u4eec\u5904\u7406\u7528\u6237\u8f93\u5165\u6216\u67e5\u8be2\uff0c\u5c31\u5982\u4f55\u5904\u7406\u8fd9\u4e9b\u8f93\u5165\u505a\u51fa\u5185\u90e8\u51b3\u7b56\uff0c\u5e76\u51b3\u5b9a\u662f\u5426\u9700\u8981\u989d\u5916\u7684\u6b65\u9aa4\uff0c\u6216\u8005\u662f\u5426\u53ef\u4ee5\u4ea4\u4ed8\u6700\u7ec8\u7ed3\u679c\u3002\u8fd9\u79cd\u6267\u884c\u81ea\u52a8\u63a8\u7406\u548c\u51b3\u7b56\u7684\u80fd\u529b\u4f7f\u4ee3\u7406\u5bf9\u590d\u6742\u7684\u6570\u636e\u5904\u7406\u4efb\u52a1\u5177\u6709\u9ad8\u5ea6\u7684\u9002\u5e94\u6027\u548c\u9ad8\u6548\u6027\u3002<\/p>\n<p>\u8be5\u56fe\u8bf4\u660e\u4e86LlamaIndex\u4ee3\u7406\u7684\u5de5\u4f5c\u6d41\u7a0b\uff1a\u5b83\u4eec\u5982\u4f55\u751f\u6210\u6b65\u9aa4\u3001\u505a\u51fa\u51b3\u7b56\u3001\u9009\u62e9\u5de5\u5177\u548c\u8bc4\u4f30\u8fdb\u5ea6\uff0c\u4ece\u800c\u6839\u636e\u7528\u6237\u8f93\u5165\u52a8\u6001\u5730\u5b8c\u6210\u4efb\u52a1\u3002<\/p>\n<h3>LlamaIndex\u4ee3\u7406\u7684\u6838\u5fc3\u7ec4\u4ef6<\/h3>\n<p>LlamaIndex\u4e2d\u7684\u4ee3\u7406\u6709\u4e24\u4e2a\u4e3b\u8981\u7ec4\u4ef6\uff1aAgentRunner\u548cAgentWorker\u3002<\/p>\n<h4>Agent Runner<\/h4>\n<p>Agent Runner\u662fLlamaIndex\u4e2d\u7684\u7f16\u6392\u5668\u3002\u5b83\u7ba1\u7406\u4ee3\u7406\u7684\u72b6\u6001\uff0c\u5305\u62ec\u4f1a\u8bdd\u5185\u5b58\uff0c\u5e76\u4e3a\u7528\u6237\u4ea4\u4e92\u63d0\u4f9b\u9ad8\u7ea7\u754c\u9762\u3002\u5b83\u521b\u5efa\u548c\u7ef4\u62a4\u4efb\u52a1\uff0c\u5e76\u8d1f\u8d23\u5728\u6bcf\u4e2a\u4efb\u52a1\u4e2d\u8fd0\u884c\u5404\u4e2a\u6b65\u9aa4\u3002\u4ee5\u4e0b\u662f\u5176\u529f\u80fd\u7684\u8be6\u7ec6\u5206\u89e3\uff1a<\/p>\n<ul data-id=\"u738a58b-EeLRQk2f\">\n<li data-id=\"ld70c578-YOW0EVDH\">\u4efb\u52a1\u521b\u5efa\uff1a\u4ee3\u7406\u6267\u884c\u5668\u6839\u636e\u7528\u6237\u67e5\u8be2\u6216\u8f93\u5165\u521b\u5efa\u4efb\u52a1\u3002<\/li>\n<li data-id=\"ld70c578-M1ZfSFWB\">\u72b6\u6001\u7ba1\u7406\uff1a\u5b58\u50a8\u548c\u7ef4\u62a4\u4f1a\u8bdd\u548c\u4efb\u52a1\u7684\u72b6\u6001\u3002<\/li>\n<li data-id=\"ld70c578-JDMfD9m6\">\u5185\u5b58\u7ba1\u7406\uff1a\u5b83\u5728\u5185\u90e8\u7ba1\u7406\u4f1a\u8bdd\u5185\u5b58\uff0c\u786e\u4fdd\u5728\u4ea4\u4e92\u4e2d\u4fdd\u6301\u573a\u666f\u3002<\/li>\n<li data-id=\"ld70c578-OH9VWVjT\">\u4efb\u52a1\u6267\u884c\uff1a\u5b83\u4e0eAgent Worker\u534f\u8c03\uff0c\u5728\u6bcf\u4e2a\u4efb\u52a1\u4e2d\u6267\u884c\u5404\u4e2a\u6b65\u9aa4\u3002<\/li>\n<\/ul>\n<p>\u4e0eLangChain\u4ee3\u7406\uff08\u9700\u8981\u5f00\u53d1\u4eba\u5458\u4eba\u5de5\u5b9a\u4e49\u548c\u4f20\u9012\u5185\u5b58)\u4e0d\u540c\uff0cLlamaIndex\u4ee3\u7406\u5728\u5185\u90e8\u5904\u7406\u5185\u5b58\u7ba1\u7406\u3002<\/p>\n<h4>Agent Worker<\/h4>\n<p>Agent Worker\u63a7\u5236\u7531Agent Runner\u7ed9\u51fa\u7684\u4efb\u52a1\u7684\u9010\u6b65\u6267\u884c\u3002\u5b83\u8d1f\u8d23\u6839\u636e\u5f53\u524d\u8f93\u5165\u751f\u6210\u4efb\u52a1\u4e2d\u7684\u4e0b\u4e00\u6b65\u3002Agent Worker\u53ef\u4ee5\u5b9a\u5236\u4ee5\u5305\u542b\u7279\u5b9a\u7684\u63a8\u7406\u903b\u8f91\uff0c\u4f7f\u5176\u9ad8\u5ea6\u9002\u5e94\u4e0d\u540c\u7684\u4efb\u52a1\u3002\u4e3b\u8981\u65b9\u9762\u5305\u62ec\uff1a<\/p>\n<ul data-id=\"u738a58b-6CKKEGQj\">\n<li data-id=\"ld70c578-MJLqqEeJ\">\u6b65\u9aa4\u751f\u6210\uff1a\u6839\u636e\u5f53\u524d\u6570\u636e\u786e\u5b9a\u4efb\u52a1\u7684\u4e0b\u4e00\u6b65\u3002<\/li>\n<li data-id=\"ld70c578-kZJnEmkM\">\u81ea\u5b9a\u4e49\uff1a\u901a\u8fc7\u81ea\u5b9a\u4e49\uff0c\u4ee5\u5904\u7406\u7279\u5b9a\u7c7b\u578b\u7684\u63a8\u7406\u6216\u6570\u636e\u5904\u7406\u3002<\/li>\n<\/ul>\n<p>Agent Runner\u7ba1\u7406\u4efb\u52a1\u7684\u521b\u5efa\u548c\u72b6\u6001\uff0c\u800cAgent Worker\u6267\u884c\u6bcf\u4e2a\u4efb\u52a1\u7684\u6b65\u9aa4\uff0c\u5728Agent Runner\u7684\u6307\u5bfc\u4e0b\u5145\u5f53\u64cd\u4f5c\u5355\u5143\u3002<\/p>\n<h3>LlamaIndex\u4e2d\u7684\u4ee3\u7406\u7c7b\u578b<\/h3>\n<p>LlamIndex\u63d0\u4f9b\u4e86\u9488\u5bf9\u7279\u5b9a\u4efb\u52a1\u548c\u529f\u80fd\u8bbe\u8ba1\u7684\u4e0d\u540c\u7c7b\u578b\u7684\u4ee3\u7406\u3002<\/p>\n<h4>\u6570\u636e\u4ee3\u7406<\/h4>\n<p><u>\u6570\u636e\u4ee3\u7406<\/u>\u662f\u4e13\u95e8\u7528\u4e8e\u5904\u7406\u5404\u79cd\u6570\u636e\u4efb\u52a1\u7684\u4ee3\u7406\uff0c\u5305\u62ec\u68c0\u7d22\u548c\u64cd\u4f5c\u3002\u5b83\u4eec\u53ef\u4ee5\u5728\u8bfb\u548c\u5199\u6a21\u5f0f\u4e0b\u8fd0\u884c\uff0c\u5e76\u4e0e\u4e0d\u540c\u7684\u6570\u636e\u6e90\u65e0\u7f1d\u4ea4\u4e92\u3002<\/p>\n<p>\u6570\u636e\u4ee3\u7406\u53ef\u4ee5\u8de8\u5404\u79cd\u6570\u636e\u5e93\u548cAPI\u641c\u7d22\u3001\u68c0\u7d22\u3001\u66f4\u65b0\u548c\u64cd\u4f5c\u6570\u636e\u3002\u5b83\u4eec\u652f\u6301\u4e0eSlack\u3001Shopify\u3001Google\u7b49\u5e73\u53f0\u7684\u4ea4\u4e92\uff0c\u4ece\u800c\u53ef\u4ee5\u8f7b\u677e\u5730\u4e0e\u8fd9\u4e9b\u670d\u52a1\u96c6\u6210\u3002\u6570\u636e\u4ee3\u7406\u53ef\u4ee5\u5904\u7406\u590d\u6742\u7684\u6570\u636e\u64cd\u4f5c\uff0c\u4f8b\u5982\u67e5\u8be2\u6570\u636e\u5e93\u3001\u8c03\u7528API\u3001\u66f4\u65b0\u8bb0\u5f55\u548c\u6267\u884c\u6570\u636e\u8f6c\u6362\u3002\u5176\u9002\u5e94\u6027\u5f3a\u7684\u8bbe\u8ba1\u4f7f\u5176\u9002\u7528\u4e8e\u4ece\u7b80\u5355\u7684\u6570\u636e\u68c0\u7d22\u5230\u590d\u6742\u7684\u6570\u636e\u5904\u7406\u7ba1\u9053\u7684\u5e7f\u6cdb\u5e94\u7528\u3002<\/p>\n<p>Python<\/p>\n<p>\u590d\u5236<\/p>\n<p>1 from llama_index.agent import OpenAIAgent, ReActAgent 2 from llama_index.llms import OpenAI 3 4 # import and define tools 5 &#8230; 6 # initialize llm 7 llm = OpenAI(model=&#8221;gpt-3.5-turbo&#8221;) 8 # initialize openai agent 9 agent = OpenAIAgent.from_tools(tools, llm=llm, verbose=True) 10 # initialize ReAct agent 11 agent = ReActAgent.from_tools(tools, llm=llm, verbose=True) 12 # use agent 13 response = agent.chat(&#8220;What is (121 * 3) + 42?&#8221;)<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<\/ul>\n<h4>\u81ea\u5b9a\u4e49\u4ee3\u7406<\/h4>\n<p>\u81ea\u5b9a\u4e49\u4ee3\u7406\uff08Custom Agents\uff09\u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u5f88\u591a\u7684\u7075\u6d3b\u6027\u548c\u81ea\u5b9a\u4e49\u9009\u9879\u3002\u901a\u8fc7\u5b50\u7c7b\u5316CustomSimpleAgentWorker\uff0c\u53ef\u4ee5\u4e3a\u4ee3\u7406\u5b9a\u4e49\u7279\u5b9a\u7684\u903b\u8f91\u548c\u884c\u4e3a\u3002\u8fd9\u5305\u62ec\u5904\u7406\u590d\u6742\u67e5\u8be2\u3001\u96c6\u6210\u591a\u4e2a\u5de5\u5177\u548c\u5b9e\u73b0\u9519\u8bef\u5904\u7406\u673a\u5236\u3002<\/p>\n<p>\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u5b9a\u4e49\u5206\u6b65\u903b\u8f91\u3001\u91cd\u8bd5\u673a\u5236\u548c\u96c6\u6210\u5404\u79cd\u5de5\u5177\u6765\u5b9a\u5236\u81ea\u5b9a\u4e49\u4ee3\u7406\u4ee5\u6ee1\u8db3\u7279\u5b9a\u9700\u6c42\u3002\u8fd9\u79cd\u81ea\u5b9a\u4e49\u5141\u8bb8\u7528\u6237\u521b\u5efa\u7ba1\u7406\u590d\u6742\u4efb\u52a1\u548c\u5de5\u4f5c\u6d41\u7684\u4ee3\u7406\uff0c\u4f7f\u5b83\u4eec\u80fd\u591f\u9ad8\u5ea6\u9002\u5e94\u4e0d\u540c\u7684\u573a\u666f\u3002\u65e0\u8bba\u662f\u7ba1\u7406\u590d\u6742\u7684\u6570\u636e\u64cd\u4f5c\u8fd8\u662f\u4e0e\u72ec\u7279\u7684\u670d\u52a1\u96c6\u6210\uff0c\u81ea\u5b9a\u4e49\u4ee3\u7406\u90fd\u80fd\u63d0\u4f9b\u6784\u5efa\u4e13\u4e1a\u3001\u9ad8\u6548\u89e3\u51b3\u65b9\u6848\u6240\u9700\u7684\u5de5\u5177\u3002<\/p>\n<h4>\u5de5\u5177\u548c\u5de5\u5177\u89c4\u683c<\/h4>\n<p>\u5de5\u5177\u662f\u4efb\u4f55\u4ee3\u7406\u4e2d\u6700\u91cd\u8981\u7684\u7ec4\u4ef6\uff0c\u5b83\u4eec\u5141\u8bb8\u4ee3\u7406\u6267\u884c\u5404\u79cd\u4efb\u52a1\u5e76\u6269\u5c55\u5176\u529f\u80fd\u3002\u901a\u8fc7\u4f7f\u7528\u4e0d\u540c\u7c7b\u578b\u7684\u5de5\u5177\uff0c\u4ee3\u7406\u53ef\u4ee5\u6839\u636e\u9700\u8981\u6267\u884c\u7279\u5b9a\u7684\u64cd\u4f5c\u3002\u8fd9\u4f7f\u5f97\u8be5\u4ee3\u7406\u5177\u6709\u5f88\u9ad8\u7684\u9002\u5e94\u6027\u548c\u6548\u7387\u3002<\/p>\n<h4>\u51fd\u6570\u5de5\u5177<\/h4>\n<p>\u51fd\u6570\u5de5\u5177\uff08FunctionTool\uff09\u5141\u8bb8\u7528\u6237\u5c06\u4efb\u4f55Python\u51fd\u6570\u8f6c\u6362\u4e3a\u4ee3\u7406\u53ef\u4ee5\u4f7f\u7528\u7684\u5de5\u5177\u3002\u8fd9\u4e00\u7279\u6027\u5bf9\u4e8e\u521b\u5efa\u81ea\u5b9a\u4e49\u64cd\u4f5c\u975e\u5e38\u6709\u7528\uff0c\u53ef\u4ee5\u589e\u5f3a\u4ee3\u7406\u6267\u884c\u5404\u79cd\u4efb\u52a1\u7684\u80fd\u529b\u3002<\/p>\n<p>\u7528\u6237\u53ef\u4ee5\u5c06\u7b80\u5355\u7684\u51fd\u6570\u8f6c\u6362\u4e3a\u4ee3\u7406\u5c06\u5176\u96c6\u6210\u5230\u5176\u5de5\u4f5c\u6d41\u4e2d\u7684\u5de5\u5177\u3002\u8fd9\u53ef\u4ee5\u5305\u62ec\u6570\u5b66\u8fd0\u7b97\u3001\u6570\u636e\u5904\u7406\u51fd\u6570\u548c\u5176\u4ed6\u81ea\u5b9a\u4e49\u903b\u8f91\u3002<\/p>\n<p>\u53ef\u4ee5\u5c06Python\u51fd\u6570\u8f6c\u6362\u4e3a\u5982\u4e0b\u7684\u5de5\u5177\uff1a<\/p>\n<p>Python<\/p>\n<p>\u590d\u5236<\/p>\n<p>1 from llama_index.core.tools import FunctionTool 2 def multiply(a\uff1a int, b\uff1a int) -&gt; int\uff1a 3 &#8220;&#8221;&#8221;Multiple two integers and returns the result integer&#8221;&#8221;&#8221; 4 return a * b 5 6 multiply_tool = FunctionTool.from_defaults(fn=multiply)<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<\/ul>\n<p>LlamaIndex\u4e2d\u7684FunctionTool\u65b9\u6cd5\u5141\u8bb8\u7528\u6237\u5c06\u4efb\u4f55Python\u51fd\u6570\u8f6c\u6362\u4e3a\u4ee3\u7406\u53ef\u4ee5\u4f7f\u7528\u7684\u5de5\u5177\u3002\u51fd\u6570\u7684\u540d\u79f0\u6210\u4e3a\u5de5\u5177\u7684\u540d\u79f0\uff0c\u51fd\u6570\u7684\u6587\u6863\u5b57\u7b26\u4e32\u5145\u5f53\u5de5\u5177\u7684\u63cf\u8ff0\u3002<\/p>\n<h4>\u67e5\u8be2\u5f15\u64ce\u5de5\u5177<\/h4>\n<p>\u67e5\u8be2\u5f15\u64ce\u5de5\u5177\uff08QueryEngine\u00a0Tools\uff09\u5305\u88c5\u4e86\u73b0\u6709\u7684\u67e5\u8be2\u5f15\u64ce\uff0c\u5141\u8bb8\u4ee3\u7406\u5bf9\u6570\u636e\u6e90\u6267\u884c\u590d\u6742\u7684\u67e5\u8be2\u3002\u8fd9\u4e9b\u5de5\u5177\u4e0e\u5404\u79cd\u6570\u636e\u5e93\u548cAPI\u96c6\u6210\uff0c\u4f7f\u4ee3\u7406\u80fd\u591f\u9ad8\u6548\u5730\u68c0\u7d22\u548c\u64cd\u4f5c\u6570\u636e\u3002<\/p>\n<p>\u8fd9\u4e9b\u5de5\u5177\u4f7f\u4ee3\u7406\u80fd\u591f\u4e0e\u7279\u5b9a\u7684\u6570\u636e\u6e90\u4ea4\u4e92\u3001\u6267\u884c\u590d\u6742\u7684\u67e5\u8be2\u548c\u68c0\u7d22\u76f8\u5173\u4fe1\u606f\u3002\u8fd9\u79cd\u96c6\u6210\u5141\u8bb8\u4ee3\u7406\u5728\u51b3\u7b56\u8fc7\u7a0b\u4e2d\u6709\u6548\u5730\u4f7f\u7528\u6570\u636e\u3002<\/p>\n<p>\u8981\u5c06\u4efb\u4f55\u67e5\u8be2\u5f15\u64ce\u8f6c\u6362\u4e3a\u67e5\u8be2\u5f15\u64ce\u5de5\u5177\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>Python<\/p>\n<p>\u590d\u5236<\/p>\n<p>1 from llama_index.core.tools import QueryEngineTool 2 from llama_index.core.tools import ToolMetadata 3 query_engine_tools = QueryEngineTool( 4 query_engine=&#8221;your_index_as_query_engine_here&#8221;, 5 metadata=ToolMetadata( 6 name=&#8221;name_your_tool&#8221;, 7 description=&#8221;Provide the description&#8221;, 8 ), 9 )<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<\/ul>\n<p>QueryEngineTool\u65b9\u6cd5\u5141\u8bb8\u7528\u6237\u5c06\u67e5\u8be2\u5f15\u64ce\u8f6c\u6362\u4e3a\u4ee3\u7406\u53ef\u4ee5\u4f7f\u7528\u7684\u5de5\u5177\u3002ToolMetadata\u7c7b\u5e2e\u52a9\u5b9a\u4e49\u8fd9\u4e2a\u5de5\u5177\u7684\u540d\u79f0\u548c\u63cf\u8ff0\u3002\u5de5\u5177\u7684\u540d\u79f0\u7531name\u5c5e\u6027\u8bbe\u7f6e\uff0c\u63cf\u8ff0\u7531description\u5c5e\u6027\u8bbe\u7f6e\u3002<\/p>\n<ul data-id=\"u738a58b-KCPf0aVX\">\n<li data-id=\"ld70c578-kadpddWA\">\u6ce8\u610f\uff1a\u5de5\u5177\u7684\u63cf\u8ff0\u975e\u5e38\u91cd\u8981\uff0c\u56e0\u4e3a\u5b83\u6709\u52a9\u4e8eLLM\u51b3\u5b9a\u4f55\u65f6\u4f7f\u7528\u8be5\u5de5\u5177\u3002<\/li>\n<\/ul>\n<h3>\u4f7f\u7528MyScaleDB\u548cLlamaIndex\u6784\u5efa\u4eba\u5de5\u667a\u80fd\u4ee3\u7406<\/h3>\n<p>\u4f7f\u7528\u67e5\u8be2\u5f15\u64ce\u5de5\u5177\u548c\u529f\u80fd\u5de5\u5177\u6784\u5efa\u4e00\u4e2a<strong>\u4eba\u5de5\u667a\u80fd<\/strong>\u4ee3\u7406\uff0c\u4ee5\u6f14\u793a\u5982\u4f55\u6709\u6548\u5730\u96c6\u6210\u548c\u5229\u7528\u8fd9\u4e9b\u5de5\u5177\u3002<\/p>\n<h4>\u5b89\u88c5\u5fc5\u8981\u7684\u5e93<\/h4>\n<p>\u9996\u5148\uff0c\u901a\u8fc7\u5728\u7ec8\u7aef\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u6240\u9700\u7684\u5e93\uff1a<\/p>\n<p>Shell<\/p>\n<p>\u590d\u5236<\/p>\n<p>1 pip install myscale-client llama<\/p>\n<ul>\n<li>1.<\/li>\n<\/ul>\n<p>\u5c06\u4f7f\u7528MyScaleDB\u4f5c\u4e3a\u5411\u91cf\u641c\u7d22\u5f15\u64ce\u6765\u5f00\u53d1\u67e5\u8be2\u5f15\u64ce\u3002\u8fd9\u662f\u4e00\u4e2a\u4e13\u95e8\u4e3a\u53ef\u6269\u5c55\u5e94\u7528\u7a0b\u5e8f\u8bbe\u8ba1\u7684\u9ad8\u7ea7SQL\u5411\u91cf\u6570\u636e\u5e93\u3002<\/p>\n<h4>\u83b7\u53d6\u67e5\u8be2\u5f15\u64ce\u7684\u6570\u636e<\/h4>\n<p>\u5bf9\u4e8e\u8fd9\u4e2a\u4f8b\u5b50\uff0c\u5c06\u4f7f\u7528Nike\u76ee\u5f55\u6570\u636e\u96c6\u3002\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u4e0b\u8f7d\u5e76\u51c6\u5907\u6570\u636e\uff1a<\/p>\n<p>Python<\/p>\n<p>\u590d\u5236<\/p>\n<p>1 from llama_index.core import VectorStoreIndex, SimpleDirectoryReader 2 import requests 3 4 url = &#8216;https\uff1a\/\/niketeam-asset-download.nike.net\/catalogs\/2024\/2024_Nike%20Kids_02_09_24.pdf?cb=09302022&#8217; 5 response = requests.get(url) 6 7 with open(&#8216;Nike_Catalog.pdf&#8217;, &#8216;wb&#8217;) as f\uff1a 8 f.write(response.content) 9 10 reader = SimpleDirectoryReader(input_files=[&#8220;Nike_Catalog.pdf&#8221;]) 11 documents = reader.load_data()<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<\/ul>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u5c06\u4e0b\u8f7dNike\u76ee\u5f55PDF\u5e76\u52a0\u8f7d\u6570\u636e\u4ee5\u4fbf\u5728\u67e5\u8be2\u5f15\u64ce\u4e2d\u4f7f\u7528\u3002<\/p>\n<h4>\u8fde\u63a5MyScaleDB<\/h4>\n<p>\u5728\u4f7f\u7528MyScaleDB\u4e4b\u524d\uff0c\u9700\u8981\u5efa\u7acb\u4e00\u4e2a\u8fde\u63a5\uff1a<\/p>\n<p>Python<\/p>\n<p>\u590d\u5236<\/p>\n<p>1 import clickhouse_connect 2 3 client = clickhouse_connect.get_client( 4 host=&#8217;your_host_here&#8217;, 5 port=443, 6 username=&#8217;your_username_here&#8217;, 7 password=&#8217;your_password_here&#8217; 8 )<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<\/ul>\n<p>\u8981\u4e86\u89e3\u5982\u4f55\u83b7\u53d6\u96c6\u7fa4\u8be6\u7ec6\u4fe1\u606f\u5e76\u9605\u8bfb\u6709\u5173MyScale\u7684\u66f4\u591a\u4fe1\u606f\u53ef\u4ee5\u53c2\u8003<u>MyScaleDB<\/u>\u5feb\u901f\u5165\u95e8\u6307\u5357\u3002<\/p>\n<h4>\u521b\u5efa\u67e5\u8be2\u5f15\u64ce\u5de5\u5177<\/h4>\n<p>\u9996\u5148\u4e3a\u4ee3\u7406\u6784\u5efa\u7b2c\u4e00\u4e2a\u5de5\u5177\uff0c\u5373\u67e5\u8be2\u5f15\u64ce\u5de5\u5177\u3002\u4e3a\u6b64\uff0c\u9996\u5148\u4f7f\u7528MyScaleDB\u5f00\u53d1\u67e5\u8be2\u5f15\u64ce\uff0c\u5e76\u5c06Nike\u76ee\u5f55\u6570\u636e\u6dfb\u52a0\u5230\u77e2\u91cf\u5b58\u50a8\u4e2d\u3002<\/p>\n<p>\u83b7\u53d6\u67e5\u8be2\u5f15\u64ce\u7684\u6570\u636e<\/p>\n<p>Python<\/p>\n<p>\u590d\u5236<\/p>\n<p>1 from llama_index.vector_stores.myscale import MyScaleVectorStore 2 from llama_index.core import StorageContext 3 vector_store = MyScaleVectorStore(myscale_client=client) 4 storage_context = StorageContext.from_defaults(vector_store=vector_store) 5 index = VectorStoreIndex.from_documents( 6 documents, storage_context=storage_context 7 ) 8 query_engine = index.as_query_engine()<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<\/ul>\n<p>\u4e00\u65e6\u6570\u636e\u88ab\u8f93\u5165\u5230\u5411\u91cf\u5b58\u50a8\u4e2d\uff0c\u5c31\u4f1a\u521b\u5efa\u4e00\u4e2a\u7d22\u5f15\u3002\u4e0b\u4e00\u6b65\u662f\u5c06\u67e5\u8be2\u5f15\u64ce\u8f6c\u6362\u4e3a\u5de5\u5177\u3002\u4e3a\u6b64\uff0c\u5c06\u4f7f\u7528LlamaIndex\u7684QueryEngineTool\u65b9\u6cd5\u3002<\/p>\n<p>Python<\/p>\n<p>\u590d\u5236<\/p>\n<p>1 from llama_index.core.tools import QueryEngineTool 2 from llama_index.core.tools import ToolMetadata 3 4 query_engine_tool = QueryEngineTool( 5 query_engine=index, 6 metadata=ToolMetadata( 7 name=&#8221;nike_data&#8221;, 8 description=&#8221;Provide information about the Nike products. Use a detailed plain text question as input to the tool.&#8221; 9 ), 10 )<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<\/ul>\n<p>QueryEngineTool\u63a5\u53d7query_engine\u548cmeta_data\u4f5c\u4e3a\u53c2\u6570\u3002\u5728\u5143\u6570\u636e\u4e2d\uff0c\u91c7\u7528\u63cf\u8ff0\u5b9a\u4e49\u5de5\u5177\u7684\u540d\u79f0\u3002<\/p>\n<h4>\u521b\u5efa\u51fd\u6570\u5de5\u5177<\/h4>\n<p>\u4e0b\u4e00\u4e2a\u5de5\u5177\u662f\u4e00\u4e2a\u7b80\u5355\u7684Python\u51fd\u6570\uff0c\u5b83\u5c06\u4e24\u4e2a\u6570\u5b57\u76f8\u4e58\u3002\u6b64\u65b9\u6cd5\u5c06\u4f7f\u7528LlamaIndex\u7684FunctionTool\u8f6c\u6362\u4e3a\u5de5\u5177\u3002<\/p>\n<p>Python<\/p>\n<p>\u590d\u5236<\/p>\n<p>1 from llama_index.core.tools import FunctionTool 2 # Define a simple Python function 3 def multiply(a\uff1a int, b\uff1a int) -&gt; int\uff1a 4 &#8220;&#8221;&#8221;Multiply two integers and return the result.&#8221;&#8221;&#8221; 5 return a * b 6 # Change function to a tool 7 multiply_tool = FunctionTool.from_defaults(fn=multiply)<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<\/ul>\n<p>\u5728\u6b64\u4e4b\u540e\uff0c\u5b8c\u6210\u4e86\u5de5\u5177\u7684\u521b\u5efa\u3002LlamaIndex\u4ee3\u7406\u5c06\u5de5\u5177\u4f5c\u4e3aPython\u5217\u8868\u3002\u7136\u540e\u628a\u8fd9\u4e9b\u5de5\u5177\u6dfb\u52a0\u5230\u4e00\u4e2a\u5217\u8868\u4e2d\u3002<\/p>\n<p>Python<\/p>\n<p>\u590d\u5236<\/p>\n<p>1 tools = [multiply_tool, query_engine_tool]<\/p>\n<ul>\n<li>1.<\/li>\n<\/ul>\n<h4>\u5b9a\u4e49LLM<\/h4>\n<p>\u5b9a\u4e49LLM\u662f\u4efb\u4f55LlamaIndex\u4ee3\u7406\u7684\u6838\u5fc3\u3002LLM\u7684\u9009\u62e9\u662f\u81f3\u5173\u91cd\u8981\u7684\uff0c\u56e0\u4e3a\u5b9a\u4e49LLM\u7684\u7406\u89e3\u548c\u6027\u80fd\u8d8a\u597d\uff0c\u5b83\u5c31\u8d8a\u80fd\u6709\u6548\u5730\u5145\u5f53\u51b3\u7b56\u8005\u548c\u5904\u7406\u590d\u6742\u95ee\u9898\u3002\u5c06\u4f7f\u7528OpenAI\u7684gpt-3.5 turbo\u6a21\u578b\u3002<\/p>\n<p>Python<\/p>\n<p>\u590d\u5236<\/p>\n<p>1 from llama_index.llms.openai import OpenAI 2 llm = OpenAI(model=&#8221;gpt-3.5-turbo&#8221;)<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<\/ul>\n<h4>\u521d\u59cb\u5316\u4ee3\u7406<\/h4>\n<p>\u6b63\u5982\u524d\u9762\u770b\u5230\u7684\uff0c\u4e00\u4e2a\u4ee3\u7406\u7531\u4e00\u4e2aAgent Runner\u548c\u4e00\u4e2aAgent Worker\u7ec4\u6210\u3002\u8fd9\u662f\u4ee3\u7406\u7684\u4e24\u4e2a\u7ec4\u6210\u90e8\u5206\u3002\u73b0\u5728\u5c06\u63a2\u7d22\u5b83\u4eec\u5728\u5b9e\u8df5\u4e2d\u662f\u5982\u4f55\u5de5\u4f5c\u7684\u3002\u4ee5\u4e24\u79cd\u65b9\u5f0f\u5b9e\u73b0\u4e86\u4e0b\u9762\u7684\u4ee3\u7801\uff1a<\/p>\n<ul data-id=\"u738a58b-onl56YDf\">\n<li data-id=\"ld70c578-4mAJlIQW\">\u81ea\u5b9a\u4e49\u4ee3\u7406\uff1a\u7b2c\u4e00\u79cd\u65b9\u6cd5\u662f\u9996\u5148\u4f7f\u7528\u5de5\u5177\u548cLLM\u521d\u59cb\u5316\u4ee3\u7406\u5de5\u4f5c\u8005\u3002\u7136\u540e\uff0c\u5c06Agent Worker\u4f20\u9012\u7ed9Agent Runner\u4ee5\u5904\u7406\u5b8c\u6574\u7684\u4ee3\u7406\u3002\u5728\u8fd9\u91cc\u5c06\u5bfc\u5165\u5fc5\u8981\u7684\u6a21\u5757\u5e76\u7f16\u5199\u81ea\u5df1\u7684\u4ee3\u7406\u3002<\/li>\n<\/ul>\n<p>Python<\/p>\n<p>\u590d\u5236<\/p>\n<p>1 from llama_index.core.agent import AgentRunner 2 from llama_index.agent.openai import OpenAIAgentWorker 3 4 # Method 2\uff1a Initialize AgentRunner with OpenAIAgentWorker 5 openai_step_engine = OpenAIAgentWorker.from_tools(tools, llm=llm, verbose=True) 6 agent1 = AgentRunner(openai_step_engine)<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<\/ul>\n<ul data-id=\"u738a58b-CXW4aiVN\">\n<li data-id=\"ld70c578-bJDkKrrh\">\u4f7f\u7528\u9884\u5b9a\u4e49\u4ee3\u7406\uff1a\u7b2c\u4e8c\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528\u4ee3\u7406\uff0c\u4ee3\u7406\u662fAgentRunner\u7684\u5b50\u7c7b\uff0c\u5b83\u5728\u5e95\u5c42\u6346\u7ed1\u4e86OpenAIAgentWorker\u3002\u56e0\u6b64\u4e0d\u9700\u8981\u81ea\u5df1\u5b9a\u4e49AgentRunner\u6216AgentWorkers\uff0c\u56e0\u4e3a\u5b83\u4eec\u662f\u5728\u540e\u7aef\u5b9e\u73b0\u7684\u3002<\/li>\n<\/ul>\n<p>Python<\/p>\n<p>\u590d\u5236<\/p>\n<p>1 from llama_index.agent.openai import OpenAIAgent 2 3 # Initialize OpenAIAgent 4 agent = OpenAIAgent.from_tools(tools, llm=llm, verbose=True)<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<\/ul>\n<ul data-id=\"u738a58b-40rE3cE6\">\n<li data-id=\"ld70c578-kfAIu7C8\">\u6ce8\u610f\uff1a\u5f53\u5728LLM\u4e2d\u8bbe\u7f6everbose=true\u65f6\uff0c\u53ef\u4ee5\u6df1\u5165\u4e86\u89e3\u6a21\u578b\u7684\u601d\u7ef4\u8fc7\u7a0b\uff0c\u4ece\u800c\u901a\u8fc7\u63d0\u4f9b\u8be6\u7ec6\u7684\u89e3\u91ca\u548c\u63a8\u7406\u6765\u7406\u89e3\u5b83\u662f\u5982\u4f55\u5f97\u5230\u7b54\u6848\u7684\u3002<\/li>\n<\/ul>\n<p>\u65e0\u8bba\u521d\u59cb\u5316\u65b9\u6cd5\u662f\u4ec0\u4e48\uff0c\u90fd\u53ef\u4ee5\u4f7f\u7528\u76f8\u540c\u7684\u65b9\u6cd5\u6d4b\u8bd5\u4ee3\u7406\u3002\u6d4b\u8bd5\u7b2c\u4e00\u4e2a\uff1a<\/p>\n<p>Python<\/p>\n<p>\u590d\u5236<\/p>\n<p>1 # Call the custom agent 2 agent = agent.chat(&#8220;What&#8217;s the price of BOYS NIKE DF STOCK RECRUIT PANT DJ573?&#8221;)<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<\/ul>\n<p>\u5e94\u8be5\u5f97\u5230\u7c7b\u4f3c\u8fd9\u6837\u7684\u7ed3\u679c\uff1a<\/p>\n<p>\u73b0\u5728\u91c7\u7528\u6570\u5b66\u8fd0\u7b97\u8c03\u7528\u7b2c\u4e00\u4e2a\u81ea\u5b9a\u4e49\u4ee3\u7406\u3002<\/p>\n<p>Python<\/p>\n<p>\u590d\u5236<\/p>\n<p>1 # Call the second agent 2 response = agent1.chat(&#8220;What&#8217;s 2+2?&#8221;)<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<\/ul>\n<p>\u8c03\u7528\u7b2c\u4e8c\u4e2a\u4ee3\u7406\uff0c\u5e76\u8981\u6c42\u8fdb\u884c\u6570\u5b66\u8fd0\u7b97\u3002\u4f1a\u5f97\u5230\u7c7b\u4f3c\u8fd9\u6837\u7684\u56de\u590d\uff1a<\/p>\n<p>\u4eba\u5de5\u667a\u80fd\u4ee3\u7406\u81ea\u4e3b\u5904\u7406\u590d\u6742\u4efb\u52a1\u7684\u6f5c\u529b\u6b63\u5728\u6269\u5927\uff0c\u8fd9\u4f7f\u5f97\u5b83\u4eec\u5728\u5546\u4e1a\u73af\u5883\u4e2d\u5177\u6709\u4e0d\u53ef\u4f30\u91cf\u7684\u4ef7\u503c\uff0c\u5728\u8fd9\u4e9b\u73af\u5883\u4e2d\uff0c\u5b83\u4eec\u53ef\u4ee5\u7ba1\u7406\u65e5\u5e38\u4efb\u52a1\uff0c\u5e76\u5c06\u4eba\u7c7b\u89e3\u653e\u51fa\u6765\u4ece\u4e8b\u66f4\u9ad8\u4ef7\u503c\u7684\u6d3b\u52a8\u3002\u968f\u7740\u6280\u672f\u7684\u8fdb\u6b65\u548c\u5411\u524d\u53d1\u5c55\uff0c\u4eba\u5de5\u667a\u80fd\u4ee3\u7406\u7684\u91c7\u7528\u9884\u8ba1\u5c06\u4f1a\u589e\u957f\uff0c\u8fdb\u4e00\u6b65\u5f7b\u5e95\u6539\u53d8\u4eba\u4eec\u4e0e\u6280\u672f\u7684\u4e92\u52a8\u65b9\u5f0f\uff0c\u5e76\u4f18\u5316\u5de5\u4f5c\u6d41\u7a0b\u3002<\/p>\n<h3>\u7ed3\u8bba<\/h3>\n<p>LlamaIndex\u4ee3\u7406\u63d0\u4f9b\u4e86\u4e00\u79cd\u7ba1\u7406\u548c\u5904\u7406\u6570\u636e\u7684\u667a\u80fd\u65b9\u5f0f\uff0c\u8d85\u8d8a\u4e86\u4f20\u7edf\u7684RAG\u7cfb\u7edf\u3002\u4e0e\u9759\u6001\u6570\u636e\u7ba1\u9053\u4e0d\u540c\uff0c\u8fd9\u4e9b\u4ee3\u7406\u53ef\u4ee5\u505a\u51fa\u5b9e\u65f6\u51b3\u7b56\uff0c\u6839\u636e\u4f20\u5165\u7684\u6570\u636e\u8c03\u6574\u5176\u64cd\u4f5c\u3002\u8fd9\u79cd\u81ea\u52a8\u63a8\u7406\u4f7f\u5b83\u4eec\u5bf9\u590d\u6742\u4efb\u52a1\u5177\u6709\u9ad8\u5ea6\u7684\u9002\u5e94\u6027\u548c\u9ad8\u6548\u6027\u3002\u5b83\u4eec\u96c6\u6210\u4e86\u4ece\u57fa\u672c\u529f\u80fd\u5230\u9ad8\u7ea7\u67e5\u8be2\u5f15\u64ce\u7684\u5404\u79cd\u5de5\u5177\uff0c\u4ee5\u667a\u80fd\u5730\u5904\u7406\u8f93\u5165\u5e76\u63d0\u4f9b\u4f18\u5316\u7684\u7ed3\u679c\u3002<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_21978\" class=\"pvc_stats total_only  \" data-element-id=\"21978\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.0\" viewBox=\"0 0 502 315\" preserveAspectRatio=\"xMidYMid meet\"><g transform=\"translate(0,332) scale(0.1,-0.1)\" fill=\"\" stroke=\"none\"><path d=\"M2394 3279 l-29 -30 -3 -207 c-2 -182 0 -211 15 -242 39 -76 157 -76 196 0 15 31 17 60 15 243 l-3 209 -33 29 c-26 23 -41 29 -80 29 -41 0 -53 -5 -78 -31z\"\/><path d=\"M3085 3251 c-45 -19 -58 -50 -96 -229 -47 -217 -49 -260 -13 -295 52 -53 146 -42 177 20 16 31 87 366 87 410 0 70 -86 122 -155 94z\"\/><path d=\"M1751 3234 c-13 -9 -29 -31 -37 -50 -12 -29 -10 -49 21 -204 19 -94 39 -189 45 -210 14 -50 54 -80 110 -80 34 0 48 6 76 34 21 21 34 44 34 59 0 14 -18 113 -40 219 -37 178 -43 195 -70 221 -36 32 -101 37 -139 11z\"\/><path d=\"M1163 3073 c-36 -7 -73 -59 -73 -102 0 -56 133 -378 171 -413 34 -32 83 -37 129 -13 70 36 67 87 -16 290 -86 209 -89 214 -129 231 -35 14 -42 15 -82 7z\"\/><path d=\"M3689 3066 c-15 -9 -33 -30 -42 -48 -48 -103 -147 -355 -147 -375 0 -98 131 -148 192 -74 13 15 57 108 97 206 80 196 84 226 37 273 -30 30 -99 39 -137 18z\"\/><path d=\"M583 2784 c-38 -19 -67 -74 -58 -113 9 -42 211 -354 242 -373 16 -10 45 -18 66 -18 51 0 107 52 107 100 0 39 -1 41 -124 234 -80 126 -108 162 -133 173 -41 17 -61 16 -100 -3z\"\/><path d=\"M4250 2784 c-14 -9 -74 -91 -133 -183 -95 -150 -107 -173 -107 -213 0 -55 33 -94 87 -104 67 -13 90 8 211 198 130 202 137 225 78 284 -27 27 -42 34 -72 34 -22 0 -50 -8 -64 -16z\"\/><path d=\"M2275 2693 c-553 -48 -1095 -270 -1585 -649 -135 -104 -459 -423 -483 -476 -23 -49 -22 -139 2 -186 73 -142 361 -457 571 -626 285 -228 642 -407 990 -497 242 -63 336 -73 660 -74 310 0 370 5 595 52 535 111 1045 392 1455 803 122 121 250 273 275 326 19 41 19 137 0 174 -41 79 -309 363 -465 492 -447 370 -946 591 -1479 653 -113 14 -422 18 -536 8z m395 -428 c171 -34 330 -124 456 -258 112 -119 167 -219 211 -378 27 -96 24 -300 -5 -401 -72 -255 -236 -447 -474 -557 -132 -62 -201 -76 -368 -76 -167 0 -236 14 -368 76 -213 98 -373 271 -451 485 -162 444 86 934 547 1084 153 49 292 57 452 25z m909 -232 c222 -123 408 -262 593 -441 76 -74 138 -139 138 -144 0 -16 -233 -242 -330 -319 -155 -123 -309 -223 -461 -299 l-81 -41 32 46 c18 26 49 83 70 128 143 306 141 649 -6 957 -25 52 -61 116 -79 142 l-34 47 45 -20 c26 -10 76 -36 113 -56z m-2057 25 c-40 -58 -105 -190 -130 -263 -110 -324 -59 -707 132 -981 25 -35 42 -64 37 -64 -19 0 -241 119 -326 174 -188 122 -406 314 -532 468 l-58 71 108 103 c185 178 428 349 672 473 66 33 121 60 123 61 2 0 -10 -19 -26 -42z\"\/><path d=\"M2375 1950 c-198 -44 -350 -190 -395 -379 -18 -76 -8 -221 19 -290 114 -284 457 -406 731 -260 98 52 188 154 231 260 27 69 37 214 19 290 -38 163 -166 304 -326 360 -67 23 -215 33 -279 19z\"\/><\/g><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/aif.amtbbs.org\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u4f7f\u7528LlamaIndex\u7684\u67e5\u8be2\u5f15\u64ce\u5de5\u5177\u548c\u51fd\u6570\u5de5\u5177\u6784\u5efa\u4eba\u5de5\u667a\u80fd\u4ee3\u7406\uff0c\u5e76\u6f14\u793a\u5982\u4f55\u6709\u6548\u5730\u96c6\u6210\u548c\u5229\u7528\u8fd9\u4e9b\u5de5\u5177\u3002 \u57fa [&hellip;]<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_21978\" class=\"pvc_stats total_only  \" data-element-id=\"21978\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.0\" viewBox=\"0 0 502 315\" preserveAspectRatio=\"xMidYMid meet\"><g transform=\"translate(0,332) scale(0.1,-0.1)\" fill=\"\" stroke=\"none\"><path d=\"M2394 3279 l-29 -30 -3 -207 c-2 -182 0 -211 15 -242 39 -76 157 -76 196 0 15 31 17 60 15 243 l-3 209 -33 29 c-26 23 -41 29 -80 29 -41 0 -53 -5 -78 -31z\"\/><path d=\"M3085 3251 c-45 -19 -58 -50 -96 -229 -47 -217 -49 -260 -13 -295 52 -53 146 -42 177 20 16 31 87 366 87 410 0 70 -86 122 -155 94z\"\/><path d=\"M1751 3234 c-13 -9 -29 -31 -37 -50 -12 -29 -10 -49 21 -204 19 -94 39 -189 45 -210 14 -50 54 -80 110 -80 34 0 48 6 76 34 21 21 34 44 34 59 0 14 -18 113 -40 219 -37 178 -43 195 -70 221 -36 32 -101 37 -139 11z\"\/><path d=\"M1163 3073 c-36 -7 -73 -59 -73 -102 0 -56 133 -378 171 -413 34 -32 83 -37 129 -13 70 36 67 87 -16 290 -86 209 -89 214 -129 231 -35 14 -42 15 -82 7z\"\/><path d=\"M3689 3066 c-15 -9 -33 -30 -42 -48 -48 -103 -147 -355 -147 -375 0 -98 131 -148 192 -74 13 15 57 108 97 206 80 196 84 226 37 273 -30 30 -99 39 -137 18z\"\/><path d=\"M583 2784 c-38 -19 -67 -74 -58 -113 9 -42 211 -354 242 -373 16 -10 45 -18 66 -18 51 0 107 52 107 100 0 39 -1 41 -124 234 -80 126 -108 162 -133 173 -41 17 -61 16 -100 -3z\"\/><path d=\"M4250 2784 c-14 -9 -74 -91 -133 -183 -95 -150 -107 -173 -107 -213 0 -55 33 -94 87 -104 67 -13 90 8 211 198 130 202 137 225 78 284 -27 27 -42 34 -72 34 -22 0 -50 -8 -64 -16z\"\/><path d=\"M2275 2693 c-553 -48 -1095 -270 -1585 -649 -135 -104 -459 -423 -483 -476 -23 -49 -22 -139 2 -186 73 -142 361 -457 571 -626 285 -228 642 -407 990 -497 242 -63 336 -73 660 -74 310 0 370 5 595 52 535 111 1045 392 1455 803 122 121 250 273 275 326 19 41 19 137 0 174 -41 79 -309 363 -465 492 -447 370 -946 591 -1479 653 -113 14 -422 18 -536 8z m395 -428 c171 -34 330 -124 456 -258 112 -119 167 -219 211 -378 27 -96 24 -300 -5 -401 -72 -255 -236 -447 -474 -557 -132 -62 -201 -76 -368 -76 -167 0 -236 14 -368 76 -213 98 -373 271 -451 485 -162 444 86 934 547 1084 153 49 292 57 452 25z m909 -232 c222 -123 408 -262 593 -441 76 -74 138 -139 138 -144 0 -16 -233 -242 -330 -319 -155 -123 -309 -223 -461 -299 l-81 -41 32 46 c18 26 49 83 70 128 143 306 141 649 -6 957 -25 52 -61 116 -79 142 l-34 47 45 -20 c26 -10 76 -36 113 -56z m-2057 25 c-40 -58 -105 -190 -130 -263 -110 -324 -59 -707 132 -981 25 -35 42 -64 37 -64 -19 0 -241 119 -326 174 -188 122 -406 314 -532 468 l-58 71 108 103 c185 178 428 349 672 473 66 33 121 60 123 61 2 0 -10 -19 -26 -42z\"\/><path d=\"M2375 1950 c-198 -44 -350 -190 -395 -379 -18 -76 -8 -221 19 -290 114 -284 457 -406 731 -260 98 52 188 154 231 260 27 69 37 214 19 290 -38 163 -166 304 -326 360 -67 23 -215 33 -279 19z\"\/><\/g><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/aif.amtbbs.org\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":56,"featured_media":21980,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,80],"tags":[1285],"class_list":["post-21978","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-23","category-80","tag-llm-llamaindex-"],"_links":{"self":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts\/21978","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/users\/56"}],"replies":[{"embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/comments?post=21978"}],"version-history":[{"count":1,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts\/21978\/revisions"}],"predecessor-version":[{"id":21981,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts\/21978\/revisions\/21981"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/media\/21980"}],"wp:attachment":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/media?parent=21978"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/categories?post=21978"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/tags?post=21978"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}