aotrautils-srv 0.0.646 → 0.0.648

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 (19/10/2023-23:30:06)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (19/10/2023-23:59:24)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -5034,12 +5034,10 @@ window.stringifyObject=function(objectToStringify){
5034
5034
  class OpenAIAPIClient{
5035
5035
 
5036
5036
  construct(modelName, apiURL, agentRole, prompt){
5037
-
5038
5037
  this.modelName=modelName;
5039
5038
  this.apiURL=apiURL;
5040
5039
  this.agentRole=agentRole;
5041
5040
  this.prompt=prompt;
5042
-
5043
5041
  }
5044
5042
 
5045
5043
  getAnswer(AIAPIKey, additionalPrompt){
@@ -5050,7 +5048,10 @@ class OpenAIAPIClient{
5050
5048
  { role: "user", content: (this.prompt + additionalPrompt) },
5051
5049
  ];
5052
5050
 
5053
- async function getResult(){
5051
+ //DBG
5052
+ lognow("!!!!!!self.apiURL:",self.apiURL);
5053
+ /*
5054
+ const result=()=>{
5054
5055
  const p=new Promise((resolve,reject)=>{
5055
5056
 
5056
5057
  fetch(self.apiURL, {
@@ -5064,30 +5065,25 @@ class OpenAIAPIClient{
5064
5065
  messages,
5065
5066
  }),
5066
5067
  })
5067
- .then(response => response.json())
5068
- .then(data => {
5069
- // DBG
5070
- // console.log("data :",data);
5071
- const assistantReply = data.choices[0].message.content;
5072
- resolve(assistantReply);
5073
- })
5074
- .catch(error => {
5075
- // TRACE
5076
- console.error("Error:", error);
5077
- reject(""+error);
5078
- });
5079
-
5080
- });
5081
-
5082
- const r=await p;
5068
+ .then(response => response.json())
5069
+ .then(data => {
5070
+ // DBG
5071
+ // console.log("data :",data);
5072
+ const assistantReply = data.choices[0].message.content;
5073
+ resolve(assistantReply);
5074
+ })
5075
+ .catch(error => {
5076
+ // TRACE
5077
+ console.error("Error:", error);
5078
+ reject(""+error);
5079
+ });
5083
5080
 
5081
+ }();
5082
+
5084
5083
  // DBG
5085
- // console.log("! RESULT text :",r);
5086
-
5087
- return r;
5088
- }
5089
-
5090
- return getResult();
5084
+ console.log("! RESULT text :",result);
5085
+ */
5086
+ return result;
5091
5087
  }
5092
5088
 
5093
5089
 
@@ -5096,6 +5092,10 @@ class OpenAIAPIClient{
5096
5092
 
5097
5093
  // Nodejs compatibility :
5098
5094
  getOpenAIAPIClient=(modelName, apiURL, agentRole, prompt)=>{
5095
+
5096
+ // DBG
5097
+ lognow(`TEST : ${modelName}, ${apiUR}L, ${agentRole}, ${prompt}.`)
5098
+
5099
5099
  return new OpenAIAPIClient(modelName, apiURL, agentRole, prompt);
5100
5100
  };
5101
5101
 
@@ -5111,7 +5111,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
5111
5111
 
5112
5112
 
5113
5113
 
5114
- /*utils SERVER library associated with aotra version : «1_29072022-2359 (19/10/2023-23:30:06)»*/
5114
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (19/10/2023-23:59:24)»*/
5115
5115
  /*-----------------------------------------------------------------------------*/
5116
5116
 
5117
5117
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.646",
3
+ "version": "0.0.648",
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)",