大家好,我是老章
一文中,我介紹了
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.