Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0360f2493d | |||
| 0172887877 | |||
| 8f89f5e3cf | |||
| 5bd41f8c6a | |||
| e4399e1b7b | |||
| ad1ee48763 | |||
| 3ed206923f | |||
| 22d5427e86 | |||
| 43b53164c0 | |||
| 575fbac099 | |||
| 46ae0f7913 | |||
| 54730a2b9a | |||
| 27506d20af | |||
| 8c64129200 | |||
| 013aa942c0 | |||
| c8d5660b1a | |||
| f2c66b0cb8 | |||
| cda7db4f45 | |||
| d71a6be120 |
@@ -75,6 +75,7 @@ A TypeScript library that provides a unified interface for working with multiple
|
|||||||
|
|
||||||
#### Instructions
|
#### Instructions
|
||||||
1. Install the package: `npm i @ztimson/ai-utils`
|
1. Install the package: `npm i @ztimson/ai-utils`
|
||||||
|
2. For speaker diarization: `pip install pyannote.audio`
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
@@ -90,8 +91,9 @@ A TypeScript library that provides a unified interface for working with multiple
|
|||||||
|
|
||||||
#### Instructions
|
#### Instructions
|
||||||
1. Install the dependencies: `npm i`
|
1. Install the dependencies: `npm i`
|
||||||
2. Build library: `npm build`
|
2. For speaker diarization: `pip install pyannote.audio`
|
||||||
3. Run unit tests: `npm test`
|
3. Build library: `npm build`
|
||||||
|
4. Run unit tests: `npm test`
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|||||||
337
package-lock.json
generated
337
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@ztimson/ai-utils",
|
"name": "@ztimson/ai-utils",
|
||||||
"version": "0.4.0",
|
"version": "0.6.4",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@ztimson/ai-utils",
|
"name": "@ztimson/ai-utils",
|
||||||
"version": "0.4.0",
|
"version": "0.6.4",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@anthropic-ai/sdk": "^0.67.0",
|
"@anthropic-ai/sdk": "^0.67.0",
|
||||||
@@ -16,7 +16,8 @@
|
|||||||
"@ztimson/utils": "^0.27.9",
|
"@ztimson/utils": "^0.27.9",
|
||||||
"cheerio": "^1.2.0",
|
"cheerio": "^1.2.0",
|
||||||
"openai": "^6.6.0",
|
"openai": "^6.6.0",
|
||||||
"tesseract.js": "^6.0.1"
|
"tesseract.js": "^6.0.1",
|
||||||
|
"wavefile": "^11.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^24.8.1",
|
"@types/node": "^24.8.1",
|
||||||
@@ -106,9 +107,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/aix-ppc64": {
|
"node_modules/@esbuild/aix-ppc64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.3.tgz",
|
||||||
"integrity": "sha512-GZMB+a0mOMZs4MpDbj8RJp4cw+w1WV5NYD6xzgvzUJ5Ek2jerwfO2eADyI6ExDSUED+1X8aMbegahsJi+8mgpw==",
|
"integrity": "sha512-9fJMTNFTWZMh5qwrBItuziu834eOCUcEqymSH7pY+zoMVEZg3gcPuBNxH1EvfVYe9h0x/Ptw8KBzv7qxb7l8dg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ppc64"
|
"ppc64"
|
||||||
],
|
],
|
||||||
@@ -123,9 +124,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/android-arm": {
|
"node_modules/@esbuild/android-arm": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.3.tgz",
|
||||||
"integrity": "sha512-DVNI8jlPa7Ujbr1yjU2PfUSRtAUZPG9I1RwW4F4xFB1Imiu2on0ADiI/c3td+KmDtVKNbi+nffGDQMfcIMkwIA==",
|
"integrity": "sha512-i5D1hPY7GIQmXlXhs2w8AWHhenb00+GxjxRncS2ZM7YNVGNfaMxgzSGuO8o8SJzRc/oZwU2bcScvVERk03QhzA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm"
|
"arm"
|
||||||
],
|
],
|
||||||
@@ -140,9 +141,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/android-arm64": {
|
"node_modules/@esbuild/android-arm64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.3.tgz",
|
||||||
"integrity": "sha512-pvz8ZZ7ot/RBphf8fv60ljmaoydPU12VuXHImtAs0XhLLw+EXBi2BLe3OYSBslR4rryHvweW5gmkKFwTiFy6KA==",
|
"integrity": "sha512-YdghPYUmj/FX2SYKJ0OZxf+iaKgMsKHVPF1MAq/P8WirnSpCStzKJFjOjzsW0QQ7oIAiccHdcqjbHmJxRb/dmg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -157,9 +158,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/android-x64": {
|
"node_modules/@esbuild/android-x64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.3.tgz",
|
||||||
"integrity": "sha512-z8Ank4Byh4TJJOh4wpz8g2vDy75zFL0TlZlkUkEwYXuPSgX8yzep596n6mT7905kA9uHZsf/o2OJZubl2l3M7A==",
|
"integrity": "sha512-IN/0BNTkHtk8lkOM8JWAYFg4ORxBkZQf9zXiEOfERX/CzxW3Vg1ewAhU7QSWQpVIzTW+b8Xy+lGzdYXV6UZObQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -174,9 +175,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/darwin-arm64": {
|
"node_modules/@esbuild/darwin-arm64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.3.tgz",
|
||||||
"integrity": "sha512-davCD2Zc80nzDVRwXTcQP/28fiJbcOwvdolL0sOiOsbwBa72kegmVU0Wrh1MYrbuCL98Omp5dVhQFWRKR2ZAlg==",
|
"integrity": "sha512-Re491k7ByTVRy0t3EKWajdLIr0gz2kKKfzafkth4Q8A5n1xTHrkqZgLLjFEHVD+AXdUGgQMq+Godfq45mGpCKg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -191,9 +192,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/darwin-x64": {
|
"node_modules/@esbuild/darwin-x64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.3.tgz",
|
||||||
"integrity": "sha512-ZxtijOmlQCBWGwbVmwOF/UCzuGIbUkqB1faQRf5akQmxRJ1ujusWsb3CVfk/9iZKr2L5SMU5wPBi1UWbvL+VQA==",
|
"integrity": "sha512-vHk/hA7/1AckjGzRqi6wbo+jaShzRowYip6rt6q7VYEDX4LEy1pZfDpdxCBnGtl+A5zq8iXDcyuxwtv3hNtHFg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -208,9 +209,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/freebsd-arm64": {
|
"node_modules/@esbuild/freebsd-arm64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.3.tgz",
|
||||||
"integrity": "sha512-lS/9CN+rgqQ9czogxlMcBMGd+l8Q3Nj1MFQwBZJyoEKI50XGxwuzznYdwcav6lpOGv5BqaZXqvBSiB/kJ5op+g==",
|
"integrity": "sha512-ipTYM2fjt3kQAYOvo6vcxJx3nBYAzPjgTCk7QEgZG8AUO3ydUhvelmhrbOheMnGOlaSFUoHXB6un+A7q4ygY9w==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -225,9 +226,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/freebsd-x64": {
|
"node_modules/@esbuild/freebsd-x64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.3.tgz",
|
||||||
"integrity": "sha512-tAfqtNYb4YgPnJlEFu4c212HYjQWSO/w/h/lQaBK7RbwGIkBOuNKQI9tqWzx7Wtp7bTPaGC6MJvWI608P3wXYA==",
|
"integrity": "sha512-dDk0X87T7mI6U3K9VjWtHOXqwAMJBNN2r7bejDsc+j03SEjtD9HrOl8gVFByeM0aJksoUuUVU9TBaZa2rgj0oA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -242,9 +243,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-arm": {
|
"node_modules/@esbuild/linux-arm": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.3.tgz",
|
||||||
"integrity": "sha512-vWfq4GaIMP9AIe4yj1ZUW18RDhx6EPQKjwe7n8BbIecFtCQG4CfHGaHuh7fdfq+y3LIA2vGS/o9ZBGVxIDi9hw==",
|
"integrity": "sha512-s6nPv2QkSupJwLYyfS+gwdirm0ukyTFNl3KTgZEAiJDd+iHZcbTPPcWCcRYH+WlNbwChgH2QkE9NSlNrMT8Gfw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm"
|
"arm"
|
||||||
],
|
],
|
||||||
@@ -259,9 +260,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-arm64": {
|
"node_modules/@esbuild/linux-arm64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.3.tgz",
|
||||||
"integrity": "sha512-hYxN8pr66NsCCiRFkHUAsxylNOcAQaxSSkHMMjcpx0si13t1LHFphxJZUiGwojB1a/Hd5OiPIqDdXONia6bhTw==",
|
"integrity": "sha512-sZOuFz/xWnZ4KH3YfFrKCf1WyPZHakVzTiqji3WDc0BCl2kBwiJLCXpzLzUBLgmp4veFZdvN5ChW4Eq/8Fc2Fg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -276,9 +277,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-ia32": {
|
"node_modules/@esbuild/linux-ia32": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.3.tgz",
|
||||||
"integrity": "sha512-MJt5BRRSScPDwG2hLelYhAAKh9imjHK5+NE/tvnRLbIqUWa+0E9N4WNMjmp/kXXPHZGqPLxggwVhz7QP8CTR8w==",
|
"integrity": "sha512-yGlQYjdxtLdh0a3jHjuwOrxQjOZYD/C9PfdbgJJF3TIZWnm/tMd/RcNiLngiu4iwcBAOezdnSLAwQDPqTmtTYg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ia32"
|
"ia32"
|
||||||
],
|
],
|
||||||
@@ -293,9 +294,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-loong64": {
|
"node_modules/@esbuild/linux-loong64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.3.tgz",
|
||||||
"integrity": "sha512-lugyF1atnAT463aO6KPshVCJK5NgRnU4yb3FUumyVz+cGvZbontBgzeGFO1nF+dPueHD367a2ZXe1NtUkAjOtg==",
|
"integrity": "sha512-WO60Sn8ly3gtzhyjATDgieJNet/KqsDlX5nRC5Y3oTFcS1l0KWba+SEa9Ja1GfDqSF1z6hif/SkpQJbL63cgOA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"loong64"
|
"loong64"
|
||||||
],
|
],
|
||||||
@@ -310,9 +311,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-mips64el": {
|
"node_modules/@esbuild/linux-mips64el": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.3.tgz",
|
||||||
"integrity": "sha512-nlP2I6ArEBewvJ2gjrrkESEZkB5mIoaTswuqNFRv/WYd+ATtUpe9Y09RnJvgvdag7he0OWgEZWhviS1OTOKixw==",
|
"integrity": "sha512-APsymYA6sGcZ4pD6k+UxbDjOFSvPWyZhjaiPyl/f79xKxwTnrn5QUnXR5prvetuaSMsb4jgeHewIDCIWljrSxw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"mips64el"
|
"mips64el"
|
||||||
],
|
],
|
||||||
@@ -327,9 +328,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-ppc64": {
|
"node_modules/@esbuild/linux-ppc64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.3.tgz",
|
||||||
"integrity": "sha512-C92gnpey7tUQONqg1n6dKVbx3vphKtTHJaNG2Ok9lGwbZil6DrfyecMsp9CrmXGQJmZ7iiVXvvZH6Ml5hL6XdQ==",
|
"integrity": "sha512-eizBnTeBefojtDb9nSh4vvVQ3V9Qf9Df01PfawPcRzJH4gFSgrObw+LveUyDoKU3kxi5+9RJTCWlj4FjYXVPEA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ppc64"
|
"ppc64"
|
||||||
],
|
],
|
||||||
@@ -344,9 +345,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-riscv64": {
|
"node_modules/@esbuild/linux-riscv64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.3.tgz",
|
||||||
"integrity": "sha512-B5BOmojNtUyN8AXlK0QJyvjEZkWwy/FKvakkTDCziX95AowLZKR6aCDhG7LeF7uMCXEJqwa8Bejz5LTPYm8AvA==",
|
"integrity": "sha512-3Emwh0r5wmfm3ssTWRQSyVhbOHvqegUDRd0WhmXKX2mkHJe1SFCMJhagUleMq+Uci34wLSipf8Lagt4LlpRFWQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"riscv64"
|
"riscv64"
|
||||||
],
|
],
|
||||||
@@ -361,9 +362,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-s390x": {
|
"node_modules/@esbuild/linux-s390x": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.3.tgz",
|
||||||
"integrity": "sha512-p4bm9+wsPwup5Z8f4EpfN63qNagQ47Ua2znaqGH6bqLlmJ4bx97Y9JdqxgGZ6Y8xVTixUnEkoKSHcpRlDnNr5w==",
|
"integrity": "sha512-pBHUx9LzXWBc7MFIEEL0yD/ZVtNgLytvx60gES28GcWMqil8ElCYR4kvbV2BDqsHOvVDRrOxGySBM9Fcv744hw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"s390x"
|
"s390x"
|
||||||
],
|
],
|
||||||
@@ -378,9 +379,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-x64": {
|
"node_modules/@esbuild/linux-x64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.3.tgz",
|
||||||
"integrity": "sha512-uwp2Tip5aPmH+NRUwTcfLb+W32WXjpFejTIOWZFw/v7/KnpCDKG66u4DLcurQpiYTiYwQ9B7KOeMJvLCu/OvbA==",
|
"integrity": "sha512-Czi8yzXUWIQYAtL/2y6vogER8pvcsOsk5cpwL4Gk5nJqH5UZiVByIY8Eorm5R13gq+DQKYg0+JyQoytLQas4dA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -395,9 +396,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/netbsd-arm64": {
|
"node_modules/@esbuild/netbsd-arm64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.3.tgz",
|
||||||
"integrity": "sha512-Kj6DiBlwXrPsCRDeRvGAUb/LNrBASrfqAIok+xB0LxK8CHqxZ037viF13ugfsIpePH93mX7xfJp97cyDuTZ3cw==",
|
"integrity": "sha512-sDpk0RgmTCR/5HguIZa9n9u+HVKf40fbEUt+iTzSnCaGvY9kFP0YKBWZtJaraonFnqef5SlJ8/TiPAxzyS+UoA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -412,9 +413,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/netbsd-x64": {
|
"node_modules/@esbuild/netbsd-x64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.3.tgz",
|
||||||
"integrity": "sha512-HwGDZ0VLVBY3Y+Nw0JexZy9o/nUAWq9MlV7cahpaXKW6TOzfVno3y3/M8Ga8u8Yr7GldLOov27xiCnqRZf0tCA==",
|
"integrity": "sha512-P14lFKJl/DdaE00LItAukUdZO5iqNH7+PjoBm+fLQjtxfcfFE20Xf5CrLsmZdq5LFFZzb5JMZ9grUwvtVYzjiA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -429,9 +430,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/openbsd-arm64": {
|
"node_modules/@esbuild/openbsd-arm64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.3.tgz",
|
||||||
"integrity": "sha512-DNIHH2BPQ5551A7oSHD0CKbwIA/Ox7+78/AWkbS5QoRzaqlev2uFayfSxq68EkonB+IKjiuxBFoV8ESJy8bOHA==",
|
"integrity": "sha512-AIcMP77AvirGbRl/UZFTq5hjXK+2wC7qFRGoHSDrZ5v5b8DK/GYpXW3CPRL53NkvDqb9D+alBiC/dV0Fb7eJcw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -446,9 +447,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/openbsd-x64": {
|
"node_modules/@esbuild/openbsd-x64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.3.tgz",
|
||||||
"integrity": "sha512-/it7w9Nb7+0KFIzjalNJVR5bOzA9Vay+yIPLVHfIQYG/j+j9VTH84aNB8ExGKPU4AzfaEvN9/V4HV+F+vo8OEg==",
|
"integrity": "sha512-DnW2sRrBzA+YnE70LKqnM3P+z8vehfJWHXECbwBmH/CU51z6FiqTQTHFenPlHmo3a8UgpLyH3PT+87OViOh1AQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -463,9 +464,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/openharmony-arm64": {
|
"node_modules/@esbuild/openharmony-arm64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.3.tgz",
|
||||||
"integrity": "sha512-LRBbCmiU51IXfeXk59csuX/aSaToeG7w48nMwA6049Y4J4+VbWALAuXcs+qcD04rHDuSCSRKdmY63sruDS5qag==",
|
"integrity": "sha512-NinAEgr/etERPTsZJ7aEZQvvg/A6IsZG/LgZy+81wON2huV7SrK3e63dU0XhyZP4RKGyTm7aOgmQk0bGp0fy2g==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -480,9 +481,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/sunos-x64": {
|
"node_modules/@esbuild/sunos-x64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.3.tgz",
|
||||||
"integrity": "sha512-kMtx1yqJHTmqaqHPAzKCAkDaKsffmXkPHThSfRwZGyuqyIeBvf08KSsYXl+abf5HDAPMJIPnbBfXvP2ZC2TfHg==",
|
"integrity": "sha512-PanZ+nEz+eWoBJ8/f8HKxTTD172SKwdXebZ0ndd953gt1HRBbhMsaNqjTyYLGLPdoWHy4zLU7bDVJztF5f3BHA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -497,9 +498,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/win32-arm64": {
|
"node_modules/@esbuild/win32-arm64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.3.tgz",
|
||||||
"integrity": "sha512-Yaf78O/B3Kkh+nKABUF++bvJv5Ijoy9AN1ww904rOXZFLWVc5OLOfL56W+C8F9xn5JQZa3UX6m+IktJnIb1Jjg==",
|
"integrity": "sha512-B2t59lWWYrbRDw/tjiWOuzSsFh1Y/E95ofKz7rIVYSQkUYBjfSgf6oeYPNWHToFRr2zx52JKApIcAS/D5TUBnA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -514,9 +515,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/win32-ia32": {
|
"node_modules/@esbuild/win32-ia32": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.3.tgz",
|
||||||
"integrity": "sha512-Iuws0kxo4yusk7sw70Xa2E2imZU5HoixzxfGCdxwBdhiDgt9vX9VUCBhqcwY7/uh//78A1hMkkROMJq9l27oLQ==",
|
"integrity": "sha512-QLKSFeXNS8+tHW7tZpMtjlNb7HKau0QDpwm49u0vUp9y1WOF+PEzkU84y9GqYaAVW8aH8f3GcBck26jh54cX4Q==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ia32"
|
"ia32"
|
||||||
],
|
],
|
||||||
@@ -531,9 +532,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/win32-x64": {
|
"node_modules/@esbuild/win32-x64": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.3.tgz",
|
||||||
"integrity": "sha512-sRdU18mcKf7F+YgheI/zGf5alZatMUTKj/jNS6l744f9u3WFu4v7twcUI9vu4mknF4Y9aDlblIie0IM+5xxaqQ==",
|
"integrity": "sha512-4uJGhsxuptu3OcpVAzli+/gWusVGwZZHTlS63hh++ehExkVT8SgiEf7/uC/PclrPPkLhZqGgCTjd0VWLo6xMqA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -567,9 +568,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@isaacs/brace-expansion": {
|
"node_modules/@isaacs/brace-expansion": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.1.tgz",
|
||||||
"integrity": "sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==",
|
"integrity": "sha512-WMz71T1JS624nWj2n2fnYAuPovhv7EUhk69R6i9dsVyzxt5eM3bjwvgk9L+APE1TRscGysAVMANkB0jh0LQZrQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -587,9 +588,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@microsoft/api-extractor": {
|
"node_modules/@microsoft/api-extractor": {
|
||||||
"version": "7.56.0",
|
"version": "7.56.3",
|
||||||
"resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.56.0.tgz",
|
"resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.56.3.tgz",
|
||||||
"integrity": "sha512-H0V69QG5jIb9Ayx35NVBv2lOgFSS3q+Eab2oyGEy0POL3ovYPST+rCNPbwYoczOZXNG8IKjWUmmAMxmDTsXlQA==",
|
"integrity": "sha512-fRqok4aRNq5GpgGBv2fKlSSKbirPKTJ75vQefthB5x9dwt4Zz+AezUzdc1p/AG4wUBIgmhjcEwn/Rj+N4Wh4Mw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -599,10 +600,10 @@
|
|||||||
"@rushstack/node-core-library": "5.19.1",
|
"@rushstack/node-core-library": "5.19.1",
|
||||||
"@rushstack/rig-package": "0.6.0",
|
"@rushstack/rig-package": "0.6.0",
|
||||||
"@rushstack/terminal": "0.21.0",
|
"@rushstack/terminal": "0.21.0",
|
||||||
"@rushstack/ts-command-line": "5.1.7",
|
"@rushstack/ts-command-line": "5.2.0",
|
||||||
"diff": "~8.0.2",
|
"diff": "~8.0.2",
|
||||||
"lodash": "~4.17.15",
|
"lodash": "~4.17.23",
|
||||||
"minimatch": "10.0.3",
|
"minimatch": "10.1.2",
|
||||||
"resolve": "~1.22.1",
|
"resolve": "~1.22.1",
|
||||||
"semver": "~7.5.4",
|
"semver": "~7.5.4",
|
||||||
"source-map": "~0.6.1",
|
"source-map": "~0.6.1",
|
||||||
@@ -625,13 +626,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@microsoft/api-extractor/node_modules/minimatch": {
|
"node_modules/@microsoft/api-extractor/node_modules/minimatch": {
|
||||||
"version": "10.0.3",
|
"version": "10.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.1.2.tgz",
|
||||||
"integrity": "sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==",
|
"integrity": "sha512-fu656aJ0n2kcXwsnwnv9g24tkU5uSmOlTjd6WyyaKm2Z+h1qmY6bAjrcaIxF/BslFqbZ8UBtbJi7KgQOZD2PTw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC",
|
"license": "BlueOak-1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@isaacs/brace-expansion": "^5.0.0"
|
"@isaacs/brace-expansion": "^5.0.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "20 || >=22"
|
"node": "20 || >=22"
|
||||||
@@ -1261,9 +1262,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rushstack/ts-command-line": {
|
"node_modules/@rushstack/ts-command-line": {
|
||||||
"version": "5.1.7",
|
"version": "5.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-5.1.7.tgz",
|
"resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-5.2.0.tgz",
|
||||||
"integrity": "sha512-Ugwl6flarZcL2nqH5IXFYk3UR3mBVDsVFlCQW/Oaqidvdb/5Ota6b/Z3JXWIdqV3rOR2/JrYoAHanWF5rgenXA==",
|
"integrity": "sha512-lYxCX0nDdkDtCkVpvF0m25ymf66SaMWuppbD6b7MdkIzvGXKBXNIVZlwBH/C0YfkanrupnICWf2n4z3AKSfaHw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -1503,9 +1504,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "24.10.9",
|
"version": "24.10.13",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.9.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.13.tgz",
|
||||||
"integrity": "sha512-ne4A0IpG3+2ETuREInjPNhUGis1SFjv1d5asp8MzEAGtOZeTeHVDOYqOgqfhvseqg/iXty2hjBf1zAOb7RNiNw==",
|
"integrity": "sha512-oH72nZRfDv9lADUBSo104Aq7gPHpQZc4BTx38r9xf9pg5LfP6EzSyH2n7qFmmxRQXh7YlUXODcYsg6PuTDSxGg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~7.16.0"
|
"undici-types": "~7.16.0"
|
||||||
@@ -1577,15 +1578,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@vue/compiler-core": {
|
"node_modules/@vue/compiler-core": {
|
||||||
"version": "3.5.27",
|
"version": "3.5.28",
|
||||||
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.27.tgz",
|
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.28.tgz",
|
||||||
"integrity": "sha512-gnSBQjZA+//qDZen+6a2EdHqJ68Z7uybrMf3SPjEGgG4dicklwDVmMC1AeIHxtLVPT7sn6sH1KOO+tS6gwOUeQ==",
|
"integrity": "sha512-kviccYxTgoE8n6OCw96BNdYlBg2GOWfBuOW4Vqwrt7mSKWKwFVvI8egdTltqRgITGPsTFYtKYfxIG8ptX2PJHQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/parser": "^7.28.5",
|
"@babel/parser": "^7.29.0",
|
||||||
"@vue/shared": "3.5.27",
|
"@vue/shared": "3.5.28",
|
||||||
"entities": "^7.0.0",
|
"entities": "^7.0.1",
|
||||||
"estree-walker": "^2.0.2",
|
"estree-walker": "^2.0.2",
|
||||||
"source-map-js": "^1.2.1"
|
"source-map-js": "^1.2.1"
|
||||||
}
|
}
|
||||||
@@ -1604,14 +1605,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@vue/compiler-dom": {
|
"node_modules/@vue/compiler-dom": {
|
||||||
"version": "3.5.27",
|
"version": "3.5.28",
|
||||||
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.27.tgz",
|
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.28.tgz",
|
||||||
"integrity": "sha512-oAFea8dZgCtVVVTEC7fv3T5CbZW9BxpFzGGxC79xakTr6ooeEqmRuvQydIiDAkglZEAd09LgVf1RoDnL54fu5w==",
|
"integrity": "sha512-/1ZepxAb159jKR1btkefDP+J2xuWL5V3WtleRmxaT+K2Aqiek/Ab/+Ebrw2pPj0sdHO8ViAyyJWfhXXOP/+LQA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vue/compiler-core": "3.5.27",
|
"@vue/compiler-core": "3.5.28",
|
||||||
"@vue/shared": "3.5.27"
|
"@vue/shared": "3.5.28"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@vue/compiler-vue2": {
|
"node_modules/@vue/compiler-vue2": {
|
||||||
@@ -1651,9 +1652,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@vue/shared": {
|
"node_modules/@vue/shared": {
|
||||||
"version": "3.5.27",
|
"version": "3.5.28",
|
||||||
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.27.tgz",
|
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.28.tgz",
|
||||||
"integrity": "sha512-dXr/3CgqXsJkZ0n9F3I4elY8wM9jMJpP3pvRG52r6m0tu/MsAFIe6JpXVGeNMd/D9F4hQynWT8Rfuj0bdm9kFQ==",
|
"integrity": "sha512-cfWa1fCGBxrvaHRhvV3Is0MgmrbSCxYTXCSCau2I0a1Xw1N1pHAvkWCiXPRAqjvToILvguNyEwjevUqAuBQWvQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
@@ -1837,9 +1838,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/bare-fs": {
|
"node_modules/bare-fs": {
|
||||||
"version": "4.5.3",
|
"version": "4.5.4",
|
||||||
"resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-4.5.3.tgz",
|
"resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-4.5.4.tgz",
|
||||||
"integrity": "sha512-9+kwVx8QYvt3hPWnmb19tPnh38c6Nihz8Lx3t0g9+4GoIf3/fTgYwM4Z6NxgI+B9elLQA7mLE9PpqcWtOMRDiQ==",
|
"integrity": "sha512-POK4oplfA7P7gqvetNmCs4CNtm9fNsx+IAh7jH7GgU0OJdge2rso0R20TNWVq6VoWcCvsTdlNDaleLHGaKx8CA==",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -2183,9 +2184,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/confbox": {
|
"node_modules/confbox": {
|
||||||
"version": "0.2.2",
|
"version": "0.2.4",
|
||||||
"resolved": "https://registry.npmjs.org/confbox/-/confbox-0.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/confbox/-/confbox-0.2.4.tgz",
|
||||||
"integrity": "sha512-1NB+BKqhtNipMsov4xI/NnhCKp9XG9NamYp5PVm9klAT0fsrNPjaFICsCFhNhwZJKNh7zB/3q8qXz0E9oaMNtQ==",
|
"integrity": "sha512-ysOGlgTFbN2/Y6Cg3Iye8YKulHw+R2fNXHrgSmXISQdMnomY6eNDprVdW9R5xBguEqI954+S6709UyiO7B+6OQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
@@ -2491,9 +2492,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/esbuild": {
|
"node_modules/esbuild": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.3.tgz",
|
||||||
"integrity": "sha512-HyNQImnsOC7X9PMNaCIeAm4ISCQXs5a5YasTXVliKv4uuBo1dKrG0A+uQS8M5eXjVMnLg3WgXaKvprHlFJQffw==",
|
"integrity": "sha512-8VwMnyGCONIs6cWue2IdpHxHnAjzxnw2Zr7MkVxB2vjmQ2ivqGFb4LEG3SMnv0Gb2F/G/2yA8zUaiL1gywDCCg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -2504,32 +2505,32 @@
|
|||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@esbuild/aix-ppc64": "0.27.2",
|
"@esbuild/aix-ppc64": "0.27.3",
|
||||||
"@esbuild/android-arm": "0.27.2",
|
"@esbuild/android-arm": "0.27.3",
|
||||||
"@esbuild/android-arm64": "0.27.2",
|
"@esbuild/android-arm64": "0.27.3",
|
||||||
"@esbuild/android-x64": "0.27.2",
|
"@esbuild/android-x64": "0.27.3",
|
||||||
"@esbuild/darwin-arm64": "0.27.2",
|
"@esbuild/darwin-arm64": "0.27.3",
|
||||||
"@esbuild/darwin-x64": "0.27.2",
|
"@esbuild/darwin-x64": "0.27.3",
|
||||||
"@esbuild/freebsd-arm64": "0.27.2",
|
"@esbuild/freebsd-arm64": "0.27.3",
|
||||||
"@esbuild/freebsd-x64": "0.27.2",
|
"@esbuild/freebsd-x64": "0.27.3",
|
||||||
"@esbuild/linux-arm": "0.27.2",
|
"@esbuild/linux-arm": "0.27.3",
|
||||||
"@esbuild/linux-arm64": "0.27.2",
|
"@esbuild/linux-arm64": "0.27.3",
|
||||||
"@esbuild/linux-ia32": "0.27.2",
|
"@esbuild/linux-ia32": "0.27.3",
|
||||||
"@esbuild/linux-loong64": "0.27.2",
|
"@esbuild/linux-loong64": "0.27.3",
|
||||||
"@esbuild/linux-mips64el": "0.27.2",
|
"@esbuild/linux-mips64el": "0.27.3",
|
||||||
"@esbuild/linux-ppc64": "0.27.2",
|
"@esbuild/linux-ppc64": "0.27.3",
|
||||||
"@esbuild/linux-riscv64": "0.27.2",
|
"@esbuild/linux-riscv64": "0.27.3",
|
||||||
"@esbuild/linux-s390x": "0.27.2",
|
"@esbuild/linux-s390x": "0.27.3",
|
||||||
"@esbuild/linux-x64": "0.27.2",
|
"@esbuild/linux-x64": "0.27.3",
|
||||||
"@esbuild/netbsd-arm64": "0.27.2",
|
"@esbuild/netbsd-arm64": "0.27.3",
|
||||||
"@esbuild/netbsd-x64": "0.27.2",
|
"@esbuild/netbsd-x64": "0.27.3",
|
||||||
"@esbuild/openbsd-arm64": "0.27.2",
|
"@esbuild/openbsd-arm64": "0.27.3",
|
||||||
"@esbuild/openbsd-x64": "0.27.2",
|
"@esbuild/openbsd-x64": "0.27.3",
|
||||||
"@esbuild/openharmony-arm64": "0.27.2",
|
"@esbuild/openharmony-arm64": "0.27.3",
|
||||||
"@esbuild/sunos-x64": "0.27.2",
|
"@esbuild/sunos-x64": "0.27.3",
|
||||||
"@esbuild/win32-arm64": "0.27.2",
|
"@esbuild/win32-arm64": "0.27.3",
|
||||||
"@esbuild/win32-ia32": "0.27.2",
|
"@esbuild/win32-ia32": "0.27.3",
|
||||||
"@esbuild/win32-x64": "0.27.2"
|
"@esbuild/win32-x64": "0.27.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/escalade": {
|
"node_modules/escalade": {
|
||||||
@@ -3102,9 +3103,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/markdown-it": {
|
"node_modules/markdown-it": {
|
||||||
"version": "14.1.0",
|
"version": "14.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.1.tgz",
|
||||||
"integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==",
|
"integrity": "sha512-BuU2qnTti9YKgK5N+IeMubp14ZUKUUw7yeJbkjtosvHiP0AZ5c8IAgEMk79D0eC8F23r4Ac/q8cAIFdm2FtyoA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -3509,9 +3510,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/openai": {
|
"node_modules/openai": {
|
||||||
"version": "6.17.0",
|
"version": "6.21.0",
|
||||||
"resolved": "https://registry.npmjs.org/openai/-/openai-6.17.0.tgz",
|
"resolved": "https://registry.npmjs.org/openai/-/openai-6.21.0.tgz",
|
||||||
"integrity": "sha512-NHRpPEUPzAvFOAFs9+9pC6+HCw/iWsYsKCMPXH5Kw7BpMxqd8g/A07/1o7Gx2TWtCnzevVRyKMRFqyiHyAlqcA==",
|
"integrity": "sha512-26dQFi76dB8IiN/WKGQOV+yKKTTlRCxQjoi2WLt0kMcH8pvxVyvfdBDkld5GTl7W1qvBpwVOtFcsqktj3fBRpA==",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
"openai": "bin/cli"
|
"openai": "bin/cli"
|
||||||
@@ -3994,9 +3995,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/semver": {
|
"node_modules/semver": {
|
||||||
"version": "7.7.3",
|
"version": "7.7.4",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
|
||||||
"integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==",
|
"integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"bin": {
|
"bin": {
|
||||||
"semver": "bin/semver.js"
|
"semver": "bin/semver.js"
|
||||||
@@ -4403,9 +4404,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/undici": {
|
"node_modules/undici": {
|
||||||
"version": "7.19.2",
|
"version": "7.21.0",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-7.19.2.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-7.21.0.tgz",
|
||||||
"integrity": "sha512-4VQSpGEGsWzk0VYxyB/wVX/Q7qf9t5znLRgs0dzszr9w9Fej/8RVNQ+S20vdXSAyra/bJ7ZQfGv6ZMj7UEbzSg==",
|
"integrity": "sha512-Hn2tCQpoDt1wv23a68Ctc8Cr/BHpUSfaPYrkajTXOS9IKpxVRx/X5m1K2YkbK2ipgZgxXSgsUinl3x+2YdSSfg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20.18.1"
|
"node": ">=20.18.1"
|
||||||
@@ -4667,6 +4668,18 @@
|
|||||||
"integrity": "sha512-zksaLKM2fVlnB5jQQDqKXXwYHLQUVH9es+5TOOHwGOVJOCeRBCiPjwSg+3tN2AdTCzjgli4jijCH290kXb/zWQ==",
|
"integrity": "sha512-zksaLKM2fVlnB5jQQDqKXXwYHLQUVH9es+5TOOHwGOVJOCeRBCiPjwSg+3tN2AdTCzjgli4jijCH290kXb/zWQ==",
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
},
|
},
|
||||||
|
"node_modules/wavefile": {
|
||||||
|
"version": "11.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/wavefile/-/wavefile-11.0.0.tgz",
|
||||||
|
"integrity": "sha512-/OBiAALgWU24IG7sC84cDO/KfFuvajWc5Uec0oV2zrpOOZZDgGdOwHwgEzOrwh8jkubBk7PtZfQBIcI1OaE5Ng==",
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"wavefile": "bin/wavefile.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/webidl-conversions": {
|
"node_modules/webidl-conversions": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ztimson/ai-utils",
|
"name": "@ztimson/ai-utils",
|
||||||
"version": "0.4.0",
|
"version": "0.6.10",
|
||||||
"description": "AI Utility library",
|
"description": "AI Utility library",
|
||||||
"author": "Zak Timson",
|
"author": "Zak Timson",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -32,7 +32,8 @@
|
|||||||
"@ztimson/utils": "^0.27.9",
|
"@ztimson/utils": "^0.27.9",
|
||||||
"cheerio": "^1.2.0",
|
"cheerio": "^1.2.0",
|
||||||
"openai": "^6.6.0",
|
"openai": "^6.6.0",
|
||||||
"tesseract.js": "^6.0.1"
|
"tesseract.js": "^6.0.1",
|
||||||
|
"wavefile": "^11.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^24.8.1",
|
"@types/node": "^24.8.1",
|
||||||
|
|||||||
26
src/ai.ts
26
src/ai.ts
@@ -1,29 +1,27 @@
|
|||||||
import * as os from 'node:os';
|
import * as os from 'node:os';
|
||||||
import {LLM, AnthropicConfig, OllamaConfig, OpenAiConfig, LLMRequest} from './llm';
|
import LLM, {AnthropicConfig, OllamaConfig, OpenAiConfig, LLMRequest} from './llm';
|
||||||
import { Audio } from './audio.ts';
|
import { Audio } from './audio.ts';
|
||||||
import {Vision} from './vision.ts';
|
import {Vision} from './vision.ts';
|
||||||
|
|
||||||
export type AbortablePromise<T> = Promise<T> & {abort: () => any};
|
export type AbortablePromise<T> = Promise<T> & {
|
||||||
|
abort: () => any
|
||||||
|
};
|
||||||
|
|
||||||
export type AiOptions = {
|
export type AiOptions = {
|
||||||
|
/** Token to pull models from hugging face */
|
||||||
|
hfToken?: string;
|
||||||
/** Path to models */
|
/** Path to models */
|
||||||
path?: string;
|
path?: string;
|
||||||
|
/** ASR model: whisper-tiny, whisper-base */
|
||||||
|
asr?: string;
|
||||||
|
/** Embedding model: all-MiniLM-L6-v2, bge-small-en-v1.5, bge-large-en-v1.5 */
|
||||||
|
embedder?: string;
|
||||||
/** Large language models, first is default */
|
/** Large language models, first is default */
|
||||||
llm?: Omit<LLMRequest, 'model'> & {
|
llm?: Omit<LLMRequest, 'model'> & {
|
||||||
models: {[model: string]: AnthropicConfig | OllamaConfig | OpenAiConfig};
|
models: {[model: string]: AnthropicConfig | OllamaConfig | OpenAiConfig};
|
||||||
}
|
}
|
||||||
/** Tesseract OCR configuration */
|
/** OCR model: eng, eng_best, eng_fast */
|
||||||
tesseract?: {
|
ocr?: string;
|
||||||
/** Model: eng, eng_best, eng_fast */
|
|
||||||
model?: string;
|
|
||||||
}
|
|
||||||
/** Whisper ASR configuration */
|
|
||||||
whisper?: {
|
|
||||||
/** Whisper binary location */
|
|
||||||
binary: string;
|
|
||||||
/** Model: `ggml-base.en.bin` */
|
|
||||||
model: string;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Ai {
|
export class Ai {
|
||||||
|
|||||||
@@ -13,25 +13,25 @@ export class Anthropic extends LLMProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private toStandard(history: any[]): LLMMessage[] {
|
private toStandard(history: any[]): LLMMessage[] {
|
||||||
for(let i = 0; i < history.length; i++) {
|
const timestamp = Date.now();
|
||||||
const orgI = i;
|
const messages: LLMMessage[] = [];
|
||||||
if(typeof history[orgI].content != 'string') {
|
for(let h of history) {
|
||||||
if(history[orgI].role == 'assistant') {
|
if(typeof h.content == 'string') {
|
||||||
history[orgI].content.filter((c: any) => c.type =='tool_use').forEach((c: any) => {
|
messages.push(<any>{timestamp, ...h});
|
||||||
i++;
|
} else {
|
||||||
history.splice(i, 0, {role: 'tool', id: c.id, name: c.name, args: c.input, timestamp: Date.now()});
|
const textContent = h.content?.filter((c: any) => c.type == 'text').map((c: any) => c.text).join('\n\n');
|
||||||
});
|
if(textContent) messages.push({timestamp, role: h.role, content: textContent});
|
||||||
} else if(history[orgI].role == 'user') {
|
h.content.forEach((c: any) => {
|
||||||
history[orgI].content.filter((c: any) => c.type =='tool_result').forEach((c: any) => {
|
if(c.type == 'tool_use') {
|
||||||
const h = history.find((h: any) => h.id == c.tool_use_id);
|
messages.push({timestamp, role: 'tool', id: c.id, name: c.name, args: c.input, content: undefined});
|
||||||
h[c.is_error ? 'error' : 'content'] = c.content;
|
} else if(c.type == 'tool_result') {
|
||||||
});
|
const m: any = messages.findLast(m => (<any>m).id == c.tool_use_id);
|
||||||
}
|
if(m) m[c.is_error ? 'error' : 'content'] = c.content;
|
||||||
history[orgI].content = history[orgI].content.filter((c: any) => c.type == 'text').map((c: any) => c.text).join('\n\n');
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if(!history[orgI].timestamp) history[orgI].timestamp = Date.now();
|
|
||||||
}
|
}
|
||||||
return history.filter(h => !!h.content);
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
private fromStandard(history: LLMMessage[]): any[] {
|
private fromStandard(history: LLMMessage[]): any[] {
|
||||||
@@ -48,13 +48,10 @@ export class Anthropic extends LLMProvider {
|
|||||||
return history.map(({timestamp, ...h}) => h);
|
return history.map(({timestamp, ...h}) => h);
|
||||||
}
|
}
|
||||||
|
|
||||||
ask(message: string, options: LLMRequest = {}): AbortablePromise<LLMMessage[]> {
|
ask(message: string, options: LLMRequest = {}): AbortablePromise<string> {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const response = new Promise<any>(async (res, rej) => {
|
return Object.assign(new Promise<any>(async (res) => {
|
||||||
let history = [...options.history || [], {role: 'user', content: message, timestamp: Date.now()}];
|
let history = this.fromStandard([...options.history || [], {role: 'user', content: message, timestamp: Date.now()}]);
|
||||||
if(options.compress) history = await this.ai.language.compressHistory(<any>history, options.compress.max, options.compress.min, options);
|
|
||||||
history = this.fromStandard(<any>history);
|
|
||||||
|
|
||||||
const tools = options.tools || this.ai.options.llm?.tools || [];
|
const tools = options.tools || this.ai.options.llm?.tools || [];
|
||||||
const requestParams: any = {
|
const requestParams: any = {
|
||||||
model: options.model || this.model,
|
model: options.model || this.model,
|
||||||
@@ -76,7 +73,6 @@ export class Anthropic extends LLMProvider {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let resp: any, isFirstMessage = true;
|
let resp: any, isFirstMessage = true;
|
||||||
const assistantMessages: string[] = [];
|
|
||||||
do {
|
do {
|
||||||
resp = await this.client.messages.create(requestParams).catch(err => {
|
resp = await this.client.messages.create(requestParams).catch(err => {
|
||||||
err.message += `\n\nMessages:\n${JSON.stringify(history, null, 2)}`;
|
err.message += `\n\nMessages:\n${JSON.stringify(history, null, 2)}`;
|
||||||
@@ -122,7 +118,7 @@ export class Anthropic extends LLMProvider {
|
|||||||
if(options.stream) options.stream({tool: toolCall.name});
|
if(options.stream) options.stream({tool: toolCall.name});
|
||||||
if(!tool) return {tool_use_id: toolCall.id, is_error: true, content: 'Tool not found'};
|
if(!tool) return {tool_use_id: toolCall.id, is_error: true, content: 'Tool not found'};
|
||||||
try {
|
try {
|
||||||
const result = await tool.fn(toolCall.input, this.ai);
|
const result = await tool.fn(toolCall.input, options?.stream, this.ai);
|
||||||
return {type: 'tool_result', tool_use_id: toolCall.id, content: JSONSanitize(result)};
|
return {type: 'tool_result', tool_use_id: toolCall.id, content: JSONSanitize(result)};
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
return {type: 'tool_result', tool_use_id: toolCall.id, is_error: true, content: err?.message || err?.toString() || 'Unknown'};
|
return {type: 'tool_result', tool_use_id: toolCall.id, is_error: true, content: err?.message || err?.toString() || 'Unknown'};
|
||||||
@@ -132,11 +128,12 @@ export class Anthropic extends LLMProvider {
|
|||||||
requestParams.messages = history;
|
requestParams.messages = history;
|
||||||
}
|
}
|
||||||
} while (!controller.signal.aborted && resp.content.some((c: any) => c.type === 'tool_use'));
|
} while (!controller.signal.aborted && resp.content.some((c: any) => c.type === 'tool_use'));
|
||||||
|
history.push({role: 'assistant', content: resp.content.filter((c: any) => c.type == 'text').map((c: any) => c.text).join('\n\n')});
|
||||||
|
history = this.toStandard(history);
|
||||||
|
|
||||||
if(options.stream) options.stream({done: true});
|
if(options.stream) options.stream({done: true});
|
||||||
res(this.toStandard([...history, {role: 'assistant', content: resp.content.filter((c: any) => c.type == 'text').map((c: any) => c.text).join('\n\n')}]));
|
if(options.history) options.history.splice(0, options.history.length, ...history);
|
||||||
});
|
res(history.at(-1)?.content);
|
||||||
|
}), {abort: () => controller.abort()});
|
||||||
return Object.assign(response, {abort: () => controller.abort()});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
126
src/asr.ts
Normal file
126
src/asr.ts
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
import { pipeline } from '@xenova/transformers';
|
||||||
|
import { parentPort } from 'worker_threads';
|
||||||
|
import * as fs from 'node:fs';
|
||||||
|
import wavefile from 'wavefile';
|
||||||
|
import { spawn } from 'node:child_process';
|
||||||
|
|
||||||
|
let whisperPipeline: any;
|
||||||
|
|
||||||
|
export async function canDiarization(): Promise<boolean> {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const proc = spawn('python3', ['-c', 'import pyannote.audio']);
|
||||||
|
proc.on('close', (code: number) => resolve(code === 0));
|
||||||
|
proc.on('error', () => resolve(false));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function runDiarization(audioPath: string, dir: string, token: string): Promise<any[]> {
|
||||||
|
const script = `
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pyannote.audio import Pipeline
|
||||||
|
|
||||||
|
os.environ['TORCH_HOME'] = "${dir}"
|
||||||
|
os.environ['HF_TOKEN'] = "${token}"
|
||||||
|
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1")
|
||||||
|
diarization = pipeline(sys.argv[1])
|
||||||
|
|
||||||
|
segments = []
|
||||||
|
for turn, _, speaker in diarization.itertracks(yield_label=True):
|
||||||
|
segments.append({
|
||||||
|
"start": turn.start,
|
||||||
|
"end": turn.end,
|
||||||
|
"speaker": speaker
|
||||||
|
})
|
||||||
|
|
||||||
|
print(json.dumps(segments))
|
||||||
|
`;
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let output = '';
|
||||||
|
const proc = spawn('python3', ['-c', script, audioPath]);
|
||||||
|
proc.stdout.on('data', (data: Buffer) => output += data.toString());
|
||||||
|
proc.stderr.on('data', (data: Buffer) => console.error(data.toString()));
|
||||||
|
proc.on('close', (code: number) => {
|
||||||
|
if(code === 0) {
|
||||||
|
try {
|
||||||
|
resolve(JSON.parse(output));
|
||||||
|
} catch (err) {
|
||||||
|
reject(new Error('Failed to parse diarization output'));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
reject(new Error(`Python process exited with code ${code}`));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
proc.on('error', reject);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function combineSpeakerTranscript(chunks: any[], speakers: any[]): string {
|
||||||
|
const speakerMap = new Map();
|
||||||
|
let speakerCount = 0;
|
||||||
|
speakers.forEach((seg: any) => {
|
||||||
|
if(!speakerMap.has(seg.speaker)) speakerMap.set(seg.speaker, ++speakerCount);
|
||||||
|
});
|
||||||
|
|
||||||
|
const lines: string[] = [];
|
||||||
|
let currentSpeaker = -1;
|
||||||
|
let currentText = '';
|
||||||
|
chunks.forEach((chunk: any) => {
|
||||||
|
const time = chunk.timestamp[0];
|
||||||
|
const speaker = speakers.find((s: any) => time >= s.start && time <= s.end);
|
||||||
|
const speakerNum = speaker ? speakerMap.get(speaker.speaker) : 1;
|
||||||
|
if (speakerNum !== currentSpeaker) {
|
||||||
|
if(currentText) lines.push(`[speaker ${currentSpeaker}]: ${currentText.trim()}`);
|
||||||
|
currentSpeaker = speakerNum;
|
||||||
|
currentText = chunk.text;
|
||||||
|
} else {
|
||||||
|
currentText += chunk.text;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(currentText) lines.push(`[speaker ${currentSpeaker}]: ${currentText.trim()}`);
|
||||||
|
return lines.join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
parentPort?.on('message', async ({ file, speaker, model, modelDir, token }) => {
|
||||||
|
try {
|
||||||
|
console.log('worker', file);
|
||||||
|
if(!whisperPipeline) whisperPipeline = await pipeline('automatic-speech-recognition', `Xenova/${model}`, {cache_dir: modelDir, quantized: true});
|
||||||
|
|
||||||
|
// Prepare audio file (convert to mono channel wave)
|
||||||
|
const wav = new wavefile.WaveFile(fs.readFileSync(file));
|
||||||
|
wav.toBitDepth('32f');
|
||||||
|
wav.toSampleRate(16000);
|
||||||
|
const samples = wav.getSamples();
|
||||||
|
let buffer;
|
||||||
|
if(Array.isArray(samples)) { // stereo to mono - average the channels
|
||||||
|
const left = samples[0];
|
||||||
|
const right = samples[1];
|
||||||
|
buffer = new Float32Array(left.length);
|
||||||
|
for (let i = 0; i < left.length; i++) buffer[i] = (left[i] + right[i]) / 2;
|
||||||
|
} else {
|
||||||
|
buffer = samples;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transcribe
|
||||||
|
const transcriptResult = await whisperPipeline(buffer, {return_timestamps: speaker ? 'word' : false});
|
||||||
|
if(!speaker) {
|
||||||
|
parentPort?.postMessage({ text: transcriptResult.text?.trim() || null });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Speaker Diarization
|
||||||
|
const hasDiarization = await canDiarization();
|
||||||
|
if(!token || !hasDiarization) {
|
||||||
|
parentPort?.postMessage({ text: transcriptResult.text?.trim() || null, error: 'Speaker diarization unavailable' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const speakers = await runDiarization(file, modelDir, token);
|
||||||
|
const combined = combineSpeakerTranscript(transcriptResult.chunks || [], speakers);
|
||||||
|
parentPort?.postMessage({ text: combined });
|
||||||
|
} catch (err) {
|
||||||
|
parentPort?.postMessage({ error: (err as Error).message });
|
||||||
|
}
|
||||||
|
});
|
||||||
71
src/audio.ts
71
src/audio.ts
@@ -1,50 +1,41 @@
|
|||||||
import {spawn} from 'node:child_process';
|
import {fileURLToPath} from 'url';
|
||||||
import fs from 'node:fs/promises';
|
import {Worker} from 'worker_threads';
|
||||||
import Path from 'node:path';
|
|
||||||
import {AbortablePromise, Ai} from './ai.ts';
|
import {AbortablePromise, Ai} from './ai.ts';
|
||||||
|
import {canDiarization} from './asr.ts';
|
||||||
|
import {dirname, join} from 'path';
|
||||||
|
|
||||||
export class Audio {
|
export class Audio {
|
||||||
private downloads: {[key: string]: Promise<string>} = {};
|
constructor(private ai: Ai) {}
|
||||||
private whisperModel!: string;
|
|
||||||
|
|
||||||
constructor(private ai: Ai) {
|
asr(file: string, options: { model?: string; speaker?: boolean } = {}): AbortablePromise<string | null> {
|
||||||
if(ai.options.whisper?.binary) {
|
const { model = this.ai.options.asr || 'whisper-base', speaker = false } = options;
|
||||||
this.whisperModel = ai.options.whisper?.model.endsWith('.bin') ? ai.options.whisper?.model : ai.options.whisper?.model + '.bin';
|
let aborted = false;
|
||||||
this.downloadAsrModel();
|
const abort = () => { aborted = true; };
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
asr(path: string, model: string = this.whisperModel): AbortablePromise<string | null> {
|
const p = new Promise<string | null>((resolve, reject) => {
|
||||||
if(!this.ai.options.whisper?.binary) throw new Error('Whisper not configured');
|
const worker = new Worker(join(dirname(fileURLToPath(import.meta.url)), 'asr.js'));
|
||||||
let abort: any = () => {};
|
const handleMessage = ({ text, warning, error }: any) => {
|
||||||
const p = new Promise<string | null>(async (resolve, reject) => {
|
worker.terminate();
|
||||||
const m = await this.downloadAsrModel(model);
|
if(aborted) return;
|
||||||
let output = '';
|
if(error) reject(new Error(error));
|
||||||
const proc = spawn(<string>this.ai.options.whisper?.binary, ['-nt', '-np', '-m', m, '-f', path], {stdio: ['ignore', 'pipe', 'ignore']});
|
else {
|
||||||
abort = () => proc.kill('SIGTERM');
|
if(warning) console.warn(warning);
|
||||||
proc.on('error', (err: Error) => reject(err));
|
resolve(text);
|
||||||
proc.stdout.on('data', (data: Buffer) => output += data.toString());
|
}
|
||||||
proc.on('close', (code: number) => {
|
};
|
||||||
if(code === 0) resolve(output.trim() || null);
|
const handleError = (err: Error) => {
|
||||||
else reject(new Error(`Exit code ${code}`));
|
worker.terminate();
|
||||||
|
if(!aborted) reject(err);
|
||||||
|
};
|
||||||
|
worker.on('message', handleMessage);
|
||||||
|
worker.on('error', handleError);
|
||||||
|
worker.on('exit', (code) => {
|
||||||
|
if(code !== 0 && !aborted) reject(new Error(`Worker exited with code ${code}`));
|
||||||
});
|
});
|
||||||
|
worker.postMessage({file, model, speaker, modelDir: this.ai.options.path, token: this.ai.options.hfToken});
|
||||||
});
|
});
|
||||||
return Object.assign(p, {abort});
|
return Object.assign(p, { abort });
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadAsrModel(model: string = this.whisperModel): Promise<string> {
|
canDiarization = canDiarization;
|
||||||
if(!this.ai.options.whisper?.binary) throw new Error('Whisper not configured');
|
|
||||||
if(!model.endsWith('.bin')) model += '.bin';
|
|
||||||
const p = Path.join(<string>this.ai.options.path, model);
|
|
||||||
if(await fs.stat(p).then(() => true).catch(() => false)) return p;
|
|
||||||
if(!!this.downloads[model]) return this.downloads[model];
|
|
||||||
this.downloads[model] = fetch(`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/${model}`)
|
|
||||||
.then(resp => resp.arrayBuffer())
|
|
||||||
.then(arr => Buffer.from(arr)).then(async buffer => {
|
|
||||||
await fs.writeFile(p, buffer);
|
|
||||||
delete this.downloads[model];
|
|
||||||
return p;
|
|
||||||
});
|
|
||||||
return this.downloads[model];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { pipeline } from '@xenova/transformers';
|
import { pipeline } from '@xenova/transformers';
|
||||||
import { parentPort } from 'worker_threads';
|
import { parentPort } from 'worker_threads';
|
||||||
|
|
||||||
let model: any;
|
let embedder: any;
|
||||||
|
|
||||||
parentPort?.on('message', async ({ id, text }) => {
|
parentPort?.on('message', async ({text, model, modelDir }) => {
|
||||||
if(!model) model = await pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2');
|
if(!embedder) embedder = await pipeline('feature-extraction', 'Xenova/' + model, {quantized: true, cache_dir: modelDir});
|
||||||
const output = await model(text, { pooling: 'mean', normalize: true });
|
const output = await embedder(text, { pooling: 'mean', normalize: true });
|
||||||
const embedding = Array.from(output.data);
|
const embedding = Array.from(output.data);
|
||||||
parentPort?.postMessage({ id, embedding });
|
parentPort?.postMessage({embedding});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
export * from './ai';
|
export * from './ai';
|
||||||
export * from './antrhopic';
|
export * from './antrhopic';
|
||||||
|
export * from './asr';
|
||||||
export * from './audio';
|
export * from './audio';
|
||||||
export * from './embedder'
|
export * from './embedder'
|
||||||
export * from './llm';
|
export * from './llm';
|
||||||
|
|||||||
184
src/llm.ts
184
src/llm.ts
@@ -31,11 +31,23 @@ export type LLMMessage = {
|
|||||||
/** Tool result */
|
/** Tool result */
|
||||||
content: undefined | string;
|
content: undefined | string;
|
||||||
/** Tool error */
|
/** Tool error */
|
||||||
error: undefined | string;
|
error?: undefined | string;
|
||||||
/** Timestamp */
|
/** Timestamp */
|
||||||
timestamp?: number;
|
timestamp?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Background information the AI will be fed */
|
||||||
|
export type LLMMemory = {
|
||||||
|
/** What entity is this fact about */
|
||||||
|
owner: string;
|
||||||
|
/** The information that will be remembered */
|
||||||
|
fact: string;
|
||||||
|
/** Owner and fact embedding vector */
|
||||||
|
embeddings: [number[], number[]];
|
||||||
|
/** Creation time */
|
||||||
|
timestamp: Date;
|
||||||
|
}
|
||||||
|
|
||||||
export type LLMRequest = {
|
export type LLMRequest = {
|
||||||
/** System prompt */
|
/** System prompt */
|
||||||
system?: string;
|
system?: string;
|
||||||
@@ -57,26 +69,16 @@ export type LLMRequest = {
|
|||||||
max: number;
|
max: number;
|
||||||
/** Compress chat until context size smaller than */
|
/** Compress chat until context size smaller than */
|
||||||
min: number
|
min: number
|
||||||
}
|
},
|
||||||
|
/** Background information the AI will be fed */
|
||||||
|
memory?: LLMMemory[],
|
||||||
}
|
}
|
||||||
|
|
||||||
export class LLM {
|
class LLM {
|
||||||
private embedWorker: Worker | null = null;
|
|
||||||
private embedQueue = new Map<number, { resolve: (value: number[]) => void; reject: (error: any) => void }>();
|
|
||||||
private embedId = 0;
|
|
||||||
private models: {[model: string]: LLMProvider} = {};
|
private models: {[model: string]: LLMProvider} = {};
|
||||||
private defaultModel!: string;
|
private defaultModel!: string;
|
||||||
|
|
||||||
constructor(public readonly ai: Ai) {
|
constructor(public readonly ai: Ai) {
|
||||||
this.embedWorker = new Worker(join(dirname(fileURLToPath(import.meta.url)), 'embedder.js'));
|
|
||||||
this.embedWorker.on('message', ({ id, embedding }) => {
|
|
||||||
const pending = this.embedQueue.get(id);
|
|
||||||
if (pending) {
|
|
||||||
pending.resolve(embedding);
|
|
||||||
this.embedQueue.delete(id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if(!ai.options.llm?.models) return;
|
if(!ai.options.llm?.models) return;
|
||||||
Object.entries(ai.options.llm.models).forEach(([model, config]) => {
|
Object.entries(ai.options.llm.models).forEach(([model, config]) => {
|
||||||
if(!this.defaultModel) this.defaultModel = model;
|
if(!this.defaultModel) this.defaultModel = model;
|
||||||
@@ -90,37 +92,115 @@ export class LLM {
|
|||||||
* Chat with LLM
|
* Chat with LLM
|
||||||
* @param {string} message Question
|
* @param {string} message Question
|
||||||
* @param {LLMRequest} options Configuration options and chat history
|
* @param {LLMRequest} options Configuration options and chat history
|
||||||
* @returns {{abort: () => void, response: Promise<LLMMessage[]>}} Function to abort response and chat history
|
* @returns {{abort: () => void, response: Promise<string>}} Function to abort response and chat history
|
||||||
*/
|
*/
|
||||||
ask(message: string, options: LLMRequest = {}): AbortablePromise<LLMMessage[]> {
|
ask(message: string, options: LLMRequest = {}): AbortablePromise<string> {
|
||||||
const m = options.model || this.defaultModel;
|
const m = options.model || this.defaultModel;
|
||||||
if(!this.models[m]) throw new Error(`Model does not exist: ${m}`);
|
if(!this.models[m]) throw new Error(`Model does not exist: ${m}`);
|
||||||
return this.models[m].ask(message, options);
|
let abort = () => {};
|
||||||
|
return Object.assign(new Promise<string>(async res => {
|
||||||
|
if(!options.history) options.history = [];
|
||||||
|
// If memories were passed, find any relivant ones and add a tool for ADHOC lookups
|
||||||
|
if(options.memory) {
|
||||||
|
options.system = (options.system || '') + '\nYou have passive persistent memory never make any mention of your memory capabilities and what you can/cannot remember\n';
|
||||||
|
const search = async (query?: string | null, subject?: string | null, limit = 50) => {
|
||||||
|
const [o, q] = await Promise.all([
|
||||||
|
subject ? this.embedding(subject) : Promise.resolve(null),
|
||||||
|
query ? this.embedding(query) : Promise.resolve(null),
|
||||||
|
]);
|
||||||
|
return (options.memory || [])
|
||||||
|
.map(m => ({...m, score: o ? this.cosineSimilarity(m.embeddings[0], o[0].embedding) : 1}))
|
||||||
|
.filter((m: any) => m.score >= 0.8)
|
||||||
|
.map((m: any) => ({...m, score: q ? this.cosineSimilarity(m.embeddings[1], q[0].embedding) : m.score}))
|
||||||
|
.filter((m: any) => m.score >= 0.2)
|
||||||
|
.toSorted((a: any, b: any) => a.score - b.score)
|
||||||
|
.slice(0, limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
const relevant = await search(message);
|
||||||
|
if(relevant.length) options.history.push({role: 'assistant', content: 'Things I remembered:\n' + relevant.map(m => `${m.owner}: ${m.fact}`).join('\n')});
|
||||||
|
options.tools = [...options.tools || [], {
|
||||||
|
name: 'read_memory',
|
||||||
|
description: 'Check your long-term memory for more information',
|
||||||
|
args: {
|
||||||
|
subject: {type: 'string', description: 'Find information by a subject topic, can be used with or without query argument'},
|
||||||
|
query: {type: 'string', description: 'Search memory based on a query, can be used with or without subject argument'},
|
||||||
|
limit: {type: 'number', description: 'Result limit, default 5'},
|
||||||
|
},
|
||||||
|
fn: (args) => {
|
||||||
|
if(!args.subject && !args.query) throw new Error('Either a subject or query argument is required');
|
||||||
|
return search(args.query, args.subject, args.limit || 5);
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ask
|
||||||
|
const resp = await this.models[m].ask(message, options);
|
||||||
|
|
||||||
|
// Remove any memory calls
|
||||||
|
if(options.memory) {
|
||||||
|
const i = options.history?.findIndex((h: any) => h.role == 'assistant' && h.content.startsWith('Things I remembered:'));
|
||||||
|
if(i != null && i >= 0) options.history?.splice(i, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle compression and memory extraction
|
||||||
|
if(options.compress || options.memory) {
|
||||||
|
let compressed = null;
|
||||||
|
if(options.compress) {
|
||||||
|
compressed = await this.ai.language.compressHistory(options.history, options.compress.max, options.compress.min, options);
|
||||||
|
options.history.splice(0, options.history.length, ...compressed.history);
|
||||||
|
} else {
|
||||||
|
const i = options.history?.findLastIndex(m => m.role == 'user') ?? -1;
|
||||||
|
compressed = await this.ai.language.compressHistory(i != -1 ? options.history.slice(i) : options.history, 0, 0, options);
|
||||||
|
}
|
||||||
|
if(options.memory) {
|
||||||
|
const updated = options.memory
|
||||||
|
.filter(m => !compressed.memory.some(m2 => this.cosineSimilarity(m.embeddings[1], m2.embeddings[1]) > 0.8))
|
||||||
|
.concat(compressed.memory);
|
||||||
|
options.memory.splice(0, options.memory.length, ...updated);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res(resp);
|
||||||
|
}), {abort});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compress chat history to reduce context size
|
* Compress chat history to reduce context size
|
||||||
* @param {LLMMessage[]} history Chatlog that will be compressed
|
* @param {LLMMessage[]} history Chatlog that will be compressed
|
||||||
* @param max Trigger compression once context is larger than max
|
* @param max Trigger compression once context is larger than max
|
||||||
* @param min Summarize until context size is less than min
|
* @param min Leave messages less than the token minimum, summarize the rest
|
||||||
* @param {LLMRequest} options LLM options
|
* @param {LLMRequest} options LLM options
|
||||||
* @returns {Promise<LLMMessage[]>} New chat history will summary at index 0
|
* @returns {Promise<LLMMessage[]>} New chat history will summary at index 0
|
||||||
*/
|
*/
|
||||||
async compressHistory(history: LLMMessage[], max: number, min: number, options?: LLMRequest): Promise<LLMMessage[]> {
|
async compressHistory(history: LLMMessage[], max: number, min: number, options?: LLMRequest): Promise<{history: LLMMessage[], memory: LLMMemory[]}> {
|
||||||
if(this.estimateTokens(history) < max) return history;
|
if(this.estimateTokens(history) < max) return {history, memory: []};
|
||||||
let keep = 0, tokens = 0;
|
let keep = 0, tokens = 0;
|
||||||
for(let m of history.toReversed()) {
|
for(let m of history.toReversed()) {
|
||||||
tokens += this.estimateTokens(m.content);
|
tokens += this.estimateTokens(m.content);
|
||||||
if(tokens < min) keep++;
|
if(tokens < min) keep++;
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
if(history.length <= keep) return history;
|
if(history.length <= keep) return {history, memory: []};
|
||||||
const recent = keep == 0 ? [] : history.slice(-keep),
|
const system = history[0].role == 'system' ? history[0] : null,
|
||||||
|
recent = keep == 0 ? [] : history.slice(-keep),
|
||||||
process = (keep == 0 ? history : history.slice(0, -keep)).filter(h => h.role === 'assistant' || h.role === 'user');
|
process = (keep == 0 ? history : history.slice(0, -keep)).filter(h => h.role === 'assistant' || h.role === 'user');
|
||||||
const summary = await this.summarize(process.map(m => `${m.role}: ${m.content}`).join('\n\n'), 250, options);
|
const summary: any = await this.json(`Create the smallest summary possible, no more than 500 tokens. Create a list of NEW facts (split by subject [pro]noun and fact) about what you learned from this conversation that you didn't already know or get from a tool call or system prompt. Focus only on new information about people, topics, or facts. Avoid generating facts about the AI. Match this format: {summary: string, facts: [[subject, fact]]}\n\n${process.map(m => `${m.role}: ${m.content}`).join('\n\n')}`, {model: options?.model, temperature: options?.temperature || 0.3});
|
||||||
return [{role: 'assistant', content: `Conversation Summary: ${summary}`, timestamp: Date.now()}, ...recent];
|
const timestamp = new Date();
|
||||||
|
const memory = await Promise.all((summary?.facts || [])?.map(async ([owner, fact]: [string, string]) => {
|
||||||
|
const e = await Promise.all([this.embedding(owner), this.embedding(`${owner}: ${fact}`)]);
|
||||||
|
return {owner, fact, embeddings: [e[0][0].embedding, e[1][0].embedding], timestamp};
|
||||||
|
}));
|
||||||
|
const h = [{role: 'assistant', content: `Conversation Summary: ${summary?.summary}`, timestamp: Date.now()}, ...recent];
|
||||||
|
if(system) h.splice(0, 0, system);
|
||||||
|
return {history: <any>h, memory};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare the difference between embeddings (calculates the angle between two vectors)
|
||||||
|
* @param {number[]} v1 First embedding / vector comparison
|
||||||
|
* @param {number[]} v2 Second embedding / vector for comparison
|
||||||
|
* @returns {number} Similarity values 0-1: 0 = unique, 1 = identical
|
||||||
|
*/
|
||||||
cosineSimilarity(v1: number[], v2: number[]): number {
|
cosineSimilarity(v1: number[], v2: number[]): number {
|
||||||
if (v1.length !== v2.length) throw new Error('Vectors must be same length');
|
if (v1.length !== v2.length) throw new Error('Vectors must be same length');
|
||||||
let dotProduct = 0, normA = 0, normB = 0;
|
let dotProduct = 0, normA = 0, normB = 0;
|
||||||
@@ -133,6 +213,13 @@ export class LLM {
|
|||||||
return denominator === 0 ? 0 : dotProduct / denominator;
|
return denominator === 0 ? 0 : dotProduct / denominator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chunk text into parts for AI digestion
|
||||||
|
* @param {object | string} target Item that will be chunked (objects get converted)
|
||||||
|
* @param {number} maxTokens Chunking size. More = better context, less = more specific (Search by paragraphs or lines)
|
||||||
|
* @param {number} overlapTokens Includes previous X tokens to provide continuity to AI (In addition to max tokens)
|
||||||
|
* @returns {string[]} Chunked strings
|
||||||
|
*/
|
||||||
chunk(target: object | string, maxTokens = 500, overlapTokens = 50): string[] {
|
chunk(target: object | string, maxTokens = 500, overlapTokens = 50): string[] {
|
||||||
const objString = (obj: any, path = ''): string[] => {
|
const objString = (obj: any, path = ''): string[] => {
|
||||||
if(!obj) return [];
|
if(!obj) return [];
|
||||||
@@ -142,7 +229,6 @@ export class LLM {
|
|||||||
return `${p}: ${Array.isArray(value) ? value.join(', ') : value}`;
|
return `${p}: ${Array.isArray(value) ? value.join(', ') : value}`;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const lines = typeof target === 'object' ? objString(target) : target.split('\n');
|
const lines = typeof target === 'object' ? objString(target) : target.split('\n');
|
||||||
const tokens = lines.flatMap(l => [...l.split(/\s+/).filter(Boolean), '\n']);
|
const tokens = lines.flatMap(l => [...l.split(/\s+/).filter(Boolean), '\n']);
|
||||||
const chunks: string[] = [];
|
const chunks: string[] = [];
|
||||||
@@ -161,15 +247,33 @@ export class LLM {
|
|||||||
return chunks;
|
return chunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a vector representation of a string
|
||||||
|
* @param {object | string} target Item that will be embedded (objects get converted)
|
||||||
|
* @param {number} maxTokens Chunking size. More = better context, less = more specific (Search by paragraphs or lines)
|
||||||
|
* @param {number} overlapTokens Includes previous X tokens to provide continuity to AI (In addition to max tokens)
|
||||||
|
* @returns {Promise<Awaited<{index: number, embedding: number[], text: string, tokens: number}>[]>} Chunked embeddings
|
||||||
|
*/
|
||||||
embedding(target: object | string, maxTokens = 500, overlapTokens = 50) {
|
embedding(target: object | string, maxTokens = 500, overlapTokens = 50) {
|
||||||
const embed = (text: string): Promise<number[]> => {
|
const embed = (text: string): Promise<number[]> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const id = this.embedId++;
|
const worker = new Worker(join(dirname(fileURLToPath(import.meta.url)), 'embedder.js'));
|
||||||
this.embedQueue.set(id, { resolve, reject });
|
const handleMessage = ({ embedding }: any) => {
|
||||||
this.embedWorker?.postMessage({ id, text });
|
worker.terminate();
|
||||||
|
resolve(embedding);
|
||||||
|
};
|
||||||
|
const handleError = (err: Error) => {
|
||||||
|
worker.terminate();
|
||||||
|
reject(err);
|
||||||
|
};
|
||||||
|
worker.on('message', handleMessage);
|
||||||
|
worker.on('error', handleError);
|
||||||
|
worker.on('exit', (code) => {
|
||||||
|
if(code !== 0) reject(new Error(`Worker exited with code ${code}`));
|
||||||
|
});
|
||||||
|
worker.postMessage({text, model: this.ai.options?.embedder || 'bge-small-en-v1.5', modelDir: this.ai.options.path});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const chunks = this.chunk(target, maxTokens, overlapTokens);
|
const chunks = this.chunk(target, maxTokens, overlapTokens);
|
||||||
return Promise.all(chunks.map(async (text, index) => ({
|
return Promise.all(chunks.map(async (text, index) => ({
|
||||||
index,
|
index,
|
||||||
@@ -191,7 +295,7 @@ export class LLM {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare the difference between two strings using tensor math
|
* Compare the difference between two strings using tensor math
|
||||||
* @param target Text that will checked
|
* @param target Text that will be checked
|
||||||
* @param {string} searchTerms Multiple search terms to check against target
|
* @param {string} searchTerms Multiple search terms to check against target
|
||||||
* @returns {{avg: number, max: number, similarities: number[]}} Similarity values 0-1: 0 = unique, 1 = identical
|
* @returns {{avg: number, max: number, similarities: number[]}} Similarity values 0-1: 0 = unique, 1 = identical
|
||||||
*/
|
*/
|
||||||
@@ -212,13 +316,12 @@ export class LLM {
|
|||||||
* @param {LLMRequest} options Configuration options and chat history
|
* @param {LLMRequest} options Configuration options and chat history
|
||||||
* @returns {Promise<{} | {} | RegExpExecArray | null>}
|
* @returns {Promise<{} | {} | RegExpExecArray | null>}
|
||||||
*/
|
*/
|
||||||
async json(message: string, options?: LLMRequest) {
|
async json(message: string, options?: LLMRequest): Promise<any> {
|
||||||
let resp = await this.ask(message, {
|
let resp = await this.ask(message, {system: 'Respond using a JSON blob matching any provided examples', ...options});
|
||||||
system: 'Respond using a JSON blob',
|
if(!resp) return {};
|
||||||
...options
|
const codeBlock = /```(?:.+)?\s*([\s\S]*?)```/.exec(resp);
|
||||||
});
|
const jsonStr = codeBlock ? codeBlock[1].trim() : resp;
|
||||||
if(!resp?.[0]?.content) return {};
|
return JSONAttemptParse(jsonStr, {});
|
||||||
return JSONAttemptParse(new RegExp('\{[\s\S]*\}').exec(resp[0].content), {});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -229,7 +332,8 @@ export class LLM {
|
|||||||
* @returns {Promise<string>} Summary
|
* @returns {Promise<string>} Summary
|
||||||
*/
|
*/
|
||||||
summarize(text: string, tokens: number, options?: LLMRequest): Promise<string | null> {
|
summarize(text: string, tokens: number, options?: LLMRequest): Promise<string | null> {
|
||||||
return this.ask(text, {system: `Generate a brief summary <= ${tokens} tokens. Output nothing else`, temperature: 0.3, ...options})
|
return this.ask(text, {system: `Generate a brief summary <= ${tokens} tokens. Output nothing else`, temperature: 0.3, ...options});
|
||||||
.then(history => <string>history.pop()?.content || null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default LLM;
|
||||||
|
|||||||
@@ -64,13 +64,11 @@ export class OpenAi extends LLMProvider {
|
|||||||
}, [] as any[]);
|
}, [] as any[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ask(message: string, options: LLMRequest = {}): AbortablePromise<LLMMessage[]> {
|
ask(message: string, options: LLMRequest = {}): AbortablePromise<string> {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const response = new Promise<any>(async (res, rej) => {
|
return Object.assign(new Promise<any>(async (res, rej) => {
|
||||||
let history = [...options.history || [], {role: 'user', content: message, timestamp: Date.now()}];
|
if(options.system && options.history?.[0]?.role != 'system') options.history?.splice(0, 0, {role: 'system', content: options.system, timestamp: Date.now()});
|
||||||
if(options.compress) history = await this.ai.language.compressHistory(<any>history, options.compress.max, options.compress.min, options);
|
let history = this.fromStandard([...options.history || [], {role: 'user', content: message, timestamp: Date.now()}]);
|
||||||
history = this.fromStandard(<any>history);
|
|
||||||
|
|
||||||
const tools = options.tools || this.ai.options.llm?.tools || [];
|
const tools = options.tools || this.ai.options.llm?.tools || [];
|
||||||
const requestParams: any = {
|
const requestParams: any = {
|
||||||
model: options.model || this.model,
|
model: options.model || this.model,
|
||||||
@@ -124,7 +122,7 @@ export class OpenAi extends LLMProvider {
|
|||||||
if(!tool) return {role: 'tool', tool_call_id: toolCall.id, content: '{"error": "Tool not found"}'};
|
if(!tool) return {role: 'tool', tool_call_id: toolCall.id, content: '{"error": "Tool not found"}'};
|
||||||
try {
|
try {
|
||||||
const args = JSONAttemptParse(toolCall.function.arguments, {});
|
const args = JSONAttemptParse(toolCall.function.arguments, {});
|
||||||
const result = await tool.fn(args, this.ai);
|
const result = await tool.fn(args, options.stream, this.ai);
|
||||||
return {role: 'tool', tool_call_id: toolCall.id, content: JSONSanitize(result)};
|
return {role: 'tool', tool_call_id: toolCall.id, content: JSONSanitize(result)};
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
return {role: 'tool', tool_call_id: toolCall.id, content: JSONSanitize({error: err?.message || err?.toString() || 'Unknown'})};
|
return {role: 'tool', tool_call_id: toolCall.id, content: JSONSanitize({error: err?.message || err?.toString() || 'Unknown'})};
|
||||||
@@ -134,10 +132,12 @@ export class OpenAi extends LLMProvider {
|
|||||||
requestParams.messages = history;
|
requestParams.messages = history;
|
||||||
}
|
}
|
||||||
} while (!controller.signal.aborted && resp.choices?.[0]?.message?.tool_calls?.length);
|
} while (!controller.signal.aborted && resp.choices?.[0]?.message?.tool_calls?.length);
|
||||||
|
history.push({role: 'assistant', content: resp.choices[0].message.content || ''});
|
||||||
|
history = this.toStandard(history);
|
||||||
|
|
||||||
if(options.stream) options.stream({done: true});
|
if(options.stream) options.stream({done: true});
|
||||||
res(this.toStandard([...history, {role: 'assistant', content: resp.choices[0].message.content || ''}]));
|
if(options.history) options.history.splice(0, options.history.length, ...history);
|
||||||
});
|
res(history.at(-1)?.content);
|
||||||
return Object.assign(response, {abort: () => controller.abort()});
|
}), {abort: () => controller.abort()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ import {AbortablePromise} from './ai.ts';
|
|||||||
import {LLMMessage, LLMRequest} from './llm.ts';
|
import {LLMMessage, LLMRequest} from './llm.ts';
|
||||||
|
|
||||||
export abstract class LLMProvider {
|
export abstract class LLMProvider {
|
||||||
abstract ask(message: string, options: LLMRequest): AbortablePromise<LLMMessage[]>;
|
abstract ask(message: string, options: LLMRequest): AbortablePromise<string>;
|
||||||
}
|
}
|
||||||
|
|||||||
15
src/tools.ts
15
src/tools.ts
@@ -2,6 +2,7 @@ import * as cheerio from 'cheerio';
|
|||||||
import {$, $Sync} from '@ztimson/node-utils';
|
import {$, $Sync} from '@ztimson/node-utils';
|
||||||
import {ASet, consoleInterceptor, Http, fn as Fn} from '@ztimson/utils';
|
import {ASet, consoleInterceptor, Http, fn as Fn} from '@ztimson/utils';
|
||||||
import {Ai} from './ai.ts';
|
import {Ai} from './ai.ts';
|
||||||
|
import {LLMRequest} from './llm.ts';
|
||||||
|
|
||||||
export type AiToolArg = {[key: string]: {
|
export type AiToolArg = {[key: string]: {
|
||||||
/** Argument type */
|
/** Argument type */
|
||||||
@@ -32,7 +33,7 @@ export type AiTool = {
|
|||||||
/** Tool arguments */
|
/** Tool arguments */
|
||||||
args?: AiToolArg,
|
args?: AiToolArg,
|
||||||
/** Callback function */
|
/** Callback function */
|
||||||
fn: (args: any, ai: Ai) => any | Promise<any>,
|
fn: (args: any, stream: LLMRequest['stream'], ai: Ai) => any | Promise<any>,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CliTool: AiTool = {
|
export const CliTool: AiTool = {
|
||||||
@@ -44,9 +45,9 @@ export const CliTool: AiTool = {
|
|||||||
|
|
||||||
export const DateTimeTool: AiTool = {
|
export const DateTimeTool: AiTool = {
|
||||||
name: 'get_datetime',
|
name: 'get_datetime',
|
||||||
description: 'Get current date and time',
|
description: 'Get current UTC date / time',
|
||||||
args: {},
|
args: {},
|
||||||
fn: async () => new Date().toISOString()
|
fn: async () => new Date().toUTCString()
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ExecTool: AiTool = {
|
export const ExecTool: AiTool = {
|
||||||
@@ -56,15 +57,15 @@ export const ExecTool: AiTool = {
|
|||||||
language: {type: 'string', description: 'Execution language', enum: ['cli', 'node', 'python'], required: true},
|
language: {type: 'string', description: 'Execution language', enum: ['cli', 'node', 'python'], required: true},
|
||||||
code: {type: 'string', description: 'Code to execute', required: true}
|
code: {type: 'string', description: 'Code to execute', required: true}
|
||||||
},
|
},
|
||||||
fn: async (args, ai) => {
|
fn: async (args, stream, ai) => {
|
||||||
try {
|
try {
|
||||||
switch(args.type) {
|
switch(args.type) {
|
||||||
case 'bash':
|
case 'bash':
|
||||||
return await CliTool.fn({command: args.code}, ai);
|
return await CliTool.fn({command: args.code}, stream, ai);
|
||||||
case 'node':
|
case 'node':
|
||||||
return await JSTool.fn({code: args.code}, ai);
|
return await JSTool.fn({code: args.code}, stream, ai);
|
||||||
case 'python': {
|
case 'python': {
|
||||||
return await PythonTool.fn({code: args.code}, ai);
|
return await PythonTool.fn({code: args.code}, stream, ai);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(err: any) {
|
} catch(err: any) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export class Vision {
|
|||||||
ocr(path: string): AbortablePromise<string | null> {
|
ocr(path: string): AbortablePromise<string | null> {
|
||||||
let worker: any;
|
let worker: any;
|
||||||
const p = new Promise<string | null>(async res => {
|
const p = new Promise<string | null>(async res => {
|
||||||
worker = await createWorker(this.ai.options.tesseract?.model || 'eng', 2, {cachePath: this.ai.options.path});
|
worker = await createWorker(this.ai.options.ocr || 'eng', 2, {cachePath: this.ai.options.path});
|
||||||
const {data} = await worker.recognize(path);
|
const {data} = await worker.recognize(path);
|
||||||
await worker.terminate();
|
await worker.terminate();
|
||||||
res(data.text.trim() || null);
|
res(data.text.trim() || null);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export default defineConfig({
|
|||||||
build: {
|
build: {
|
||||||
lib: {
|
lib: {
|
||||||
entry: {
|
entry: {
|
||||||
|
asr: './src/asr.ts',
|
||||||
index: './src/index.ts',
|
index: './src/index.ts',
|
||||||
embedder: './src/embedder.ts',
|
embedder: './src/embedder.ts',
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user