Word文档加入ChatGPT功能命令

工具软件2年前 (2023)发布 AI观察员
169 0 0
Sub ChatGPT()Dim selectedText As StringDim apiKey As StringDim response As Object, re As StringDim midString As StringDim ans As StringIf Selection.Type = wdSelectionNormal ThenselectedText = Selection.TextselectedText = Replace(selectedText, ChrW$(13), "")appKey = "我的AppKey"apiKey = "我的apiKey"URL = " Set response = CreateObject("MSXML2.XMLHTTP")response.Open "POST", URL, Falseresponse.setRequestHeader "Content-Type", "application/json"response.setRequestHeader "Authorization", appKeyresponse.Send "{""apiKey"":""" & apiKey & """,""model"":""gpt-3.5-turbo-0301"", ""messages"":[{""role"":""user"",""content"":""" & selectedText & """}], ""temperature"":0.3}"re = response.responseTextmidString = Mid(re, InStr(re, """content"":""") + 11)ans = Split(midString, """")(0)ans = Replace(ans, "\n", "" & vbCrLf & "")Selection.Text = selectedText & vbNewLine & ansElseExit SubEnd IfEnd Sub

 

Word文档加入ChatGPT功能命令
© 版权声明

相关文章

天猫U特购  京东优惠购        京东优惠    天猫优惠