Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T8 #1018

Merged
merged 15 commits into from
May 15, 2024
252 changes: 127 additions & 125 deletions LICENSES.txt

Large diffs are not rendered by default.

153 changes: 77 additions & 76 deletions js/oafp.js

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions js/openaf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4415,6 +4415,7 @@ var $from = function(a) {
* get(nameOrPath), set(obj, path), setp(obj, path, name)\
* range(count), ranges(count, start, step)\
* inc(name), dec(name), getc(name), unset(obj, name)\
* k2a(map, keyre, outkey, removeNulls), geta(nameOrPath, arrayIndex)\
* \
* Custom functions:\
* $path(2, "example(@)", { example: { _func: (a) => { return Number(a) + 10; }, _signature: [ { types: [ $path().number ] } ] } });\
Expand Down Expand Up @@ -4458,11 +4459,11 @@ const $path = function(aObj, aPath, customFunctions) {
},
search_keys: {
_func: ar => searchKeys(ar[0], ar[1]),
_signature: [ { types: [ jmespath.types.array ] }, { types: [ jmespath.types.string ] } ]
_signature: [ { types: [ jmespath.types.any ] }, { types: [ jmespath.types.string ] } ]
},
search_values: {
_func: ar => searchValues(ar[0], ar[1]),
_signature: [ { types: [ jmespath.types.array ] }, { types: [ jmespath.types.string ] } ]
_signature: [ { types: [ jmespath.types.any ] }, { types: [ jmespath.types.string ] } ]
},
delete: {
_func: ar => { $$(ar[0]).unset(ar[1]); return ar[0] },
Expand Down Expand Up @@ -4749,6 +4750,17 @@ const $path = function(aObj, aPath, customFunctions) {
return ar[0]
},
_signature: [ { types: [ jmespath.types.any ] }, { types: [ jmespath.types.string ] } ]
},
k2a: {
_func: ar => {
ow.loadObj()
return ow.obj.key2array(ar[0], ar[1], ar[2], ar[3])
},
_signature: [ { types: [ jmespath.types.object ] }, { types: [ jmespath.types.string ] }, { types: [ jmespath.types.any ] }, { types: [ jmespath.types.boolean ] } ]
},
geta: {
_func: ar => $$(_locals).get(ar[0])[ar[1]] || $$(aObj).get(ar[0])[ar[1]],
_signature: [ { types: [ jmespath.types.string ] }, { types: [ jmespath.types.number ] } ]
}
}, customFunctions)

Expand Down
22 changes: 16 additions & 6 deletions js/owrap.ai.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,12 @@ OpenWrap.ai.prototype.gpt.prototype.prompt = function(aPrompt, aRole, aModel, aT

/**
* <odoc>
* <key>ow.ai.gpt.promptImage(aPrompt, aImage, aDetailLevel, aRole, aModel, aTemperature) : String</key>
* <key>ow.ai.gpt.promptImage(aPrompt, aImage, aDetailLevel, aRole, aModel, aTemperature, jsonFlag) : String</key>
* Tries to prompt aPrompt (a string or an array of strings) with aImage (a file path or a base64 string representation), aRole (defaults to "user") and aModel (defaults to the one provided on the constructor).
* </odoc>
*/
OpenWrap.ai.prototype.gpt.prototype.promptImage = function(aPrompt, aImage, aDetailLevel, aRole, aModel, aTemperature) {
return this.model.promptImage(aPrompt, aImage, aDetailLevel, aRole, aModel, aTemperature)
OpenWrap.ai.prototype.gpt.prototype.promptImage = function(aPrompt, aImage, aDetailLevel, aRole, aModel, aTemperature, jsonFlag) {
return this.model.promptImage(aPrompt, aImage, aDetailLevel, aRole, aModel, aTemperature, jsonFlag)
}

/**
Expand Down Expand Up @@ -757,12 +757,22 @@ global.$gpt = function(aModel) {
},
/**
* <odoc>
* <key>$gpt.promptImage(aPrompt, aImage, aDetailLevel, aRole, aModel, aTemperature) : String</key>
* <key>$gpt.promptImage(aPrompt, aImage, aDetailLevel, aRole, aModel, aTemperature, jsonFlag) : String</key>
* Tries to prompt aPrompt (a string or an array of strings) with aImage (a file path or a base64 string representation), aRole (defaults to "user") and aModel (defaults to the one provided on the constructor).
* </odoc>
*/
promptImage: (aPrompt, aImage, aDetailLevel, aRole, aModel, aTemperature) => {
return _g.promptImage(aPrompt, aImage, aDetailLevel, aRole, aModel, aTemperature)
promptImage: (aPrompt, aImage, aDetailLevel, aRole, aModel, aTemperature, jsonFlag) => {
return _g.promptImage(aPrompt, aImage, aDetailLevel, aRole, aModel, aTemperature, jsonFlag)
},
/**
* <odoc>
* <key>$gpt.promptImgGen(aPrompt, aModel, aPath) : Array</key>
* Tries to prompt aPrompt and aModel (defaults to the one provided on the constructor) to generate one or more images and aPath to which the number of the image and ".png" will be saved to.
* Returns an array of the image files generated.
* </odoc>
*/
promptImgGen: (aPrompt, aModel, aPath) => {
return _g.promptImgGen(aPrompt, aModel, aPath)
},
/**
* <odoc>
Expand Down
2 changes: 1 addition & 1 deletion js/owrap.ch.js
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ OpenWrap.ch.prototype.__types = {
* - size (Number) Optionally getAll/getKeys to return more than 10 records (up to 10000).\
* - stamp (Map) Optionally merge with stamp map.\
* - timeout (Number) Optional request timeout in ms.\
*
* - preAction (Function) Optional function to be called before every request.\
* \
* The getAll/getKeys functions accept an extra argument to provide a ES query map to restrict the results.
* </odoc>
Expand Down
37 changes: 37 additions & 0 deletions js/owrap.obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,41 @@ OpenWrap.obj.prototype.searchArray = function(anArray, aPartialMap, useRegEx, ig
return subres;
}

/**
* <odoc>
* <key>ow.obj.key2array(aMap, aREMatch, outkey, removeEmptys) : Object</key>
* Given aMap will return an array of values where the keys match the aREMatch regular expression. Optionally
* you can provide an outkey to have return map with a key with the resulting array. If removeEmptys is true it will remove
* any undefined, null or empty values.
* </odoc>
*/
OpenWrap.obj.prototype.key2array = function(aMap, aREMatch, outkey, removeEmptys) {
_$(aMap, "aMap").isMap().$_()
outkey = _$(outkey, "outkey").isString().default(__)
removeEmptys = _$(removeEmptys, "removeEmptys").isBoolean().default(false)

var re = new RegExp(aREMatch)
var res = Object.keys(aMap)
.filter(r => r.match(re))
.sort((a,b) => a.replace(re, "") - b.replace(re, ""))

var _isEmpty = function(a) {
return removeEmptys ? a === undefined || a === null || String(a).trim() === "" : false
}

return res
.map(k => {
if (outkey) {
var v = {}
v[outkey] = aMap[k]
return !_isEmpty(aMap[k]) ? v : undefined
} else {
return aMap[k]
}
})
.filter(e => !_isEmpty(e))
}

/**
* <odoc>
* <key>ow.obj.fromObj2Array(anObj, aKey) : Array</key>
Expand Down Expand Up @@ -1858,6 +1893,8 @@ OpenWrap.obj.prototype.http.prototype.exec = function(aURL, aRequestType, aIn, a
} else {
aBody = Packages.okhttp3.MultipartBody.Builder().setType(Packages.okhttp3.MultipartBody.FORM).addFormDataPart(this.__ufn, this.__uf, Packages.okhttp3.RequestBody.create(isNull(mediaType) ? Packages.okhttp3.MediaType.get("application/octet-stream") : Packages.okhttp3.MediaType.get(mediaType), f)).build()
}
} else {
aBody = Packages.okhttp3.RequestBody.create(Packages.okhttp3.MediaType.get("application/json"), "")
}
}

Expand Down
Binary file removed lib/commons-csv-1.10.0.jar
Binary file not shown.
Binary file added lib/commons-csv-1.11.0.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified lib/js.jar
Binary file not shown.
15 changes: 10 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
</build>

<dependencies>
<dependency>
<groupId>org.mozilla</groupId>
<artifactId>rhino</artifactId>
<version>1.7.15</version>
</dependency>
<dependency>
<groupId>de.vandermeer</groupId>
<artifactId>asciilist-j7</artifactId>
Expand Down Expand Up @@ -85,7 +90,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.10.0</version>
<version>1.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down Expand Up @@ -135,22 +140,22 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.17.0</version>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.17.0</version>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.0</version>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-toml</artifactId>
<version>2.17.0</version>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>org.fusesource.jansi</groupId>
Expand Down
8 changes: 4 additions & 4 deletions versionsAndDeps.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
{
"description": "Rhino",
"path": ["lib/js.jar"],
"version": "1.7.7.2",
"version": "1.7.15",
"changes": false,
"type": ["java"],
"license": "https://raw.githubusercontent.com/mozilla/rhino/master/LICENSE.txt",
Expand Down Expand Up @@ -197,8 +197,8 @@
},
{
"description": "Apache Commons CSV",
"path": ["lib/commons-csv-1.10.jar"],
"version": "1.10",
"path": ["lib/commons-csv-1.11.jar"],
"version": "1.11",
"changes": false,
"type": ["java"],
"license": "https://raw.githubusercontent.com/licenses/license-templates/master/templates/apache.txt",
Expand Down Expand Up @@ -323,7 +323,7 @@
},
{
"description": "Jackson Core",
"path": ["lib/jackson-core-2.16.1.jar"],
"path": ["lib/jackson-core-2.17.1.jar"],
"version": "2.16.1",
"changes": false,
"type": ["java"],
Expand Down
Loading