mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-06 15:04: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 FILE = require("lib/file");
|
||||||
var HTTP = require("lib/http");
|
var HTTP = require("lib/http");
|
||||||
|
var APIKEY = require("lib/apikey");
|
||||||
function loadApiKey() {
|
|
||||||
var s = FILE.readFile("data/chatgpt-apikey.txt", FILE.CdoCharset.CdoUTF_8);
|
|
||||||
return s.trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
function chat(content) {
|
function chat(content) {
|
||||||
var s = '';
|
var answers = [];
|
||||||
|
|
||||||
var apikey = loadApiKey();
|
var apikey = APIKEY.getApiKey("chatgpt");
|
||||||
console.log("ChatGPT API KEY:", apikey);
|
console.log("ChatGPT API KEY:", apikey);
|
||||||
|
|
||||||
var response = HTTP.create("MSXML")
|
var response = HTTP.create("MSXML")
|
||||||
|
@ -43,7 +39,9 @@ function chat(content) {
|
||||||
;
|
;
|
||||||
|
|
||||||
if (response.choices.length > 0) {
|
if (response.choices.length > 0) {
|
||||||
s += response.choices[0].message.content;
|
response.choices.forEach(function(x) {
|
||||||
|
answers.push(x.message.content);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
@ -51,7 +49,7 @@ function chat(content) {
|
||||||
|
|
||||||
exports.chat = chat;
|
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.AUTHOR = "abuse@catswords.net";
|
||||||
exports.global = global;
|
exports.global = global;
|
||||||
exports.require = global.require;
|
exports.require = global.require;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user