mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-06 06:54:58 +00:00
Update language-inference-engine.js
This commit is contained in:
parent
df92b4c58e
commit
ab2f3df4ea
|
@ -9,8 +9,9 @@
|
||||||
// - Anthropic: https://www.anthropic.com/legal/privacy
|
// - Anthropic: https://www.anthropic.com/legal/privacy
|
||||||
// - Groq: https://groq.com/privacy-policy/
|
// - Groq: https://groq.com/privacy-policy/
|
||||||
// - xAI: https://x.ai/legal/privacy-policy
|
// - xAI: https://x.ai/legal/privacy-policy
|
||||||
|
// - Google Gemini: https://developers.google.com/idx/support/privacy
|
||||||
// - DeepSeek: https://chat.deepseek.com/downloads/DeepSeek%20Privacy%20Policy.html
|
// - DeepSeek: https://chat.deepseek.com/downloads/DeepSeek%20Privacy%20Policy.html
|
||||||
//
|
//
|
||||||
var HTTP = require("lib/http");
|
var HTTP = require("lib/http");
|
||||||
var CRED = require("lib/credentials");
|
var CRED = require("lib/credentials");
|
||||||
|
|
||||||
|
@ -43,6 +44,7 @@ var engineProfiles = {
|
||||||
} else {
|
} else {
|
||||||
return response.choices.reduce(function(a, x) {
|
return response.choices.reduce(function(a, x) {
|
||||||
a.push(x.message.content);
|
a.push(x.message.content);
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}, []);
|
}, []);
|
||||||
}
|
}
|
||||||
|
@ -81,6 +83,7 @@ var engineProfiles = {
|
||||||
} else {
|
} else {
|
||||||
a.push("Not supported type: " + x.type);
|
a.push("Not supported type: " + x.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}, []);
|
}, []);
|
||||||
}
|
}
|
||||||
|
@ -113,6 +116,7 @@ var engineProfiles = {
|
||||||
} else {
|
} else {
|
||||||
return response.choices.reduce(function(a, x) {
|
return response.choices.reduce(function(a, x) {
|
||||||
a.push(x.message.content);
|
a.push(x.message.content);
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}, []);
|
}, []);
|
||||||
}
|
}
|
||||||
|
@ -142,10 +146,48 @@ var engineProfiles = {
|
||||||
"callback": function(response) {
|
"callback": function(response) {
|
||||||
return response.choices.reduce(function(a, x) {
|
return response.choices.reduce(function(a, x) {
|
||||||
a.push(x.message.content);
|
a.push(x.message.content);
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}, []);
|
}, []);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"google": {
|
||||||
|
"headers": {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": "Bearer {apikey}"
|
||||||
|
},
|
||||||
|
"url": "https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={apikey}",
|
||||||
|
"warp": function(model, message) {
|
||||||
|
return {
|
||||||
|
"contents": [
|
||||||
|
{
|
||||||
|
"parts": [
|
||||||
|
{
|
||||||
|
"text": message
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"callback": function(response) {
|
||||||
|
if ("error" in response) {
|
||||||
|
return ["Error: " + response.error.message];
|
||||||
|
} else {
|
||||||
|
return response.candidates.reduce(function(a, x) {
|
||||||
|
x.content.parts.forEach(function(part) {
|
||||||
|
if ("text" in part) {
|
||||||
|
a.push(part.text);
|
||||||
|
} else {
|
||||||
|
a.push("Not supported type");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return a;
|
||||||
|
}, []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"deepseek": {
|
"deepseek": {
|
||||||
"headers": {
|
"headers": {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
@ -173,6 +215,7 @@ var engineProfiles = {
|
||||||
} else {
|
} else {
|
||||||
return response.choices.reduce(function(a, x) {
|
return response.choices.reduce(function(a, x) {
|
||||||
a.push(x.message.content);
|
a.push(x.message.content);
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}, []);
|
}, []);
|
||||||
}
|
}
|
||||||
|
@ -218,9 +261,8 @@ function LanguageInferenceEngine() {
|
||||||
var wrap = this.engineProfile.wrap;
|
var wrap = this.engineProfile.wrap;
|
||||||
var url = this.engineProfile.url;
|
var url = this.engineProfile.url;
|
||||||
var callback = this.engineProfile.callback;
|
var callback = this.engineProfile.callback;
|
||||||
|
|
||||||
return callback(
|
var response = HTTP.create("MSXML")
|
||||||
HTTP.create("MSXML")
|
|
||||||
.setVariables({
|
.setVariables({
|
||||||
"apikey": apikey
|
"apikey": apikey
|
||||||
})
|
})
|
||||||
|
@ -228,8 +270,9 @@ function LanguageInferenceEngine() {
|
||||||
.setRequestBody(wrap(message))
|
.setRequestBody(wrap(message))
|
||||||
.open("post", url)
|
.open("post", url)
|
||||||
.send()
|
.send()
|
||||||
.responseBody
|
.responseBody;
|
||||||
);
|
|
||||||
|
return callback(response);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +281,7 @@ exports.create = function() {
|
||||||
return new LanguageInferenceEngine();
|
return new LanguageInferenceEngine();
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.VERSIONINFO = "Language Inference Engine (NLP/LLM) integration version 0.1";
|
exports.VERSIONINFO = "Language Inference Engine (NLP/LLM) integration 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