{"id":61058,"date":"2025-04-28T22:37:50","date_gmt":"2025-04-28T14:37:50","guid":{"rendered":"https:\/\/fwq.ai\/blog\/?p=61058"},"modified":"2025-04-28T22:37:50","modified_gmt":"2025-04-28T14:37:50","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8windows%e4%b8%8a%e5%bf%ab%e9%80%9f%e9%83%a8%e7%bd%b2ollama%e5%b9%b6%e5%ae%9e%e7%8e%b0%e9%a1%b9%e7%9b%ae%e6%8e%a5%e5%8f%a3%e6%8e%a5%e5%85%a5","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/61058\/","title":{"rendered":"\u5982\u4f55\u5728Windows\u4e0a\u5feb\u901f\u90e8\u7f72Ollama\u5e76\u5b9e\u73b0\u9879\u76ee\u63a5\u53e3\u63a5\u5165"},"content":{"rendered":"<h2>\u5f15\u8a00<\/h2>\n<p>\u968f\u7740\u4eba\u5de5\u667a\u80fd\u6280\u672f\u7684\u53d1\u5c55\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u5f00\u53d1\u8005\u5f00\u59cb\u5728\u672c\u5730\u90e8\u7f72\u6a21\u578b\u8fdb\u884c\u6d4b\u8bd5\u4e0e\u5f00\u53d1\u3002Ollama\u4f5c\u4e3a\u4e00\u6b3e\u9ad8\u6548\u7684\u672c\u5730AI\u6a21\u578b\u8fd0\u884c\u5e73\u53f0\uff0c\u53d7\u5230\u4e86\u5e7f\u6cdb\u5173\u6ce8\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728Windows\u73af\u5883\u4e0b\u5b89\u88c5Ollama\uff0c\u62c9\u53d6DeepSeek\u6a21\u578b\uff0c\u5e76\u8fdb\u884c\u63a5\u53e3\u6d4b\u8bd5\u3002\u5982\u679c\u4f60\u9700\u8981\u4e00\u4e2a\u9ad8\u6027\u80fd\u3001\u7a33\u5b9a\u3001\u4f4e\u5ef6\u8fdf\u7684\u670d\u52a1\u5668\u6765\u8fd0\u884c\u66f4\u591a\u6a21\u578b\u5b9e\u4f8b\uff0c<a href=\"https:\/\/fwq.ai\/\">\u7f8e\u56fd\u670d\u52a1\u5668<\/a>\u662f\u60a8\u7684\u4f18\u9009\u3002<\/p>\n<h2>\u4e00\u3001Ollama\u5b89\u88c5\u6307\u5357<\/h2>\n<p>\u9996\u5148\uff0c\u8bbf\u95eeOllama\u5b98\u7f51\uff0c\u4e0b\u8f7d\u9002\u7528\u4e8eWindows\u5e73\u53f0\u7684\u5b89\u88c5\u5305<code>OllamaSetup.exe<\/code>\uff0c\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88c5\u3002<\/p>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00<strong>\u7ba1\u7406\u5458\u6743\u9650<\/strong>\u7684\u547d\u4ee4\u63d0\u793a\u7b26\uff08cmd\uff09\u7a97\u53e3\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a<\/p>\n<pre><code class=\"language-bash\">ollama -v\r\n<\/code><\/pre>\n<p>\u82e5\u80fd\u6b63\u786e\u663e\u793a\u7248\u672c\u53f7\uff0c\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<h2>\u4e8c\u3001\u62c9\u53d6\u5e76\u8fd0\u884cDeepSeek\u6a21\u578b<\/h2>\n<p>\u63a5\u4e0b\u6765\uff0c\u62c9\u53d6DeepSeek\u7684\u9884\u8bad\u7ec3\u6a21\u578b\uff08\u6ce8\u610f\u6a21\u578b\u540d\u79f0\u5fc5\u987b\u51c6\u786e\u65e0\u8bef\uff09\uff1a<\/p>\n<pre><code class=\"language-bash\">ollama pull deepseek-r1:8b\r\n<\/code><\/pre>\n<p>\u6a21\u578b\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fd0\u884c\u6a21\u578b\uff1a<\/p>\n<pre><code class=\"language-bash\">ollama run deepseek-r1:8b\r\n<\/code><\/pre>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cOllama\u670d\u52a1\u53ea\u5141\u8bb8\u672c\u5730\u8bbf\u95ee\u3002\u5982\u679c\u9700\u8981\u8ba9\u5c40\u57df\u7f51\u5185\u5176\u4ed6\u8bbe\u5907\u4e5f\u80fd\u8bbf\u95ee\uff0c\u9700\u8981\u8fdb\u884c\u5982\u4e0b\u8bbe\u7f6e\uff1a<\/p>\n<pre><code class=\"language-bash\">setx OLLAMA_HOST \"0.0.0.0:11434\" \/M\r\n<\/code><\/pre>\n<p>\u8bbe\u7f6e\u540e\uff0c\u91cd\u542fOllama\u670d\u52a1\uff1a<\/p>\n<pre><code class=\"language-bash\">ollama serve\r\n<\/code><\/pre>\n<p>\u5982\u679c\u4f60\u90e8\u7f72\u7684\u662f<a href=\"https:\/\/fwq.ai\/\">\u7f8e\u56fdVPS<\/a>\uff0c\u8fd9\u6837\u7684\u64cd\u4f5c\u540c\u6837\u9002\u7528\uff0c\u5e76\u80fd\u4fdd\u8bc1\u6a21\u578b\u8bbf\u95ee\u901f\u5ea6\u66f4\u5feb\u3001\u8fde\u63a5\u66f4\u7a33\u5b9a\u3002<\/p>\n<h2>\u4e09\u3001\u6d4f\u89c8\u5668\u9a8c\u8bc1\u670d\u52a1\u662f\u5426\u6b63\u5e38\u542f\u52a8<\/h2>\n<p>\u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95ee\uff1a<\/p>\n<pre><code>http:\/\/localhost:11434\/\r\n<\/code><\/pre>\n<p>\u5982\u679c\u770b\u5230\u76f8\u5173\u9875\u9762\uff0c\u8bf4\u660eOllama\u670d\u52a1\u5df2\u7ecf\u6b63\u5e38\u542f\u52a8\uff0c\u53ef\u4ee5\u8fdb\u884c\u4e0b\u4e00\u6b65\u5f00\u53d1\u63a5\u5165\u3002<\/p>\n<h2>\u56db\u3001Java\u9879\u76ee\u63a5\u5165\u793a\u4f8b<\/h2>\n<p>\u4e3a\u4e86\u65b9\u4fbf\u5feb\u901f\u63a5\u5165\u9879\u76ee\uff0c\u4ee5\u4e0b\u662f\u57fa\u4e8eHutool\u548cFastjson\u5e93\u7684Java\u793a\u4f8b\u4ee3\u7801\uff0c\u7528\u4e8e\u6d4b\u8bd5\u63a5\u53e3\u901a\u4fe1\uff1a<\/p>\n<pre><code class=\"language-java\">import cn.hutool.http.HtmlUtil;\r\nimport cn.hutool.http.HttpRequest;\r\nimport cn.hutool.http.HttpResponse;\r\nimport com.alibaba.fastjson.JSONArray;\r\nimport com.alibaba.fastjson.JSONObject;\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\n\r\npublic class DeepSeekUtils {\r\n\r\n    public static final String ai_host = \"http:\/\/192.168.1.18:11434\/\";\r\n\r\n    public static void main(String[] args) {\r\n        String str = \"\u7ffb\u8bd1:where are you from?\";\r\n        String res = getContent(str);\r\n        System.out.println(\"\u5185\u5bb9\uff1a \"  + res);\r\n    }\r\n\r\n    public static String getContent(String q) {\r\n        String api = ai_host + \"v1\/chat\/completions\";\r\n        JSONObject jsonObject = new JSONObject();\r\n        jsonObject.put(\"model\", \"deepseek-r1:8b\");\r\n\r\n        JSONObject messageObject = new JSONObject();\r\n        messageObject.put(\"role\", \"user\");\r\n        messageObject.put(\"content\", q);\r\n\r\n        jsonObject.put(\"messages\", new JSONObject[]{messageObject});\r\n        jsonObject.put(\"stream\", false);\r\n\r\n        HttpRequest request = HttpRequest.post(api)\r\n                .body(jsonObject.toString())\r\n                .contentType(\"application\/json;charset=UTF-8\");\r\n\r\n        HttpResponse response = request.execute();\r\n        String content = \"\";\r\n\r\n        if (response.isOk()) {\r\n            try {\r\n                JSONObject responseJson = (JSONObject) JSONObject.parse(response.body());\r\n                JSONArray choices = responseJson.getJSONArray(\"choices\");\r\n                if (choices != null &amp;&amp; choices.size() &gt; 0) {\r\n                    JSONObject firstChoice = choices.getJSONObject(0);\r\n                    JSONObject message = firstChoice.getJSONObject(\"message\");\r\n                    content = HtmlUtil.filter(message.getString(\"content\")).trim();\r\n                }\r\n            } catch (Exception e) {\r\n                System.err.println(\"JSON\u89e3\u6790\u9519\u8bef\uff1a\" + e.getMessage());\r\n            }\r\n        } else {\r\n            System.err.println(\"\u8bf7\u6c42\u5931\u8d25\uff0c\u72b6\u6001\u7801\uff1a\" + response.getStatus());\r\n        }\r\n\r\n        return content;\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0a\u4ee3\u7801\u5b9e\u73b0\u4e86\u7b80\u5355\u7684\u8bf7\u6c42\u53d1\u9001\u4e0e\u7ed3\u679c\u89e3\u6790\uff0c\u53ef\u6839\u636e\u9879\u76ee\u5b9e\u9645\u9700\u6c42\u8fdb\u884c\u6269\u5c55\u3002<\/p>\n<h2>\u4e94\u3001\u63a7\u5236\u53f0\u8f93\u51fa\u7ed3\u679c<\/h2>\n<p>\u8fd0\u884c\u4ee5\u4e0a\u7a0b\u5e8f\u540e\uff0c\u53ef\u4ee5\u5728\u63a7\u5236\u53f0\u770b\u5230\u8fd4\u56de\u7684\u6587\u672c\u5185\u5bb9\uff0c\u8bf4\u660e\u4e0eOllama\u670d\u52a1\u7684\u63a5\u53e3\u901a\u4fe1\u6b63\u5e38\uff0c\u6a21\u578b\u54cd\u5e94\u53ca\u65f6\u3002<\/p>\n<p>\u5982\u679c\u5728\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u53d1\u73b0\u7531\u4e8e\u7f51\u7edc\u5e26\u5bbd\u6216\u670d\u52a1\u5668\u8d1f\u8f7d\u5bfc\u81f4\u8bbf\u95ee\u5ef6\u8fdf\u8fc7\u9ad8\uff0c\u5f3a\u70c8\u63a8\u8350\u4f7f\u7528<a href=\"https:\/\/fwq.ai\/\">\u7f8e\u56fd\u4e91\u670d\u52a1\u5668<\/a>\uff0c\u5927\u5e26\u5bbd\u3001\u4f4e\u5ef6\u8fdf\uff0c\u7279\u522b\u9002\u5408AI\u6a21\u578b\u90e8\u7f72\u548cAPI\u63a5\u53e3\u670d\u52a1\u642d\u5efa\u3002<\/p>\n<h2>\u7ed3\u8bed<\/h2>\n<p>\u672c\u6587\u8be6\u7ec6\u8bb2\u89e3\u4e86\u5982\u4f55\u5728Windows\u73af\u5883\u4e0b\u5b89\u88c5Ollama\u3001\u90e8\u7f72DeepSeek\u6a21\u578b\uff0c\u5e76\u8fdb\u884cJava\u63a5\u53e3\u8bbf\u95ee\u6d4b\u8bd5\u3002\u65e0\u8bba\u662f\u672c\u5730\u6d4b\u8bd5\u8fd8\u662f\u7ebf\u4e0a\u90e8\u7f72\uff0c\u7a33\u5b9a\u7684\u670d\u52a1\u5668\u8d44\u6e90\u90fd\u662f\u9879\u76ee\u987a\u5229\u8fd0\u884c\u7684\u5173\u952e\u3002\u5982\u679c\u4f60\u6b63\u5728\u5bfb\u627e\u9ad8\u6027\u80fd\u3001\u6027\u4ef7\u6bd4\u4f18\u79c0\u7684\u670d\u52a1\u5668\uff0c\u6211\u4eec\u63d0\u4f9b\u7684<strong>\u7f8e\u56fdVPS<\/strong>\u3001<strong>\u7f8e\u56fd\u4e91\u670d\u52a1\u5668<\/strong>\u3001<strong>\u7f8e\u56fd\u670d\u52a1\u5668<\/strong>\u4ea7\u54c1\uff0c\u5c06\u52a9\u529b\u4f60\u7684AI\u9879\u76ee\u9ad8\u6548\u843d\u5730\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f15\u8a00 \u968f\u7740\u4eba\u5de5\u667a\u80fd\u6280\u672f\u7684\u53d1\u5c55\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u5f00\u53d1\u8005\u5f00\u59cb\u5728\u672c\u5730\u90e8\u7f72\u6a21\u578b\u8fdb\u884c\u6d4b\u8bd5\u4e0e\u5f00\u53d1\u3002Ollama\u4f5c\u4e3a\u4e00\u6b3e\u9ad8\u6548\u7684\u672c\u5730AI\u6a21\u578b\u8fd0\u884c\u5e73\u53f0\uff0c\u53d7\u5230\u4e86\u5e7f\u6cdb\u5173\u6ce8\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728Windows\u73af\u5883\u4e0b\u5b89\u88c5Ollama\uff0c\u62c9\u53d6DeepSeek\u6a21\u578b\uff0c\u5e76\u8fdb\u884c\u63a5\u53e3\u6d4b\u8bd5\u3002\u5982\u679c\u4f60\u9700\u8981\u4e00\u4e2a\u9ad8\u6027\u80fd\u3001\u7a33\u5b9a\u3001\u4f4e\u5ef6\u8fdf\u7684\u670d\u52a1\u5668\u6765\u8fd0\u884c\u66f4\u591a\u6a21\u578b\u5b9e\u4f8b\uff0c\u7f8e\u56fd\u670d\u52a1\u5668\u662f\u60a8\u7684\u4f18\u9009\u3002 \u4e00\u3001Ollama\u5b89\u88c5\u6307\u5357 \u9996\u5148\uff0c\u8bbf\u95eeOllama\u5b98\u7f51\uff0c\u4e0b\u8f7d\u9002\u7528\u4e8eWindows\u5e73\u53f0\u7684\u5b89\u88c5\u5305OllamaSetup.exe\uff0c\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88c5\u3002 \u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u7ba1\u7406\u5458\u6743\u9650\u7684\u547d\u4ee4\u63d0\u793a\u7b26\uff08cmd\uff09\u7a97\u53e3\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a ollama -v \u82e5\u80fd\u6b63\u786e\u663e\u793a\u7248\u672c\u53f7\uff0c\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002 \u4e8c\u3001\u62c9\u53d6\u5e76\u8fd0\u884cDeepSeek\u6a21\u578b \u63a5\u4e0b\u6765\uff0c\u62c9\u53d6DeepSeek\u7684\u9884\u8bad\u7ec3\u6a21\u578b\uff08\u6ce8\u610f\u6a21\u578b\u540d\u79f0\u5fc5\u987b\u51c6\u786e\u65e0\u8bef\uff09\uff1a ollama pull deepseek-r1:8b \u6a21\u578b\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fd0\u884c\u6a21\u578b\uff1a ollama run deepseek-r1:8b \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cOllama\u670d\u52a1\u53ea\u5141\u8bb8\u672c\u5730\u8bbf\u95ee\u3002\u5982\u679c\u9700\u8981\u8ba9\u5c40\u57df\u7f51\u5185\u5176\u4ed6\u8bbe\u5907\u4e5f\u80fd\u8bbf\u95ee\uff0c\u9700\u8981\u8fdb\u884c\u5982\u4e0b\u8bbe\u7f6e\uff1a setx OLLAMA_HOST &#8220;0.0.0.0:11434&#8221; \/M \u8bbe\u7f6e\u540e\uff0c\u91cd\u542fOllama\u670d\u52a1\uff1a ollama serve \u5982\u679c\u4f60\u90e8\u7f72\u7684\u662f\u7f8e\u56fdVPS\uff0c\u8fd9\u6837\u7684\u64cd\u4f5c\u540c\u6837\u9002\u7528\uff0c\u5e76\u80fd\u4fdd\u8bc1\u6a21\u578b\u8bbf\u95ee\u901f\u5ea6\u66f4\u5feb\u3001\u8fde\u63a5\u66f4\u7a33\u5b9a\u3002 \u4e09\u3001\u6d4f\u89c8\u5668\u9a8c\u8bc1\u670d\u52a1\u662f\u5426\u6b63\u5e38\u542f\u52a8 \u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95ee\uff1a http:\/\/localhost:11434\/ \u5982\u679c\u770b\u5230\u76f8\u5173\u9875\u9762\uff0c\u8bf4\u660eOllama\u670d\u52a1\u5df2\u7ecf\u6b63\u5e38\u542f\u52a8\uff0c\u53ef\u4ee5\u8fdb\u884c\u4e0b\u4e00\u6b65\u5f00\u53d1\u63a5\u5165\u3002 \u56db\u3001Java\u9879\u76ee\u63a5\u5165\u793a\u4f8b \u4e3a\u4e86\u65b9\u4fbf\u5feb\u901f\u63a5\u5165\u9879\u76ee\uff0c\u4ee5\u4e0b\u662f\u57fa\u4e8eHutool\u548cFastjson\u5e93\u7684Java\u793a\u4f8b\u4ee3\u7801\uff0c\u7528\u4e8e\u6d4b\u8bd5\u63a5\u53e3\u901a\u4fe1\uff1a import cn.hutool.http.HtmlUtil; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import java.util.HashMap; import java.util.Map; public class DeepSeekUtils { public static final String ai_host [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-61058","post","type-post","status-publish","format-standard","hentry","category-ai"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/61058","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=61058"}],"version-history":[{"count":1,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/61058\/revisions"}],"predecessor-version":[{"id":61061,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/61058\/revisions\/61061"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=61058"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=61058"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=61058"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}