< 返回B站视频无水印解析工具

联动word真的不要太方便好吗?

From: www.tiktok.com/@wilson777776/video/7223749313887767810
Sub ChatGPT()
Dim selectedText As String
Dim apiKey As String
Dim response As Object, re As String
Dim midString As String
Dim ans As String
If Selection.Type = wdSelectionNormal Then
selectedText = Selection.Text
selectedText = Replace(selectedText, ChrW$(13), "")
apiKey = "替换为你的ChatGpt的API"
URL = "https://api.openai.com/v1/chat/completions"
Set response = CreateObject("MSXML2.XMLHTTP")
response.Open "POST", URL, False
response.setRequestHeader "Content-Type", "application/json"
response.setRequestHeader "Authorization", "Bearer " + apiKey
response.Send "{""model"":""gpt-3.5-turbo"", ""messages"":[{""role"":""user"",""content"":""" & selectedText & """}], ""temperature"":0.7}"
re = response.responseText
midString = Mid(re, InStr(re, """content"":""") + 11)
ans = Split(midString, """")(0)
ans = Replace(ans, "\n", "")
Selection.Text = selectedText & vbNewLine & ans
Else
Exit Sub
End If
End Sub
前往BILIBILI(B站)播放
  • 来自:103.120.69.134
  • 时间:2023-06-25 11:07:44
  • 网址:https://www.bilibili.com/video/BV1dh4y1R7e3