{"id":28604,"date":"2025-03-14T00:22:50","date_gmt":"2025-03-13T16:22:50","guid":{"rendered":"https:\/\/www.aisharenet.com\/?p=28604"},"modified":"2025-03-14T00:22:50","modified_gmt":"2025-03-13T16:22:50","slug":"ollama-bendebushuai","status":"publish","type":"post","link":"https:\/\/www.kdjingpai.com\/en\/ollama-bendebushuai\/","title":{"rendered":"Ollama \u672c\u5730\u90e8\u7f72\u6a21\u578b\u63a5\u5165 Dify"},"content":{"rendered":"<p><a href=\"https:\/\/www.kdjingpai.com\/ja\/dify\/\">Dify<\/a> \u652f\u6301\u63a5\u5165 <a href=\"https:\/\/www.kdjingpai.com\/ja\/ollama\/\">Ollama<\/a> \u90e8\u7f72\u7684\u5927\u578b\u8bed\u8a00\u6a21\u578b\u63a8\u7406\u548c embedding \u80fd\u529b\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u5feb\u901f\u63a5\u5165<\/h2>\n<ol>\n<li>\u4e0b\u8f7d Ollama<br \/>\n\u8bbf\u95ee\u00a0<a href=\"https:\/\/www.kdjingpai.com\/ollama-anzhuangyupeiai-4\/\">Ollama \u5b89\u88c5\u4e0e\u914d\u7f6e<\/a>\uff0c\u67e5\u770b Ollama \u672c\u5730\u90e8\u7f72\u6559\u7a0b\u3002<\/li>\n<li>\u8fd0\u884c Ollama \u5e76\u4e0e Llama \u804a\u5929\n<pre><code>ollama run llama3.1\r\n<\/code><\/pre>\n<p>\u542f\u52a8\u6210\u529f\u540e\uff0collama \u5728\u672c\u5730 11434 \u7aef\u53e3\u542f\u52a8\u4e86\u4e00\u4e2a API \u670d\u52a1\uff0c\u53ef\u901a\u8fc7\u00a0<code>http:\/\/localhost:11434<\/code>\u00a0\u8bbf\u95ee\u3002<br \/>\n\u5176\u4ed6\u6a21\u578b\u53ef\u8bbf\u95ee https:\/\/ollama.ai\/library \u4e86\u89e3\u8be6\u60c5\u3002<\/li>\n<li>\u5728 Dify \u4e2d\u63a5\u5165 Ollama<br \/>\n\u5728\u00a0<code>\u8bbe\u7f6e &gt; \u6a21\u578b\u4f9b\u5e94\u5546 &gt; Ollama<\/code>\u00a0\u4e2d\u586b\u5165\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-28605\" title=\"Ollama \u672c\u5730\u90e8\u7f72\u6a21\u578b\u63a5\u5165 Dify-1\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/2b2868ff9d0a74c.png\" alt=\"Ollama \u672c\u5730\u90e8\u7f72\u6a21\u578b\u63a5\u5165 Dify-1\" width=\"1562\" height=\"887\" srcset=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/2b2868ff9d0a74c.png 1562w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/2b2868ff9d0a74c-768x436.png 768w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/2b2868ff9d0a74c-1536x872.png 1536w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/2b2868ff9d0a74c-18x10.png 18w\" sizes=\"auto, (max-width: 1562px) 100vw, 1562px\" \/>\u00a0<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-28606\" title=\"Ollama \u672c\u5730\u90e8\u7f72\u6a21\u578b\u63a5\u5165 Dify-2\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/ad62e3e17c2a662.png\" alt=\"Ollama \u672c\u5730\u90e8\u7f72\u6a21\u578b\u63a5\u5165 Dify-2\" width=\"1562\" height=\"884\" srcset=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/ad62e3e17c2a662.png 1562w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/ad62e3e17c2a662-768x435.png 768w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/ad62e3e17c2a662-1536x869.png 1536w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/ad62e3e17c2a662-18x10.png 18w\" sizes=\"auto, (max-width: 1562px) 100vw, 1562px\" \/>\u00a0<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-28607\" title=\"Ollama \u672c\u5730\u90e8\u7f72\u6a21\u578b\u63a5\u5165 Dify-3\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/b1a5747f0512515.png\" alt=\"Ollama \u672c\u5730\u90e8\u7f72\u6a21\u578b\u63a5\u5165 Dify-3\" width=\"659\" height=\"878\" srcset=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/b1a5747f0512515.png 659w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/b1a5747f0512515-9x12.png 9w\" sizes=\"auto, (max-width: 659px) 100vw, 659px\" \/><\/p>\n<ul>\n<li>\u6a21\u578b\u540d\u79f0\uff1a<code>llama3.1<\/code><\/li>\n<li>\u57fa\u7840 URL \uff1a<code>http:\/\/&lt;your-ollama-endpoint-domain&gt;:11434<\/code><br \/>\n\u6b64\u5904\u9700\u586b\u5199\u53ef\u8bbf\u95ee\u5230\u7684 Ollama \u670d\u52a1\u5730\u5740\u3002<br \/>\n\u82e5 Dify \u4e3a docker \u90e8\u7f72\uff0c\u5efa\u8bae\u586b\u5199\u5c40\u57df\u7f51 IP \u5730\u5740\uff0c\u5982\uff1a<code>http:\/\/192.168.1.100:11434<\/code>\u00a0\u6216 docker \u5bbf\u4e3b\u673a IP \u5730\u5740\uff0c\u5982\uff1a<code>http:\/\/172.17.0.1:11434<\/code>\u3002<\/p>\n<blockquote><p>\u6ce8\uff1a\u67e5\u627e\u5c40\u57df\u7f51 IP \u5730\u5740\u547d\u4ee4\uff1a<\/p>\n<ul>\n<li>\u5728 Linux\/macOS \u4e0a\uff0c\u4f7f\u7528\u547d\u4ee4\u00a0<code>ip addr show<\/code>\u00a0\u6216\u00a0<code>ifconfig<\/code>\u3002<\/li>\n<li>\u5728 Windows \u4e0a\uff0c\u4f7f\u7528\u00a0<code>ipconfig<\/code>\u00a0\u547d\u4ee4\u67e5\u627e\u7c7b\u4f3c\u7684\u5730\u5740\u3002<\/li>\n<li>\u901a\u5e38\uff0c\u8fd9\u4e2a\u5730\u5740\u4f1a\u5728 eth0 \u6216 wlan0 \u63a5\u53e3\u4e0b\u663e\u793a\uff0c\u53d6\u51b3\u4e8e\u4f60\u662f\u4f7f\u7528\u6709\u7ebf\u7f51\u7edc\u8fd8\u662f\u65e0\u7ebf\u7f51\u7edc\u3002<\/li>\n<\/ul>\n<\/blockquote>\n<p>\u82e5\u4e3a\u672c\u5730\u6e90\u7801\u90e8\u7f72\uff0c\u53ef\u586b\u5199\u00a0<code>http:\/\/localhost:11434<\/code>\u3002<\/li>\n<li>\u6a21\u578b\u7c7b\u578b\uff1a<code>\u5bf9\u8bdd<\/code><\/li>\n<li>\u6a21\u578b\u4e0a\u4e0b\u6587\u957f\u5ea6\uff1a<code>4096<\/code><br \/>\n\u6a21\u578b\u7684\u6700\u5927\u4e0a\u4e0b\u6587\u957f\u5ea6\uff0c\u82e5\u4e0d\u6e05\u695a\u53ef\u586b\u5199\u9ed8\u8ba4\u503c 4096\u3002<\/li>\n<li>\u6700\u5927 <a href=\"https:\/\/www.kdjingpai.com\/ja\/tokenization\/\">token<\/a> \u4e0a\u9650\uff1a<code>4096<\/code><br \/>\n\u6a21\u578b\u8fd4\u56de\u5185\u5bb9\u7684\u6700\u5927 token \u6570\u91cf\uff0c\u82e5\u6a21\u578b\u65e0\u7279\u522b\u8bf4\u660e\uff0c\u5219\u53ef\u4e0e\u6a21\u578b\u4e0a\u4e0b\u6587\u957f\u5ea6\u4fdd\u6301\u4e00\u81f4\u3002<\/li>\n<li>\u662f\u5426\u652f\u6301 Vision\uff1a<code>\u662f<\/code><br \/>\n\u5f53\u6a21\u578b\u652f\u6301\u56fe\u7247\u7406\u89e3\uff08\u591a\u6a21\u6001\uff09\u52fe\u9009\u6b64\u9879\uff0c\u5982\u00a0<code>llava<\/code>\u3002<\/li>\n<\/ul>\n<p>\u70b9\u51fb &#8220;\u4fdd\u5b58&#8221; \u6821\u9a8c\u65e0\u8bef\u540e\u5373\u53ef\u5728\u5e94\u7528\u4e2d\u4f7f\u7528\u8be5\u6a21\u578b\u3002<br \/>\nEmbedding \u6a21\u578b\u63a5\u5165\u65b9\u5f0f\u4e0e LLM \u7c7b\u4f3c\uff0c\u53ea\u9700\u5c06\u6a21\u578b\u7c7b\u578b\u6539\u4e3a Text Embedding \u5373\u53ef\u3002<\/li>\n<li>\u4f7f\u7528 Ollama \u6a21\u578b<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-28608\" title=\"Ollama \u672c\u5730\u90e8\u7f72\u6a21\u578b\u63a5\u5165 Dify-4\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/e50616f32a3e492.png\" alt=\"Ollama \u672c\u5730\u90e8\u7f72\u6a21\u578b\u63a5\u5165 Dify-4\" width=\"1561\" height=\"883\" srcset=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/e50616f32a3e492.png 1561w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/e50616f32a3e492-768x434.png 768w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/e50616f32a3e492-1536x869.png 1536w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/e50616f32a3e492-18x10.png 18w\" sizes=\"auto, (max-width: 1561px) 100vw, 1561px\" \/><br \/>\n\u8fdb\u5165\u9700\u8981\u914d\u7f6e\u7684 App \u63d0\u793a\u8bcd\u7f16\u6392\u9875\u9762\uff0c\u9009\u62e9 Ollama \u4f9b\u5e94\u5546\u4e0b\u7684\u00a0<code>llama3.1<\/code>\u00a0\u6a21\u578b\uff0c\u914d\u7f6e\u6a21\u578b\u53c2\u6570\u540e\u5373\u53ef\u4f7f\u7528\u3002<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h2>FAQ<\/h2>\n<h3>\u26a0\ufe0f \u5982\u679c\u60a8\u4f7f\u7528 Docker \u90e8\u7f72 Dify \u548c Ollama \uff0c\u60a8\u53ef\u80fd\u4f1a\u9047\u5230\u4ee5\u4e0b\u9519\u8bef:<\/h3>\n<pre><code>httpconnectionpool(host=127.0.0.1, port=11434): max retries exceeded with url:\/cpi\/chat (Caused by NewConnectionError('&lt;urllib3.connection.HTTPConnection object at 0x7f8562812c20&gt;: fail to establish a new connection:[Errno 111] Connection refused'))\r\nhttpconnectionpool(host=localhost, port=11434): max retries exceeded with url:\/cpi\/chat (Caused by NewConnectionError('&lt;urllib3.connection.HTTPConnection object at 0x7f8562812c20&gt;: fail to establish a new connection:[Errno 111] Connection refused'))\r\n<\/code><\/pre>\n<p>\u8fd9\u4e2a\u9519\u8bef\u662f\u56e0\u4e3a Docker \u5bb9\u5668\u65e0\u6cd5\u8bbf\u95ee Ollama \u670d\u52a1\u3002 localhost \u901a\u5e38\u6307\u7684\u662f\u5bb9\u5668\u672c\u8eab\uff0c\u800c\u4e0d\u662f\u4e3b\u673a\u6216\u5176\u4ed6\u5bb9\u5668\u3002\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u60a8\u9700\u8981\u5c06 Ollama \u670d\u52a1\u66b4\u9732\u7ed9\u7f51\u7edc\u3002<\/p>\n<h3>\u5728 Mac \u4e0a\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/h3>\n<p>\u5982\u679c\u00a0<code>Ollama<\/code>\u00a0\u4f5c\u4e3a\u00a0<code>macOS<\/code>\u00a0\u5e94\u7528\u7a0b\u5e8f\u8fd0\u884c\uff0c\u5219\u5e94\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<code>launchctl<\/code>\u00a0\uff1a<\/p>\n<ol>\n<li>\u901a\u8fc7\u8c03\u7528\u00a0<code>launchctl setenv<\/code>\u00a0\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a\n<pre><code>launchctl setenv OLLAMA_HOST \"0.0.0.0\"\r\n<\/code><\/pre>\n<\/li>\n<li>\u91cd\u542f Ollama \u5e94\u7528\u7a0b\u5e8f\u3002<\/li>\n<li>\u5982\u679c\u4ee5\u4e0a\u6b65\u9aa4\u65e0\u6548\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<br \/>\n\u95ee\u9898\u662f\u5728 docker \u5185\u90e8\uff0c\u4f60\u5e94\u8be5\u8fde\u63a5\u5230\u00a0<code>host.docker.internal<\/code>\u00a0\uff0c\u624d\u80fd\u8bbf\u95ee docker \u7684\u4e3b\u673a\uff0c\u6240\u4ee5\u5c06\u00a0<code>localhost<\/code>\u00a0\u66ff\u6362\u4e3a\u00a0<code>host.docker.internal<\/code>\u00a0\u670d\u52a1\u5c31\u53ef\u4ee5\u751f\u6548\u4e86\uff1a<\/p>\n<pre><code>http:\/\/host.docker.internal:11434\r\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<h3>\u5728 Linux \u4e0a\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/h3>\n<p>\u5982\u679c Ollama \u4f5c\u4e3a systemd \u670d\u52a1\u8fd0\u884c\uff0c\u5e94\u8be5\u4f7f\u7528\u00a0<code>systemctl<\/code>\u00a0\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n<ol>\n<li>\u901a\u8fc7\u8c03\u7528\u00a0<code>systemctl edit ollama.service<\/code>\u00a0\u7f16\u8f91 systemd \u670d\u52a1\u3002\u8fd9\u5c06\u6253\u5f00\u4e00\u4e2a\u7f16\u8f91\u5668\u3002<\/li>\n<li>\u5bf9\u4e8e\u6bcf\u4e2a\u73af\u5883\u53d8\u91cf\uff0c\u5728\u00a0<code>[Service]<\/code>\u00a0\u90e8\u5206\u4e0b\u6dfb\u52a0\u4e00\u884c\u00a0<code>Environment<\/code>\u00a0\uff1a\n<pre><code>[Service]\r\nEnvironment=\"OLLAMA_HOST=0.0.0.0\"\r\n<\/code><\/pre>\n<\/li>\n<li>\u4fdd\u5b58\u5e76\u9000\u51fa\u3002<\/li>\n<li>\u91cd\u8f7d\u00a0<code>systemd<\/code>\u00a0\u5e76\u91cd\u542f Ollama\uff1a\n<pre><code>systemctl daemon-reload\r\nsystemctl restart ollama\r\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<h3>\u5728 Windows \u4e0a\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/h3>\n<p>\u5728 Windows \u4e0a\uff0c Ollama \u7ee7\u627f\u4e86\u60a8\u7684\u7528\u6237\u548c\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<ol>\n<li>\u9996\u5148\u901a\u8fc7\u4efb\u52a1\u680f\u70b9\u51fb Ollama \u9000\u51fa\u7a0b\u5e8f<\/li>\n<li>\u4ece\u63a7\u5236\u9762\u677f\u7f16\u8f91\u7cfb\u7edf\u73af\u5883\u53d8\u91cf<\/li>\n<li>\u4e3a\u60a8\u7684\u7528\u6237\u8d26\u6237\u7f16\u8f91\u6216\u65b0\u5efa\u53d8\u91cf\uff0c\u6bd4\u5982\u00a0<code>OLLAMA_HOST<\/code>\u00a0\u3001\u00a0<code>OLLAMA_MODELS<\/code>\u00a0\u7b49\u3002<\/li>\n<li>\u70b9\u51fb OK\/Apply \u5e94\u7528\u4fdd\u5b58<\/li>\n<li>\u5728\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\u7a97\u53e3\u8fd0\u884c\u00a0<code>ollama<\/code><\/li>\n<\/ol>\n<h3>\u5982\u4f55\u5728\u6211\u7684\u7f51\u7edc\u4e0a\u66b4\u9732 Ollama\uff1f<\/h3>\n<p>Ollama \u9ed8\u8ba4\u7ed1\u5b9a127.0.0.1\u7aef\u53e311434\u3002\u901a\u8fc7\u00a0<code>OLLAMA_HOST<\/code>\u00a0\u73af\u5883\u53d8\u91cf\u66f4\u6539\u7ed1\u5b9a\u5730\u5740\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dify \u652f\u6301\u63a5\u5165 Ollama \u90e8\u7f72\u7684\u5927\u578b\u8bed\u8a00\u6a21\u578b\u63a8\u7406\u548c embedding \u80fd\u529b\u3002 &nbsp; \u5feb\u901f\u63a5\u5165 \u4e0b\u8f7d Ollama \u8bbf\u95ee\u00a0Ollama \u5b89\u88c5\u4e0e\u914d\u7f6e\uff0c\u67e5\u770b Ollama \u672c\u5730\u90e8\u7f72\u6559\u7a0b\u3002 \u8fd0\u884c Ollama \u5e76\u4e0e Llama \u804a&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[182],"tags":[],"class_list":["post-28604","post","type-post","status-publish","format-standard","hentry","category-shicao"],"_links":{"self":[{"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/posts\/28604","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/comments?post=28604"}],"version-history":[{"count":0,"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/posts\/28604\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/media?parent=28604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/categories?post=28604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/tags?post=28604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}