Update chatgpt.js

This commit is contained in:
Namhyeon Go 2024-12-27 14:52:17 +09:00 committed by GitHub
parent e9ba3cff96
commit 46c5a91032
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;