Allow load script from ChatGPT (LLM based AI) service

This commit is contained in:
Namhyeon Go 2025-01-20 10:04:49 +09:00
parent 1337320803
commit 905b56beb2
2 changed files with 24 additions and 7 deletions

16
app.js
View File

@ -216,8 +216,10 @@ function require(pathname) {
var T = null; var T = null;
var pos = FN.indexOf('://'); var pos = FN.indexOf('://');
if (pos > -1) { if (pos > -1) {
var scheme = FN.substring(0, pos);
// load script from a remote server // load script from a remote server
if (["http", "https"].indexOf(FN.substring(0, pos)) > -1) { if (["http", "https"].indexOf(scheme) > -1) {
require._addScriptProvider(function(url) { require._addScriptProvider(function(url) {
try { try {
return require("lib/http").get(url); return require("lib/http").get(url);
@ -227,6 +229,18 @@ function require(pathname) {
}); });
} }
// load script from ChatGPT (LLM based AI) service
if (["ai"].indexOf(scheme) > -1) {
require._addScriptProvider(function(url) {
try {
return require("lib/chatgpt").get(url);
} catch (e) {
return null;
}
});
}
// if exists the custom script providers
if (require._scriptProviders.length > 0) { if (require._scriptProviders.length > 0) {
var i = 0; var i = 0;
while (T == null && i < require._scriptProviders.length) { while (T == null && i < require._scriptProviders.length) {

View File

@ -25,9 +25,12 @@ function chat(content) {
"Authorization": "Bearer {OPENAI_API_KEY}" "Authorization": "Bearer {OPENAI_API_KEY}"
}) })
.setRequestBody({ .setRequestBody({
"model": "gpt-3.5-turbo", "model": "gpt-4o",
"messages": [ "messages": [
{ {
"role": "developer",
"content": "Write all future code examples in JavaScript ES3 using the exports variable. Respond exclusively in code without blocks."
}, {
"role": "user", "role": "user",
"content": content "content": content
} }