aotrautils-srv 0.0.698 → 0.0.699

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 (21/10/2023-18:33:20)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (21/10/2023-18:42:17)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -5066,12 +5066,65 @@ class OpenAIAPIClient{
5066
5066
  }
5067
5067
 
5068
5068
 
5069
+ // launchRequest(AIAPIKey, messages){
5070
+ //
5071
+ // const self=this;
5072
+ // const p=new Promise((resolve,reject)=>{
5073
+ //
5074
+ // fetch(self.apiURL, {
5075
+ // method: "POST",
5076
+ // headers: {
5077
+ // "Authorization": "Bearer "+AIAPIKey,
5078
+ // "Content-Type": "application/json",
5079
+ // },
5080
+ // body: JSON.stringify({
5081
+ // model:self.modelName,
5082
+ // messages,
5083
+ // }),
5084
+ // })
5085
+ // // STRANGE : DOES NOT WORK !!:
5086
+ // //.then(response => response.json())
5087
+ // // STRANGE : DOES WORK :
5088
+ // .then(response => {
5089
+ //
5090
+ // // DBG
5091
+ // console.log("~~~~~~~~~~~response :",response);
5092
+ //
5093
+ // return response.json();
5094
+ // })
5095
+ // .then(data => {
5096
+ //
5097
+ // if(data.error){
5098
+ // const error=data.error;
5099
+ // // TRACE
5100
+ // console.error("Error:", error);
5101
+ // reject(""+error);
5102
+ // return;
5103
+ // }
5104
+ //
5105
+ // // DBG
5106
+ // console.log("~~~~~~~~~~~data :",data);
5107
+ //
5108
+ // const assistantReply = data.choices[0].message.content;
5109
+ // resolve(assistantReply);
5110
+ // })
5111
+ // .catch(error => {
5112
+ // // TRACE
5113
+ // console.error("Error:", error);
5114
+ // reject(""+error);
5115
+ // });
5116
+ //
5117
+ //
5118
+ // });
5119
+ //
5120
+ // return p;
5121
+ // }
5122
+
5123
+
5069
5124
  launchRequest(AIAPIKey, messages){
5070
5125
 
5071
5126
  const self=this;
5072
- const p=new Promise((resolve,reject)=>{
5073
-
5074
- fetch(self.apiURL, {
5127
+ return fetch(self.apiURL, {
5075
5128
  method: "POST",
5076
5129
  headers: {
5077
5130
  "Authorization": "Bearer "+AIAPIKey,
@@ -5098,7 +5151,7 @@ class OpenAIAPIClient{
5098
5151
  const error=data.error;
5099
5152
  // TRACE
5100
5153
  console.error("Error:", error);
5101
- reject(""+error);
5154
+ throw new Error(""+error);
5102
5155
  return;
5103
5156
  }
5104
5157
 
@@ -5106,21 +5159,16 @@ class OpenAIAPIClient{
5106
5159
  console.log("~~~~~~~~~~~data :",data);
5107
5160
 
5108
5161
  const assistantReply = data.choices[0].message.content;
5109
- resolve(assistantReply);
5162
+ return assistantReply;
5110
5163
  })
5111
5164
  .catch(error => {
5112
5165
  // TRACE
5113
5166
  console.error("Error:", error);
5114
- reject(""+error);
5115
- });
5116
-
5167
+ throw new Error(""+error);
5168
+ });
5117
5169
 
5118
- });
5119
-
5120
- return p;
5121
5170
  }
5122
5171
 
5123
-
5124
5172
  }
5125
5173
 
5126
5174
 
@@ -5141,7 +5189,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
5141
5189
 
5142
5190
 
5143
5191
 
5144
- /*utils SERVER library associated with aotra version : «1_29072022-2359 (21/10/2023-18:33:20)»*/
5192
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (21/10/2023-18:42:17)»*/
5145
5193
  /*-----------------------------------------------------------------------------*/
5146
5194
 
5147
5195
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.698",
3
+ "version": "0.0.699",
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)",