mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-06 06:54:58 +00:00
Update chatgpt.js
This commit is contained in:
parent
e9ba3cff96
commit
46c5a91032
|
@ -8,16 +8,12 @@
|
|||
//
|
||||
var FILE = require("lib/file");
|
||||
var HTTP = require("lib/http");
|
||||
|
||||
function loadApiKey() {
|
||||
var s = FILE.readFile("data/chatgpt-apikey.txt", FILE.CdoCharset.CdoUTF_8);
|
||||
return s.trim();
|
||||
}
|
||||
var APIKEY = require("lib/apikey");
|
||||
|
||||
function chat(content) {
|
||||
var s = '';
|
||||
|
||||
var apikey = loadApiKey();
|
||||
var answers = [];
|
||||
|
||||
var apikey = APIKEY.getApiKey("chatgpt");
|
||||
console.log("ChatGPT API KEY:", apikey);
|
||||
|
||||
var response = HTTP.create("MSXML")
|
||||
|
@ -43,7 +39,9 @@ function chat(content) {
|
|||
;
|
||||
|
||||
if (response.choices.length > 0) {
|
||||
s += response.choices[0].message.content;
|
||||
response.choices.forEach(function(x) {
|
||||
answers.push(x.message.content);
|
||||
});
|
||||
}
|
||||
|
||||
return s;
|
||||
|
@ -51,7 +49,7 @@ function chat(content) {
|
|||
|
||||
exports.chat = chat;
|
||||
|
||||
exports.VERSIONINFO = "ChatGPT interface (chatgpt.js) version 0.1";
|
||||
exports.VERSIONINFO = "ChatGPT interface (chatgpt.js) version 0.1.1";
|
||||
exports.AUTHOR = "abuse@catswords.net";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user