@truto/truto-jsonata 1.0.7 → 1.0.9
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.
- package/README.md +37 -0
- package/dist/main.cjs +18 -0
- package/dist/main.cjs.map +1 -1
- package/dist/module.js +18 -0
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1819,6 +1819,43 @@ URL {
|
|
|
1819
1819
|
|
|
1820
1820
|
---
|
|
1821
1821
|
|
|
1822
|
+
### AI Stuff
|
|
1823
|
+
|
|
1824
|
+
<details>
|
|
1825
|
+
<summary>generateEmbeddingsCohere(body, api_key)</summary>
|
|
1826
|
+
|
|
1827
|
+
Generate embeddings through Cohere /embed API.
|
|
1828
|
+
|
|
1829
|
+
**Parameters:**
|
|
1830
|
+
|
|
1831
|
+
- **body**: The object similar to what [Cohere's /embed API](https://docs.cohere.com/reference/embed) expects.
|
|
1832
|
+
- **api_key**: Cohere's API Key
|
|
1833
|
+
|
|
1834
|
+
**Example Usage:**
|
|
1835
|
+
|
|
1836
|
+
```javascript
|
|
1837
|
+
import trutoJsonata from '@truto/truto-jsonata';
|
|
1838
|
+
|
|
1839
|
+
const body = {
|
|
1840
|
+
"model": "embed-multilingual-v3.0",
|
|
1841
|
+
"texts": [
|
|
1842
|
+
"hello",
|
|
1843
|
+
"goodbye"
|
|
1844
|
+
],
|
|
1845
|
+
"input_type": "classification",
|
|
1846
|
+
"embedding_types": [
|
|
1847
|
+
"float"
|
|
1848
|
+
]
|
|
1849
|
+
};
|
|
1850
|
+
const api_key = "c7fdd028-d967-456a-9765-be47a7959f7e";
|
|
1851
|
+
const expression = trutoJsonata("$generateEmbeddingsCohere(body, api_key)");
|
|
1852
|
+
expression.evaluate({ body, api_key }).then(result => { console.log(result); });
|
|
1853
|
+
// Output: {"id": "c7fdd028-d967-456a-9765-be47a7959f7e", .....}
|
|
1854
|
+
```
|
|
1855
|
+
|
|
1856
|
+
</details>
|
|
1857
|
+
|
|
1858
|
+
|
|
1822
1859
|
### Miscellaneous
|
|
1823
1860
|
|
|
1824
1861
|
<details>
|
package/dist/main.cjs
CHANGED
|
@@ -1342,6 +1342,23 @@ async function $2c639152271462a6$var$convertMarkdownToHtml(markdown, options) {
|
|
|
1342
1342
|
var $2c639152271462a6$export$2e2bcd8739ae039 = $2c639152271462a6$var$convertMarkdownToHtml;
|
|
1343
1343
|
|
|
1344
1344
|
|
|
1345
|
+
async function $caaee789061bb8bb$var$generateEmbeddingsCohere(body, api_key) {
|
|
1346
|
+
const response = await fetch("https://api.cohere.com/v2/embed", {
|
|
1347
|
+
method: "POST",
|
|
1348
|
+
headers: {
|
|
1349
|
+
accept: "application/json",
|
|
1350
|
+
"content-type": "application/json",
|
|
1351
|
+
"user-agent": "truto",
|
|
1352
|
+
Authorization: `Bearer ${api_key}`
|
|
1353
|
+
},
|
|
1354
|
+
body: JSON.stringify(body)
|
|
1355
|
+
});
|
|
1356
|
+
if (!response.ok) throw new Error(await response.text());
|
|
1357
|
+
return await response.json();
|
|
1358
|
+
}
|
|
1359
|
+
var $caaee789061bb8bb$export$2e2bcd8739ae039 = $caaee789061bb8bb$var$generateEmbeddingsCohere;
|
|
1360
|
+
|
|
1361
|
+
|
|
1345
1362
|
function $af351c41b7fd6f79$export$2e2bcd8739ae039(expression) {
|
|
1346
1363
|
expression.registerFunction("dtFromIso", (0, $bab42b5e4be720d3$export$2e2bcd8739ae039));
|
|
1347
1364
|
expression.registerFunction("base64decode", (0, $77081a2d6d46cd50$export$2e2bcd8739ae039));
|
|
@@ -1377,6 +1394,7 @@ function $af351c41b7fd6f79$export$2e2bcd8739ae039(expression) {
|
|
|
1377
1394
|
expression.registerFunction("sign", (0, $256af523deaf5315$export$2e2bcd8739ae039));
|
|
1378
1395
|
expression.registerFunction("xmlToJs", (0, $d08a44d57b1bb13e$export$2e2bcd8739ae039));
|
|
1379
1396
|
expression.registerFunction("jsToXml", (0, $c7a445cfc49817c1$export$2e2bcd8739ae039));
|
|
1397
|
+
expression.registerFunction("generateEmbeddingsCohere", (0, $caaee789061bb8bb$export$2e2bcd8739ae039));
|
|
1380
1398
|
expression.registerFunction("groupBy", function(array, key) {
|
|
1381
1399
|
return (0, $dxT2C$lodashes.groupBy)((0, $dxT2C$lodashes.castArray)(array), key);
|
|
1382
1400
|
});
|