我有一个excel里面的vba,想弄成本地问答并输出文档,不会py,请教大神们~
例如txt文本里面有一句话:我的名字叫李明
想用gpt调用这个txt文档里面的内容,根据我写的咒语,提取出来人物叫:李明,输出到姓名txt文件中。
大神们有弄过这种应用吗?- Function ChatGPT(prompt As String, Optional max_token As String) As String
- Dim url As String
- Dim api_key As String
- Dim request_body As String
- Dim response As String
-
-
- url = "网址"
-
-
- api_key = "key"
-
-
- request_body = "prompt=" & prompt & "&api_key=" & api_key & "&max_token=" & max_token
-
-
- 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
复制代码
|