如何集成到Excel中?
eric0id opened this issue · comments
试用了很多不同的方式部署,还是这个最简单响应也快。按教程已经添加了APIkey并可以直接通过网站交互。想集成到Excel中使用,试了好几种办法都不能实现,小白求教~~
网络上有一种比较接近的方式(如下),但是尝试返回的并不是回答的内容。。
在模块中添加:
Function ChatGPTXR(prompt As String) As String
Dim url As String
Dim api_key As String
Dim request_body As String
Dim response As String
' ChatGPT API URL
url = "https://gpt.sinraytec.cn/chatgpt.php"
' ChatGPT API密钥
api_key = "xxxxxxxxxxxxxxxxxxxxxx"
' 设置请求体
request_body = "prompt=" & prompt & "&api_key=" & api_key
' 发送POST请求
With CreateObject("MSXML2.XMLHTTP")
.Open "POST", url, False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send request_body
response = .responseText
End With
' 输出回答
ChatGPTXR = response
End Function
谢谢!