aotrautils-srv 0.0.701 → 0.0.703

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:45:47)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (21/10/2023-18:58:55)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -5066,65 +5066,12 @@ 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
-
5124
5069
  async launchRequest(AIAPIKey, messages){
5125
5070
 
5126
5071
  const self=this;
5127
- return await fetch(self.apiURL, {
5072
+ const p=new Promise((resolve,reject)=>{
5073
+
5074
+ fetch(self.apiURL, {
5128
5075
  method: "POST",
5129
5076
  headers: {
5130
5077
  "Authorization": "Bearer "+AIAPIKey,
@@ -5151,7 +5098,7 @@ class OpenAIAPIClient{
5151
5098
  const error=data.error;
5152
5099
  // TRACE
5153
5100
  console.error("Error:", error);
5154
- throw new Error(""+error);
5101
+ reject(""+error);
5155
5102
  return;
5156
5103
  }
5157
5104
 
@@ -5159,16 +5106,69 @@ class OpenAIAPIClient{
5159
5106
  console.log("~~~~~~~~~~~data :",data);
5160
5107
 
5161
5108
  const assistantReply = data.choices[0].message.content;
5162
- return assistantReply;
5109
+ resolve(assistantReply);
5163
5110
  })
5164
5111
  .catch(error => {
5165
5112
  // TRACE
5166
5113
  console.error("Error:", error);
5167
- throw new Error(""+error);
5168
- });
5114
+ reject(""+error);
5115
+ });
5169
5116
 
5117
+
5118
+ });
5119
+
5120
+ return p;
5170
5121
  }
5171
5122
 
5123
+
5124
+ // async launchRequest(AIAPIKey, messages){
5125
+ //
5126
+ // const self=this;
5127
+ // return await fetch(self.apiURL, {
5128
+ // method: "POST",
5129
+ // headers: {
5130
+ // "Authorization": "Bearer "+AIAPIKey,
5131
+ // "Content-Type": "application/json",
5132
+ // },
5133
+ // body: JSON.stringify({
5134
+ // model:self.modelName,
5135
+ // messages,
5136
+ // }),
5137
+ // })
5138
+ // // STRANGE : DOES NOT WORK !!:
5139
+ // //.then(response => response.json())
5140
+ // // STRANGE : DOES WORK :
5141
+ // .then(response => {
5142
+ //
5143
+ // // DBG
5144
+ // console.log("~~~~~~~~~~~response :",response);
5145
+ //
5146
+ // return response.json();
5147
+ // })
5148
+ // .then(data => {
5149
+ //
5150
+ // if(data.error){
5151
+ // const error=data.error;
5152
+ // // TRACE
5153
+ // console.error("Error:", error);
5154
+ // throw new Error(""+error);
5155
+ // return;
5156
+ // }
5157
+ //
5158
+ // // DBG
5159
+ // console.log("~~~~~~~~~~~data :",data);
5160
+ //
5161
+ // const assistantReply = data.choices[0].message.content;
5162
+ // return assistantReply;
5163
+ // })
5164
+ // .catch(error => {
5165
+ // // TRACE
5166
+ // console.error("Error:", error);
5167
+ // throw new Error(""+error);
5168
+ // });
5169
+ //
5170
+ // }
5171
+
5172
5172
  }
5173
5173
 
5174
5174
 
@@ -5189,7 +5189,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
5189
5189
 
5190
5190
 
5191
5191
 
5192
- /*utils SERVER library associated with aotra version : «1_29072022-2359 (21/10/2023-18:45:47)»*/
5192
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (21/10/2023-18:58:55)»*/
5193
5193
  /*-----------------------------------------------------------------------------*/
5194
5194
 
5195
5195
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.701",
3
+ "version": "0.0.703",
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)",