本地Ollama部署DeepSeek R1模型接入excel
时间: 2025-03-03 19:31:13 浏览: 256
### 部署 DeepSeek R1 模型并将其与 Excel 集成
#### 准备工作环境
为了在本地 Ollama 环境中成功部署 DeepSeek R1 模型,需先确保已安装必要的依赖项和配置好开发环境。这通常涉及 Python 和其他支持库的安装。
#### 安装 DeepSeek 模型
按照指定指南,在 Windows 上安装 DeepSeek 大模型的过程已经详尽描述过[^1]。此过程包括下载所需文件、设置运行环境以及验证安装是否成功的各个步骤。
#### 启动 DeepSeek 并连接到 Ollama
一旦 DeepSeek 成功部署于本地机器上,下一步就是让其能够通过 API 或者命令行接口被调用。对于希望将该功能嵌入至 Microsoft Office 应用程序中的用户来说,则需要特别注意 OfficeAI 插件的使用方法[^2]。
#### 实现与 Excel 的集成
要使 DeepSeek 能够同 Excel 协作,可以利用 VBA (Visual Basic for Applications) 编写宏来创建自定义函数或按钮触发器;也可以借助 Power Query 来加载外部数据源。更进一步地,如果想要实现更加无缝的操作体验,考虑采用 Add-in 形式的解决方案会更为理想——即把上述提到过的 OfficeAI 工具栏加入到 Excel 中去。
```vba
Sub CallDeepSeekAPI()
Dim http As Object, json As Dictionary, url As String
' 设置请求URL
url = "http://localhost:port/predict"
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "POST", url, False
http.setRequestHeader "Content-Type", "application/json"
http.send "{""input"": ""your input text here""}"
If http.Status = 200 Then
MsgBox ("Response from model:" & vbCrLf & http.responseText)
Else
MsgBox ("Error calling the service.")
End If
End Sub
```
这段简单的 VBA 代码展示了如何向本地运行的服务发送 POST 请求,并处理返回的结果。实际应用时应替换 `url` 变量中的端口号及路径以匹配具体的 API 地址。
阅读全文
相关推荐


















