Update language-inference-engine.js

This commit is contained in:
Namhyeon Go 2025-01-28 00:02:22 +09:00
parent df92b4c58e
commit ab2f3df4ea

View File

@ -9,6 +9,7 @@
// - Anthropic: https://www.anthropic.com/legal/privacy
// - Groq: https://groq.com/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
//
var HTTP = require("lib/http");
@ -43,6 +44,7 @@ var engineProfiles = {
} else {
return response.choices.reduce(function(a, x) {
a.push(x.message.content);
return a;
}, []);
}
@ -81,6 +83,7 @@ var engineProfiles = {
} else {
a.push("Not supported type: " + x.type);
}
return a;
}, []);
}
@ -113,6 +116,7 @@ var engineProfiles = {
} else {
return response.choices.reduce(function(a, x) {
a.push(x.message.content);
return a;
}, []);
}
@ -142,10 +146,48 @@ var engineProfiles = {
"callback": function(response) {
return response.choices.reduce(function(a, x) {
a.push(x.message.content);
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": {
"headers": {
"Content-Type": "application/json",
@ -173,6 +215,7 @@ var engineProfiles = {
} else {
return response.choices.reduce(function(a, x) {
a.push(x.message.content);
return a;
}, []);
}
@ -219,8 +262,7 @@ function LanguageInferenceEngine() {
var url = this.engineProfile.url;
var callback = this.engineProfile.callback;
return callback(
HTTP.create("MSXML")
var response = HTTP.create("MSXML")
.setVariables({
"apikey": apikey
})
@ -228,8 +270,9 @@ function LanguageInferenceEngine() {
.setRequestBody(wrap(message))
.open("post", url)
.send()
.responseBody
);
.responseBody;
return callback(response);
};
}
@ -238,7 +281,7 @@ exports.create = function() {
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.global = global;
exports.require = global.require;