aotrautils-srv 0.0.909 → 0.0.910
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (07/04/2024-
|
|
3
|
+
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (07/04/2024-16:01:40)»*/
|
|
4
4
|
/*-----------------------------------------------------------------------------*/
|
|
5
5
|
|
|
6
6
|
|
|
@@ -5211,54 +5211,98 @@ class OpenAIAPIClient{
|
|
|
5211
5211
|
lognow("! launchRequest messages :",messages);
|
|
5212
5212
|
|
|
5213
5213
|
|
|
5214
|
+
const headers={
|
|
5215
|
+
"Authorization": "Bearer "+AIAPIKey,
|
|
5216
|
+
"Content-Type": "application/json",
|
|
5217
|
+
};
|
|
5218
|
+
const parameters={
|
|
5219
|
+
model:self.modelName,
|
|
5220
|
+
messages,
|
|
5221
|
+
};
|
|
5222
|
+
|
|
5214
5223
|
const self=this;
|
|
5215
|
-
return
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
// TRACE
|
|
5243
|
-
console.error("Error:", error);
|
|
5244
|
-
reject(""+error);
|
|
5245
|
-
return;
|
|
5246
|
-
}
|
|
5247
|
-
|
|
5248
|
-
// DBG
|
|
5249
|
-
console.log("~~~~~~~~~~~data :",data);
|
|
5250
|
-
|
|
5251
|
-
const assistantReply = data.choices[0].message.content;
|
|
5252
|
-
resolve(assistantReply);
|
|
5253
|
-
})
|
|
5254
|
-
.catch(error => {
|
|
5255
|
-
// TRACE
|
|
5256
|
-
console.error("Error:", error);
|
|
5257
|
-
reject(""+error);
|
|
5258
|
-
});
|
|
5259
|
-
|
|
5260
|
-
|
|
5224
|
+
return performHTTPRequestNode(self.apiURL,"POST",headers,parameters).then((responseObj)=>{
|
|
5225
|
+
const responseData=responseObj.responseData;
|
|
5226
|
+
//const response=responseObj.response;
|
|
5227
|
+
//const responseDataStr=responseObj.responseDataStr;
|
|
5228
|
+
const dataLocal=responseData;
|
|
5229
|
+
doOnIncomingMessageForResponse(dataLocal);
|
|
5230
|
+
}).then(response=>{
|
|
5231
|
+
|
|
5232
|
+
// DBG
|
|
5233
|
+
console.log("~~~~~~~~~~~response :",response);
|
|
5234
|
+
|
|
5235
|
+
const data=response;
|
|
5236
|
+
if(data.error){
|
|
5237
|
+
const error=data.error;
|
|
5238
|
+
// TRACE
|
|
5239
|
+
console.error("Error:", error);
|
|
5240
|
+
throw new Error(`${error}`);
|
|
5241
|
+
}
|
|
5242
|
+
|
|
5243
|
+
const assistantReply = data.choices[0].message.content;
|
|
5244
|
+
// DBG
|
|
5245
|
+
console.log("~~~~~~~~~~~assistantReply :",assistantReply);
|
|
5246
|
+
return assistantReply;
|
|
5247
|
+
}).catch(error => {
|
|
5248
|
+
// TRACE
|
|
5249
|
+
console.error("Error:", error);
|
|
5250
|
+
reject(""+error);
|
|
5261
5251
|
});
|
|
5252
|
+
|
|
5253
|
+
|
|
5254
|
+
|
|
5255
|
+
|
|
5256
|
+
|
|
5257
|
+
// return new Promise((resolve,reject)=>{
|
|
5258
|
+
//
|
|
5259
|
+
// fetch(self.apiURL, {
|
|
5260
|
+
// method: "POST",
|
|
5261
|
+
// headers: {
|
|
5262
|
+
// "Authorization": "Bearer "+AIAPIKey,
|
|
5263
|
+
// "Content-Type": "application/json",
|
|
5264
|
+
// },
|
|
5265
|
+
// body: JSON.stringify({
|
|
5266
|
+
// model:self.modelName,
|
|
5267
|
+
// messages,
|
|
5268
|
+
// }),
|
|
5269
|
+
// })
|
|
5270
|
+
// // STRANGE : DOES NOT WORK !!:
|
|
5271
|
+
// //.then(response => response.json())
|
|
5272
|
+
// // STRANGE : DOES WORK :
|
|
5273
|
+
// .then(response => {
|
|
5274
|
+
//
|
|
5275
|
+
// // DBG
|
|
5276
|
+
// console.log("~~~~~~~~~~~response :",response);
|
|
5277
|
+
//
|
|
5278
|
+
// return response.json();
|
|
5279
|
+
// })
|
|
5280
|
+
// .then(data => {
|
|
5281
|
+
//
|
|
5282
|
+
// if(data.error){
|
|
5283
|
+
// const error=data.error;
|
|
5284
|
+
// // TRACE
|
|
5285
|
+
// console.error("Error:", error);
|
|
5286
|
+
// reject(""+error);
|
|
5287
|
+
// return;
|
|
5288
|
+
// }
|
|
5289
|
+
//
|
|
5290
|
+
// // DBG
|
|
5291
|
+
// console.log("~~~~~~~~~~~data :",data);
|
|
5292
|
+
//
|
|
5293
|
+
// const assistantReply = data.choices[0].message.content;
|
|
5294
|
+
// resolve(assistantReply);
|
|
5295
|
+
// })
|
|
5296
|
+
// .catch(error => {
|
|
5297
|
+
// // TRACE
|
|
5298
|
+
// console.error("Error:", error);
|
|
5299
|
+
// reject(""+error);
|
|
5300
|
+
// });
|
|
5301
|
+
// });
|
|
5302
|
+
|
|
5303
|
+
|
|
5304
|
+
|
|
5305
|
+
|
|
5262
5306
|
}
|
|
5263
5307
|
|
|
5264
5308
|
|
|
@@ -5284,7 +5328,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
|
|
|
5284
5328
|
|
|
5285
5329
|
|
|
5286
5330
|
|
|
5287
|
-
/*utils SERVER library associated with aotra version : «1_29072022-2359 (07/04/2024-
|
|
5331
|
+
/*utils SERVER library associated with aotra version : «1_29072022-2359 (07/04/2024-16:01:40)»*/
|
|
5288
5332
|
/*-----------------------------------------------------------------------------*/
|
|
5289
5333
|
|
|
5290
5334
|
|
aotrautils-srv/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils-srv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.910",
|
|
4
4
|
"main": "aotrautils-srv.build.js",
|
|
5
5
|
"description": "A library for vanilla javascript utils (server-side) used in aotra javascript CMS",
|
|
6
6
|
"author": "Jeremie Ratomposon <info@alqemia.com> (https://alqemia.com)",
|