mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-06 06:54:58 +00:00
Allow load script from ChatGPT (LLM based AI) service
This commit is contained in:
parent
1337320803
commit
905b56beb2
16
app.js
16
app.js
|
@ -216,8 +216,10 @@ function require(pathname) {
|
|||
var T = null;
|
||||
var pos = FN.indexOf('://');
|
||||
if (pos > -1) {
|
||||
var scheme = FN.substring(0, pos);
|
||||
|
||||
// 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) {
|
||||
try {
|
||||
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) {
|
||||
var i = 0;
|
||||
while (T == null && i < require._scriptProviders.length) {
|
||||
|
|
|
@ -25,12 +25,15 @@ function chat(content) {
|
|||
"Authorization": "Bearer {OPENAI_API_KEY}"
|
||||
})
|
||||
.setRequestBody({
|
||||
"model": "gpt-3.5-turbo",
|
||||
"model": "gpt-4o",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": content
|
||||
}
|
||||
{
|
||||
"role": "developer",
|
||||
"content": "Write all future code examples in JavaScript ES3 using the exports variable. Respond exclusively in code without blocks."
|
||||
}, {
|
||||
"role": "user",
|
||||
"content": content
|
||||
}
|
||||
]
|
||||
})
|
||||
.open("post", "https://api.openai.com/v1/chat/completions")
|
||||
|
|
Loading…
Reference in New Issue
Block a user