养生网站模板,wordpress主题导航调用,商务网站开发方式,如何选择网站模板目录
一、效果展示
二、配置方法
三、使用方法
四、注意事项
1、永久化使用
2、宏被禁用
3、office的生成失败 记录自己学习应用DeepSeek的过程...... 这个是与WPS配套使用的过程#xff0c;office的与这个类似#xff1a;
一、效果展示 二、配置方法
1、在最上方的…目录
一、效果展示
二、配置方法
三、使用方法
四、注意事项
1、永久化使用
2、宏被禁用
3、office的生成失败 记录自己学习应用DeepSeek的过程...... 这个是与WPS配套使用的过程office的与这个类似
一、效果展示 二、配置方法
1、在最上方的功能处找到开发工具点击VB编辑器 2、点击“插入”——模块得到一个空白的编辑界面 将下面的代码复制进去由于最近deepseek比较火我自己私有化本地部署了deepseek r1这里的url就是自己本地的地址而且代码的处理也是针对于deepseek的输出进行的编写如果是其他模型应该会报错。需要注意修改的有
第8行API http://localhost:1234/v1/chat/completions/对应大模型的url地址
第9行 SendTxt {model: deepseek-r1-distill-qwen-7b, messages: [{role:system, content:你是一个文本编辑助手}, {role:user, content: inputText }], stream: false}对应大模型的调用请求参数可能需要改的就是model这个参数
第42行api_key 1234对应于api_key如果是本地私有化部署的就随意填写如果是调用官网大模型的api就为对应的key
Function CallDeepSeekAPI(api_key As String, inputText As String) As StringDim API As StringDim SendTxt As StringDim Http As ObjectDim status_code As IntegerDim response As StringAPI http://localhost:1234/v1/chat/completions/SendTxt {model: deepseek-r1-distill-qwen-7b, messages: [{role:system, content:你是一个文本编辑助手}, {role:user, content: inputText }], stream: false}Set Http CreateObject(MSXML2.XMLHTTP)With Http.Open POST, API, False.setRequestHeader Content-Type, application/json.setRequestHeader Authorization, Bearer api_key.send SendTxtstatus_code .Statusresponse .responseTextEnd With 弹出窗口显示 API 响应调试用 MsgBox API Response: response, vbInformation, Debug InfoIf status_code 200 ThenCallDeepSeekAPI responseElseCallDeepSeekAPI Error: status_code - responseEnd IfSet Http Nothing
End FunctionSub DeepSeekR1()Dim api_key As StringDim inputText As StringDim response As StringDim regex As ObjectDim matches As ObjectDim originalSelection As Range API Keyapi_key 1234If api_key ThenMsgBox Please enter the API key., vbExclamationExit SubEnd If 检查是否有选中文本If Selection.Type wdSelectionNormal ThenMsgBox Please select text., vbExclamationExit SubEnd If 保存原始选区Set originalSelection Selection.Range.Duplicate 处理特殊字符inputText Selection.TextinputText Replace(inputText, \, \\)inputText Replace(inputText, vbCrLf, )inputText Replace(inputText, vbCr, )inputText Replace(inputText, vbLf, )inputText Replace(inputText, , \) 转义双引号 发送 API 请求response CallDeepSeekAPI(api_key, inputText) 处理 API 响应If Left(response, 5) Error Then 解析 JSONSet regex CreateObject(VBScript.RegExp)With regex.Global True.MultiLine True.IgnoreCase False.Pattern content:(.*?) 匹配 JSON 的 content 字段End WithSet matches regex.Execute(response)If matches.Count 0 Then 提取 API 响应的文本内容response matches(0).SubMatches(0) 处理转义字符response Replace(response, \n, vbCrLf)response Replace(response, \\, \) 处理 JSON 里的反斜杠response Replace(response, , ) 过滤 防止意外符号 让光标移动到文档末尾防止覆盖已有内容Selection.Collapse Direction:wdCollapseEndSelection.TypeParagraphSelection.TypeText Text:response 将光标移回原来选中文本的末尾originalSelection.SelectElseMsgBox Failed to parse API response., vbExclamationEnd IfElseMsgBox response, vbCriticalEnd If
End Sub
之后关闭窗口就行
3、点击wps左上角的”文件“——”选项“进入”选项“窗口之后选择”自定义功能区“ 进入后在开发工具这里新建组我在这里改组名为deepseek然后在左侧搜索”宏“找到之前创建的模块点击添加并重新命名我这里改为”生成“最后点击确认即可。 三、使用方法
鼠标选择要发送给大模型的文案点击你所重命名的功能按钮我这里是”生成“ 四、注意事项
1、永久化使用
这个宏只是一次性的下次创建新的文档时这个”生成“便不好使。
若要永久启动宏需要将其保存成一个模板每次创建文档时候使用这个模板创建具体方法为
1另存为带宏的模板 2之后若要编辑新的word点击“开发工具”——加载项去掉文档模板框中的内容点选共用模板里面的deepseek_word.dotm点击打开即可编辑。 2、宏被禁用
只需要把宏启动即可wps和office的宏启动方式有所不同不过均在“文件”——选项——信任中心这里wps的直接可以看到“宏安全性”将其调整问中或者低而office的在“信任中心设置”里在宏设置中启动所有宏即可。 3、office的生成失败
按照之前的步骤一般不会出现问题但是我在进行office的配置时发现报错。按照报错信息打印出来的结果如下图所示我个人推测是office在进行数据接收的时候有数据的长度限制导致后面的数据直接截断因此后面的数据处理时格式错误使得内部报错。不过网上也有说是因为单双引号导致的 解决方案
改成流式的输出这样里面的vb代码需要变化
需要注意的是
第九行SendTxt {model: deepseek-r1-distill-qwen-7b, messages: [{role:system, content:我是一个文本生成助手}, {role:user, content: inputText }], stream: true}这里的stream改为true。
之后对strArr Split(response, data:) 按照data对流数据进行切分然后再正则匹配取出答案进行拼接。
Function CallDeepSeekAPI(api_key As String, inputText As String) As StringDim API As StringDim SendTxt As StringDim Http As ObjectDim status_code As IntegerDim response As StringAPI http://localhost:1234/v1/chat/completions/SendTxt {model: deepseek-r1-distill-qwen-7b, messages: [{role:system, content:我是一个文本生成助手}, {role:user, content: inputText }], stream: true}Set Http CreateObject(MSXML2.XMLHTTP)With Http.Open POST, API, False.setRequestHeader Content-Type, application/json.setRequestHeader Authorization, Bearer api_key.send SendTxtstatus_code .Statusresponse .responseTextEnd With 弹出窗口显示 API 响应调试用 MsgBox API Response: response, vbInformation, Debug InfoIf status_code 200 ThenCallDeepSeekAPI responseElseCallDeepSeekAPI Error: status_code - responseEnd IfSet Http Nothing
End FunctionSub DeepSeekR1()Dim api_key As StringDim inputText As StringDim response As StringDim lastRes As StringDim strArr() As StringDim regex As ObjectDim matches As ObjectDim originalSelection As RangelastRes API Keyapi_key 1234If api_key ThenMsgBox Please enter the API key., vbExclamationExit SubEnd If 检查是否有选中文本If Selection.Type wdSelectionNormal ThenMsgBox Please select text., vbExclamationExit SubEnd If 保存原始选区Set originalSelection Selection.Range.Duplicate 处理特殊字符inputText Selection.TextinputText Replace(inputText, \, \\)inputText Replace(inputText, vbCrLf, )inputText Replace(inputText, vbCr, )inputText Replace(inputText, vbLf, )inputText Replace(inputText, , \) 转义双引号 发送 API 请求response CallDeepSeekAPI(api_key, inputText)strArr Split(response, data:) 按照流数据进行切割Set regex CreateObject(VBScript.RegExp)With regex.Global True.MultiLine True.IgnoreCase False.Pattern content:(.*?) 匹配 JSON 的 content 字段End WithFor Each strItem In strArr 循环处理 处理 API 响应If Left(strItem, 5) Error Then 解析 JSONSet matches regex.Execute(strItem)If matches.Count 0 Then 提取 API 响应的文本内容strItem matches(0).SubMatches(0) 处理转义字符strItem Replace(strItem, vbCrLf, )strItem Replace(strItem, \n, vbCrLf)strItem Replace(strItem, \\, \) 处理 JSON 里的反斜杠strItem Replace(strItem, , ) 过滤 防止意外符号If Len(strItem) 0 ThenlastRes lastRes strItemEnd IfEnd IfElseMsgBox response, vbCriticalEnd IfNext 让光标移动到文档末尾防止覆盖已有内容Selection.Collapse Direction:wdCollapseEndSelection.TypeParagraphSelection.TypeText Text:lastRes 将光标移回原来选中文本的末尾originalSelection.Select
End Sub 文章转载自: http://www.morning.mmkrd.cn.gov.cn.mmkrd.cn http://www.morning.thxfn.cn.gov.cn.thxfn.cn http://www.morning.lzttq.cn.gov.cn.lzttq.cn http://www.morning.pxdgy.cn.gov.cn.pxdgy.cn http://www.morning.sfsjh.cn.gov.cn.sfsjh.cn http://www.morning.wjlhp.cn.gov.cn.wjlhp.cn http://www.morning.rtbx.cn.gov.cn.rtbx.cn http://www.morning.wfjyn.cn.gov.cn.wfjyn.cn http://www.morning.kjjbz.cn.gov.cn.kjjbz.cn http://www.morning.mgkb.cn.gov.cn.mgkb.cn http://www.morning.tfsyk.cn.gov.cn.tfsyk.cn http://www.morning.fglzk.cn.gov.cn.fglzk.cn http://www.morning.tfgkq.cn.gov.cn.tfgkq.cn http://www.morning.skrxp.cn.gov.cn.skrxp.cn http://www.morning.khtjn.cn.gov.cn.khtjn.cn http://www.morning.blqsr.cn.gov.cn.blqsr.cn http://www.morning.bmqls.cn.gov.cn.bmqls.cn http://www.morning.hmktd.cn.gov.cn.hmktd.cn http://www.morning.rbhcx.cn.gov.cn.rbhcx.cn http://www.morning.tpqzs.cn.gov.cn.tpqzs.cn http://www.morning.rcjyc.cn.gov.cn.rcjyc.cn http://www.morning.mkbc.cn.gov.cn.mkbc.cn http://www.morning.ghssm.cn.gov.cn.ghssm.cn http://www.morning.sqfrg.cn.gov.cn.sqfrg.cn http://www.morning.wbhzr.cn.gov.cn.wbhzr.cn http://www.morning.jqllx.cn.gov.cn.jqllx.cn http://www.morning.wfyzs.cn.gov.cn.wfyzs.cn http://www.morning.rqfzp.cn.gov.cn.rqfzp.cn http://www.morning.mqtzd.cn.gov.cn.mqtzd.cn http://www.morning.qkxt.cn.gov.cn.qkxt.cn http://www.morning.juju8.cn.gov.cn.juju8.cn http://www.morning.xpmwt.cn.gov.cn.xpmwt.cn http://www.morning.jcfg.cn.gov.cn.jcfg.cn http://www.morning.rqsnl.cn.gov.cn.rqsnl.cn http://www.morning.bzcjx.cn.gov.cn.bzcjx.cn http://www.morning.bxqtq.cn.gov.cn.bxqtq.cn http://www.morning.mnclk.cn.gov.cn.mnclk.cn http://www.morning.wjlrw.cn.gov.cn.wjlrw.cn http://www.morning.bzsqr.cn.gov.cn.bzsqr.cn http://www.morning.yqkxr.cn.gov.cn.yqkxr.cn http://www.morning.fnzbx.cn.gov.cn.fnzbx.cn http://www.morning.wanjia-sd.com.gov.cn.wanjia-sd.com http://www.morning.qkdcb.cn.gov.cn.qkdcb.cn http://www.morning.tgqzp.cn.gov.cn.tgqzp.cn http://www.morning.bkylg.cn.gov.cn.bkylg.cn http://www.morning.rlqqy.cn.gov.cn.rlqqy.cn http://www.morning.wbfly.cn.gov.cn.wbfly.cn http://www.morning.gjtdp.cn.gov.cn.gjtdp.cn http://www.morning.yqsr.cn.gov.cn.yqsr.cn http://www.morning.rptdz.cn.gov.cn.rptdz.cn http://www.morning.qxjck.cn.gov.cn.qxjck.cn http://www.morning.bswnf.cn.gov.cn.bswnf.cn http://www.morning.bnpcq.cn.gov.cn.bnpcq.cn http://www.morning.wtsr.cn.gov.cn.wtsr.cn http://www.morning.ymdhq.cn.gov.cn.ymdhq.cn http://www.morning.fldsb.cn.gov.cn.fldsb.cn http://www.morning.nlkjq.cn.gov.cn.nlkjq.cn http://www.morning.mmtbn.cn.gov.cn.mmtbn.cn http://www.morning.rsjf.cn.gov.cn.rsjf.cn http://www.morning.pdynk.cn.gov.cn.pdynk.cn http://www.morning.gbcxb.cn.gov.cn.gbcxb.cn http://www.morning.mydgr.cn.gov.cn.mydgr.cn http://www.morning.jmtrq.cn.gov.cn.jmtrq.cn http://www.morning.cpqwb.cn.gov.cn.cpqwb.cn http://www.morning.tfrlj.cn.gov.cn.tfrlj.cn http://www.morning.mqtzd.cn.gov.cn.mqtzd.cn http://www.morning.ymjgx.cn.gov.cn.ymjgx.cn http://www.morning.qjlnh.cn.gov.cn.qjlnh.cn http://www.morning.nqbcj.cn.gov.cn.nqbcj.cn http://www.morning.qrndh.cn.gov.cn.qrndh.cn http://www.morning.mlnby.cn.gov.cn.mlnby.cn http://www.morning.rpfpx.cn.gov.cn.rpfpx.cn http://www.morning.khxyx.cn.gov.cn.khxyx.cn http://www.morning.cfynn.cn.gov.cn.cfynn.cn http://www.morning.srjbs.cn.gov.cn.srjbs.cn http://www.morning.rcttz.cn.gov.cn.rcttz.cn http://www.morning.qyhcg.cn.gov.cn.qyhcg.cn http://www.morning.wgcng.cn.gov.cn.wgcng.cn http://www.morning.rksg.cn.gov.cn.rksg.cn http://www.morning.ghslr.cn.gov.cn.ghslr.cn