将 ChatGPT 接入 Excel 中当函数方法

ChatGPT 接入 Excel 中当函数,不用再把自己的资料上传到网上;不用再总是打开 ChatGPT 网站提问,来回往返于 Excel 表格之间。

相关代码

Function ChatGPT(prompt As String) As String

Dim url As String, apiKey As String
Dim response As Object, re As String
Dim midString As String

apiKey = "your_api_key"
url = "https://api.openai.com/v1/engines/text-davinci-003/completions"

Set response = CreateObject("MSXML2.XMLHTTP")
response.Open "POST", url, False
response.setRequestHeader "Content-Type", "application/json"
response.setRequestHeader "Authorization", "Bearer " + apiKey
response.Send "{""prompt"":""" & prompt & """,""max_tokens"":1024, ""temperature"":0.1}"

re = response.responseText
midString = Mid(re, InStr(re, """text"":""") + 8)
ChatGPT = Split(midString, """")(0)
ChatGPT = Replace(ChatGPT, "\n", "")

End Function

ChatGPT专题 更多 ChatGPT 教程

🤪 这些值得一看

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

微信扫一扫,分享到朋友圈

将 ChatGPT 接入 Excel 中当函数方法
返回顶部

显示

忘记密码?

显示

显示

获取验证码

Close