aotrautils 0.0.628 → 0.0.629

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 (30/09/2023-18:45:36)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (02/10/2023-19:46:25)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -5047,6 +5047,80 @@ window.stringifyObject=function(objectToStringify){
5047
5047
 
5048
5048
 
5049
5049
 
5050
+
5051
+ // AI management :
5052
+
5053
+
5054
+
5055
+ class OpenAPIClient{
5056
+
5057
+ construct(modelName, apiURL, agentRole, prompt){
5058
+
5059
+ this.modelName=modelName;
5060
+ this.apiURL=apiURL;
5061
+ this.agentRole=agentRole;
5062
+ this.prompt=prompt;
5063
+
5064
+ }
5065
+
5066
+ getAnswer(AIAPIKey, additionalPrompt){
5067
+
5068
+ const self=this;
5069
+ const messages = [
5070
+ { role: "system", content: this.agentRole },
5071
+ { role: "user", content: this.prompt+additionalPrompt },
5072
+ ];
5073
+
5074
+ async function getResult(){
5075
+ const p=new Promise((accept,reject)=>{
5076
+
5077
+ fetch(self.apiURL, {
5078
+ method: "POST",
5079
+ headers: {
5080
+ "Authorization": "Bearer "+self.apiKey,
5081
+ "Content-Type": "application/json",
5082
+ },
5083
+ body: JSON.stringify({
5084
+ model:self.modelName,
5085
+ messages,
5086
+ }),
5087
+ })
5088
+ .then(response => response.json())
5089
+ .then(data => {
5090
+ // DBG
5091
+ // console.log("data :",data);
5092
+ const assistantReply = data.choices[0].message.content;
5093
+ accept(assistantReply);
5094
+ })
5095
+ .catch(error => {
5096
+ // TRACE
5097
+ console.error("Error:", error);
5098
+ reject(""+error);
5099
+ });
5100
+
5101
+ });
5102
+
5103
+ const r=await p;
5104
+
5105
+ // DBG
5106
+ // console.log("! RESULT text :",r);
5107
+
5108
+ return r;
5109
+ }
5110
+
5111
+ return getResult();
5112
+ }
5113
+
5114
+
5115
+ }
5116
+
5117
+
5118
+
5119
+
5120
+
5121
+
5122
+
5123
+
5050
5124
  // MUST REMAIN AT THE END OF THIS LIBRARY FILE !
5051
5125
 
5052
5126
  AOTRAUTILS_LIB_IS_LOADED=true;
@@ -5054,7 +5128,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
5054
5128
 
5055
5129
 
5056
5130
 
5057
- /*utils CLIENT library associated with aotra version : «1_29072022-2359 (30/09/2023-18:45:36)»*/
5131
+ /*utils CLIENT library associated with aotra version : «1_29072022-2359 (02/10/2023-19:46:25)»*/
5058
5132
  /*-----------------------------------------------------------------------------*/
5059
5133
  /* ## Utility global methods in a browser (htmljs) client environment.
5060
5134
  *
@@ -13289,7 +13363,7 @@ createOritaMicroClient=function(url, port, isNode=false, staticMicroClientIdPara
13289
13363
 
13290
13364
 
13291
13365
 
13292
- /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (30/09/2023-18:45:36)»*/
13366
+ /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (02/10/2023-19:46:25)»*/
13293
13367
  /*-----------------------------------------------------------------------------*/
13294
13368
 
13295
13369
 
@@ -14528,7 +14602,7 @@ function rayVsUnitSphereClosestPoint(p, r) {
14528
14602
  // MUST REMAIN AT THE END OF THIS LIBRARY FILE !
14529
14603
 
14530
14604
  AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
14531
- /*utils SERVER library associated with aotra version : «1_29072022-2359 (30/09/2023-18:45:36)»*/
14605
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (02/10/2023-19:46:25)»*/
14532
14606
  /*-----------------------------------------------------------------------------*/
14533
14607
 
14534
14608
 
aotrautils/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils",
3
- "version": "0.0.628",
3
+ "version": "0.0.629",
4
4
  "main": "aotrautils.build.js",
5
5
  "description": "A library for vanilla javascript utils (client-side) used in aotra javascript CMS",
6
6
  "author": "Jeremie Ratomposon <info@alqemia.com> (https://alqemia.com)",