大家好,我是老章
一文中,我介绍了
DeepSeek + Cursor Al 辅助编程
DeepSeek+ Obsidian 辅助写作
DeepSeek+ 沉浸式翻译/总结
在 这篇文章中介绍了
DeepSeek+ JupyterHub 辅助编程
DeepSeek + openwebui 聊天助手
DeepSeek+ 知识库&Agent
今天再补充两个网友写的DeepSeek接入PyCharm和WPS教程
DeepSeek + PyCharm
作****者:G.E.N.,编辑:根根AI
PyCharm 接入 DeepSeek 实现 AI 编程。
DeepSeek-V3
DeepSeek-V3是一个拥有671B参数的MoE模型,吞吐量每秒达60 token,比上一代V2提升3倍;在数学代码性能上,堪比国外大模型Claude 3.5 Sonnet。
接下来,我们把DeepSeek接入到PyCharm中,并利用其能力辅助我们进行代码开发。
效果演示
首先来看一下效果。
我们可以直接选中代码,并对代码段进行解释。
我们也可以通过选中代码,对代码进行修改。
创建API Key
首先进入DeepSeek官网,官网链接如下
https://www.deepseek.com/
点击API开放平台:
点击左侧“API Keys”,点击创建 API key,输出名称为“AI 代码提示”,也可以使用其它自定义的名称。
点击“创建",一定要记录此处的 API key,可以先将 API key 复制在其它地方。
在PyCharm中下载Continue插件
打开PyCharm,打开文件->设置->插件,搜索“Continue”,点击安装。
等待插件安装完毕后,点击“应用”,插件安装成功。
配置Continue
插件安装成功后,在右侧的标签栏中,会显示一个Continue的标签,我们点击即可进入,随后点击设置按键,如下图。
点击后,文本编辑区将会弹出配置文件。
我们对配置文件进行修改,将内容替换为下面的内容:
Function CallSiliconFlowAPI(api_key As String, inputText As String) As String
Dim API As String
Dim SendTxt As String
Dim Http As Object
Dim status_code As Integer
Dim response As String
API = "https://api.siliconflow.cn/v1/chat/completions"
' 模型名称 SendTxt = "{ ""model"": ""deepseek-ai/DeepSeek-R1-Distill-Qwen-32B"", ""messages"": [{""role"": ""user"", ""content"": """ & inputText & """}]} " Set Http = CreateObject("MSXML2.XMLHTTP") With Http .Open "POST", API, False .setRequestHeader "Content-Type", "application/json" .setRequestHeader "Authorization", "Bearer " & api_key .send SendTxt status_code = .Status response = .responseText End With If status_code = 200 Then CallSiliconFlowAPI = response Else CallSiliconFlowAPI = "Error: " & status_code & " - " & response End If Set Http = Nothing End Function Sub SiliconFlowV3() Dim api_key As String Dim inputText As String Dim response As String Dim regex As Object Dim matches As Object Dim originalSelection As Object api_key = "你的API KEY" If api_key = "" Then MsgBox "Please enter the API key." Exit Sub ElseIf Selection.Type <> wdSelectionNormal Then MsgBox "Please select text." Exit Sub End If ' 保存原始选中的文本
Set originalSelection = Selection.Range.Duplicate
inputText = Replace(Replace(Replace(Replace(Replace(Selection.Text, "\", "\\"), vbCrLf, ""), vbCr, ""), vbLf, ""), Chr(34), "\""") ' 调用硅基流动 API response = CallSiliconFlowAPI(api_key, inputText) If Left(response, 5) <> "Error" Then Set regex = CreateObject("VBScript.RegExp") With regex .Global = True .MultiLine = True .IgnoreCase = False ' 根据文档,响应中内容的格式,调整正则表达式 .Pattern = """content"":""(.*?)""" End With Set matches = regex.Execute(response) If matches.Count > 0 Then response = matches(0).SubMatches(0) response = Replace(Replace(response, """", Chr(34)), """", Chr(34)) ' 取消选中原始文本 Selection.Collapse Direction:=wdCollapseEnd ' 将内容插入到选中文字的下一行 Selection.TypeParagraph ' 插入新行 Selection.TypeText Text:=response ' 将光标移回原来选中文本的末尾 originalSelection.Select Else MsgBox "Failed to parse API response.", vbExclamation End If Else MsgBox response, vbCritical End If End Sub
修改时将会弹出提示,点击确定。
随后,我们将两处apiKey替换为先前保存的API key。
保存文件后,即可开始使用。
DeepSeek + WPS
❝ 整理:Peter 编辑:能源数聚
今天我们讲讲怎么将最近爆火的DeepSeek接入常用的WPS文档,实现人工智能对已有文档的检查、归纳、提炼、总结,或者是一些故事和诗歌的创作。
经常用WPS的土豪或许会问了,WPS不是本身就有AI吗?
❝ 对于普通的WPS用户来说,恐怕免费才是唯一的归途。那么我接下来要写的教程则满足了大部分人在WPS使用AI的愿望。步骤1:获取DeepSeek大模型的API KEY
首先登陆【硅基流动】注册网址(现在注册每个人可以领取2000万Tokens的额度):
步骤2:配置VB编辑器
进入VB编辑器界面:
首先新建一个文档,切换到VB编辑器,同时降低宏的安全性。
输入下面的配置代码:
Function CallSiliconFlowAPI(api_key As String, inputText As String) As String
Dim API As String
Dim SendTxt As String
Dim Http As Object
Dim status_code As Integer
Dim response As String
API = "https://api.siliconflow.cn/v1/chat/completions"
' 模型名称 SendTxt = "{ ""model"": ""deepseek-ai/DeepSeek-R1-Distill-Qwen-32B"", ""messages"": [{""role"": ""user"", ""content"": """ & inputText & """}]} " Set Http = CreateObject("MSXML2.XMLHTTP") With Http .Open "POST", API, False .setRequestHeader "Content-Type", "application/json" .setRequestHeader "Authorization", "Bearer " & api_key .send SendTxt status_code = .Status response = .responseText End With If status_code = 200 Then CallSiliconFlowAPI = response Else CallSiliconFlowAPI = "Error: " & status_code & " - " & response End If Set Http = Nothing End Function Sub SiliconFlowV3() Dim api_key As String Dim inputText As String Dim response As String Dim regex As Object Dim matches As Object Dim originalSelection As Object api_key = "你的API KEY" If api_key = "" Then MsgBox "Please enter the API key." Exit Sub ElseIf Selection.Type <> wdSelectionNormal Then MsgBox "Please select text." Exit Sub End If ' 保存原始选中的文本
Set originalSelection = Selection.Range.Duplicate
inputText = Replace(Replace(Replace(Replace(Replace(Selection.Text, "\", "\\"), vbCrLf, ""), vbCr, ""), vbLf, ""), Chr(34), "\""") ' 调用硅基流动 API response = CallSiliconFlowAPI(api_key, inputText) If Left(response, 5) <> "Error" Then Set regex = CreateObject("VBScript.RegExp") With regex .Global = True .MultiLine = True .IgnoreCase = False ' 根据文档,响应中内容的格式,调整正则表达式 .Pattern = """content"":""(.*?)""" End With Set matches = regex.Execute(response) If matches.Count > 0 Then response = matches(0).SubMatches(0) response = Replace(Replace(response, """", Chr(34)), """", Chr(34)) ' 取消选中原始文本 Selection.Collapse Direction:=wdCollapseEnd ' 将内容插入到选中文字的下一行 Selection.TypeParagraph ' 插入新行 Selection.TypeText Text:=response ' 将光标移回原来选中文本的末尾 originalSelection.Select Else MsgBox "Failed to parse API response.", vbExclamation End If Else MsgBox response, vbCritical End If End Sub
其中最重要的就是这两行代码:
一个是你在硅基流动网站选用的模型名称
一个则是你生成的API KEY
SendTxt = "{ ""model"": ""deepseek-ai/DeepSeek-R1-Distill-Qwen-32B"", ""messages"": [{""role"": ""user"", ""content"": """ & inputText & """}]} "
api_key = "你的API KEY"
新建的模块可以导出到桌面,方便以后调用。右上角直接叉掉关闭VB编辑器。
步骤3:配置WPS宏
点击文档的“文件”——“选项”——“自定义功能区”,选择“宏”
此时我们可以看到我们刚才在VB编辑器里面建好的宏。新建组,重命名为DeepSeek,然后把宏添加到新建的组下面,重命名为DeepSeek,最后点击确定。
此时我们回到文档菜单栏的“工具”,就可以看到多了一个“DeepSeek”的选项。
此时我们只需要在文档里输入内容,选中输入的内容,然后点击“DeepSeek”选项,就可以得到回应啦!是不是很简单!
特别声明:以上内容(如有图片或视频亦包括在内)为自媒体平台“网易号”用户上传并发布,本平台仅提供信息存储服务。
Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.