296bbfa6 by Jerald Lim

opensource

1 parent 34d94fa0
...@@ -2237,6 +2237,21 @@ ...@@ -2237,6 +2237,21 @@
2237 "url": "https://opencollective.com/eslint" 2237 "url": "https://opencollective.com/eslint"
2238 } 2238 }
2239 }, 2239 },
2240 "node_modules/@eslint/eslintrc/node_modules/ajv": {
2241 "version": "6.12.6",
2242 "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
2243 "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
2244 "dependencies": {
2245 "fast-deep-equal": "^3.1.1",
2246 "fast-json-stable-stringify": "^2.0.0",
2247 "json-schema-traverse": "^0.4.1",
2248 "uri-js": "^4.2.2"
2249 },
2250 "funding": {
2251 "type": "github",
2252 "url": "https://github.com/sponsors/epoberezkin"
2253 }
2254 },
2240 "node_modules/@eslint/eslintrc/node_modules/argparse": { 2255 "node_modules/@eslint/eslintrc/node_modules/argparse": {
2241 "version": "2.0.1", 2256 "version": "2.0.1",
2242 "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", 2257 "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
...@@ -2267,6 +2282,11 @@ ...@@ -2267,6 +2282,11 @@
2267 "js-yaml": "bin/js-yaml.js" 2282 "js-yaml": "bin/js-yaml.js"
2268 } 2283 }
2269 }, 2284 },
2285 "node_modules/@eslint/eslintrc/node_modules/json-schema-traverse": {
2286 "version": "0.4.1",
2287 "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
2288 "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
2289 },
2270 "node_modules/@humanwhocodes/config-array": { 2290 "node_modules/@humanwhocodes/config-array": {
2271 "version": "0.11.8", 2291 "version": "0.11.8",
2272 "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", 2292 "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz",
...@@ -4746,13 +4766,13 @@ ...@@ -4746,13 +4766,13 @@
4746 } 4766 }
4747 }, 4767 },
4748 "node_modules/ajv": { 4768 "node_modules/ajv": {
4749 "version": "6.12.6", 4769 "version": "8.12.0",
4750 "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", 4770 "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz",
4751 "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", 4771 "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==",
4752 "dependencies": { 4772 "dependencies": {
4753 "fast-deep-equal": "^3.1.1", 4773 "fast-deep-equal": "^3.1.1",
4754 "fast-json-stable-stringify": "^2.0.0", 4774 "json-schema-traverse": "^1.0.0",
4755 "json-schema-traverse": "^0.4.1", 4775 "require-from-string": "^2.0.2",
4756 "uri-js": "^4.2.2" 4776 "uri-js": "^4.2.2"
4757 }, 4777 },
4758 "funding": { 4778 "funding": {
...@@ -4776,34 +4796,6 @@ ...@@ -4776,34 +4796,6 @@
4776 } 4796 }
4777 } 4797 }
4778 }, 4798 },
4779 "node_modules/ajv-formats/node_modules/ajv": {
4780 "version": "8.12.0",
4781 "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz",
4782 "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==",
4783 "dependencies": {
4784 "fast-deep-equal": "^3.1.1",
4785 "json-schema-traverse": "^1.0.0",
4786 "require-from-string": "^2.0.2",
4787 "uri-js": "^4.2.2"
4788 },
4789 "funding": {
4790 "type": "github",
4791 "url": "https://github.com/sponsors/epoberezkin"
4792 }
4793 },
4794 "node_modules/ajv-formats/node_modules/json-schema-traverse": {
4795 "version": "1.0.0",
4796 "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
4797 "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
4798 },
4799 "node_modules/ajv-keywords": {
4800 "version": "3.5.2",
4801 "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz",
4802 "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==",
4803 "peerDependencies": {
4804 "ajv": "^6.9.1"
4805 }
4806 },
4807 "node_modules/ansi-escapes": { 4799 "node_modules/ansi-escapes": {
4808 "version": "4.3.2", 4800 "version": "4.3.2",
4809 "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", 4801 "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz",
...@@ -5154,6 +5146,34 @@ ...@@ -5154,6 +5146,34 @@
5154 "webpack": ">=2" 5146 "webpack": ">=2"
5155 } 5147 }
5156 }, 5148 },
5149 "node_modules/babel-loader/node_modules/ajv": {
5150 "version": "6.12.6",
5151 "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
5152 "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
5153 "dependencies": {
5154 "fast-deep-equal": "^3.1.1",
5155 "fast-json-stable-stringify": "^2.0.0",
5156 "json-schema-traverse": "^0.4.1",
5157 "uri-js": "^4.2.2"
5158 },
5159 "funding": {
5160 "type": "github",
5161 "url": "https://github.com/sponsors/epoberezkin"
5162 }
5163 },
5164 "node_modules/babel-loader/node_modules/ajv-keywords": {
5165 "version": "3.5.2",
5166 "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz",
5167 "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==",
5168 "peerDependencies": {
5169 "ajv": "^6.9.1"
5170 }
5171 },
5172 "node_modules/babel-loader/node_modules/json-schema-traverse": {
5173 "version": "0.4.1",
5174 "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
5175 "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
5176 },
5157 "node_modules/babel-loader/node_modules/schema-utils": { 5177 "node_modules/babel-loader/node_modules/schema-utils": {
5158 "version": "2.7.1", 5178 "version": "2.7.1",
5159 "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.1.tgz", 5179 "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.1.tgz",
...@@ -6152,21 +6172,6 @@ ...@@ -6152,21 +6172,6 @@
6152 } 6172 }
6153 } 6173 }
6154 }, 6174 },
6155 "node_modules/css-minimizer-webpack-plugin/node_modules/ajv": {
6156 "version": "8.12.0",
6157 "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz",
6158 "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==",
6159 "dependencies": {
6160 "fast-deep-equal": "^3.1.1",
6161 "json-schema-traverse": "^1.0.0",
6162 "require-from-string": "^2.0.2",
6163 "uri-js": "^4.2.2"
6164 },
6165 "funding": {
6166 "type": "github",
6167 "url": "https://github.com/sponsors/epoberezkin"
6168 }
6169 },
6170 "node_modules/css-minimizer-webpack-plugin/node_modules/ajv-keywords": { 6175 "node_modules/css-minimizer-webpack-plugin/node_modules/ajv-keywords": {
6171 "version": "5.1.0", 6176 "version": "5.1.0",
6172 "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", 6177 "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz",
...@@ -6178,11 +6183,6 @@ ...@@ -6178,11 +6183,6 @@
6178 "ajv": "^8.8.2" 6183 "ajv": "^8.8.2"
6179 } 6184 }
6180 }, 6185 },
6181 "node_modules/css-minimizer-webpack-plugin/node_modules/json-schema-traverse": {
6182 "version": "1.0.0",
6183 "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
6184 "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
6185 },
6186 "node_modules/css-minimizer-webpack-plugin/node_modules/schema-utils": { 6186 "node_modules/css-minimizer-webpack-plugin/node_modules/schema-utils": {
6187 "version": "4.0.0", 6187 "version": "4.0.0",
6188 "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz", 6188 "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz",
...@@ -7533,21 +7533,6 @@ ...@@ -7533,21 +7533,6 @@
7533 "webpack": "^5.0.0" 7533 "webpack": "^5.0.0"
7534 } 7534 }
7535 }, 7535 },
7536 "node_modules/eslint-webpack-plugin/node_modules/ajv": {
7537 "version": "8.12.0",
7538 "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz",
7539 "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==",
7540 "dependencies": {
7541 "fast-deep-equal": "^3.1.1",
7542 "json-schema-traverse": "^1.0.0",
7543 "require-from-string": "^2.0.2",
7544 "uri-js": "^4.2.2"
7545 },
7546 "funding": {
7547 "type": "github",
7548 "url": "https://github.com/sponsors/epoberezkin"
7549 }
7550 },
7551 "node_modules/eslint-webpack-plugin/node_modules/ajv-keywords": { 7536 "node_modules/eslint-webpack-plugin/node_modules/ajv-keywords": {
7552 "version": "5.1.0", 7537 "version": "5.1.0",
7553 "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", 7538 "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz",
...@@ -7572,11 +7557,6 @@ ...@@ -7572,11 +7557,6 @@
7572 "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" 7557 "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0"
7573 } 7558 }
7574 }, 7559 },
7575 "node_modules/eslint-webpack-plugin/node_modules/json-schema-traverse": {
7576 "version": "1.0.0",
7577 "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
7578 "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
7579 },
7580 "node_modules/eslint-webpack-plugin/node_modules/schema-utils": { 7560 "node_modules/eslint-webpack-plugin/node_modules/schema-utils": {
7581 "version": "4.0.0", 7561 "version": "4.0.0",
7582 "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz", 7562 "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz",
...@@ -7609,6 +7589,21 @@ ...@@ -7609,6 +7589,21 @@
7609 "url": "https://github.com/chalk/supports-color?sponsor=1" 7589 "url": "https://github.com/chalk/supports-color?sponsor=1"
7610 } 7590 }
7611 }, 7591 },
7592 "node_modules/eslint/node_modules/ajv": {
7593 "version": "6.12.6",
7594 "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
7595 "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
7596 "dependencies": {
7597 "fast-deep-equal": "^3.1.1",
7598 "fast-json-stable-stringify": "^2.0.0",
7599 "json-schema-traverse": "^0.4.1",
7600 "uri-js": "^4.2.2"
7601 },
7602 "funding": {
7603 "type": "github",
7604 "url": "https://github.com/sponsors/epoberezkin"
7605 }
7606 },
7612 "node_modules/eslint/node_modules/argparse": { 7607 "node_modules/eslint/node_modules/argparse": {
7613 "version": "2.0.1", 7608 "version": "2.0.1",
7614 "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", 7609 "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
...@@ -7665,6 +7660,11 @@ ...@@ -7665,6 +7660,11 @@
7665 "js-yaml": "bin/js-yaml.js" 7660 "js-yaml": "bin/js-yaml.js"
7666 } 7661 }
7667 }, 7662 },
7663 "node_modules/eslint/node_modules/json-schema-traverse": {
7664 "version": "0.4.1",
7665 "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
7666 "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
7667 },
7668 "node_modules/espree": { 7668 "node_modules/espree": {
7669 "version": "9.4.1", 7669 "version": "9.4.1",
7670 "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz", 7670 "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz",
...@@ -8148,6 +8148,29 @@ ...@@ -8148,6 +8148,29 @@
8148 } 8148 }
8149 } 8149 }
8150 }, 8150 },
8151 "node_modules/fork-ts-checker-webpack-plugin/node_modules/ajv": {
8152 "version": "6.12.6",
8153 "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
8154 "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
8155 "dependencies": {
8156 "fast-deep-equal": "^3.1.1",
8157 "fast-json-stable-stringify": "^2.0.0",
8158 "json-schema-traverse": "^0.4.1",
8159 "uri-js": "^4.2.2"
8160 },
8161 "funding": {
8162 "type": "github",
8163 "url": "https://github.com/sponsors/epoberezkin"
8164 }
8165 },
8166 "node_modules/fork-ts-checker-webpack-plugin/node_modules/ajv-keywords": {
8167 "version": "3.5.2",
8168 "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz",
8169 "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==",
8170 "peerDependencies": {
8171 "ajv": "^6.9.1"
8172 }
8173 },
8151 "node_modules/fork-ts-checker-webpack-plugin/node_modules/chalk": { 8174 "node_modules/fork-ts-checker-webpack-plugin/node_modules/chalk": {
8152 "version": "4.1.2", 8175 "version": "4.1.2",
8153 "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", 8176 "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
...@@ -8192,6 +8215,11 @@ ...@@ -8192,6 +8215,11 @@
8192 "node": ">=10" 8215 "node": ">=10"
8193 } 8216 }
8194 }, 8217 },
8218 "node_modules/fork-ts-checker-webpack-plugin/node_modules/json-schema-traverse": {
8219 "version": "0.4.1",
8220 "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
8221 "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
8222 },
8195 "node_modules/fork-ts-checker-webpack-plugin/node_modules/schema-utils": { 8223 "node_modules/fork-ts-checker-webpack-plugin/node_modules/schema-utils": {
8196 "version": "2.7.0", 8224 "version": "2.7.0",
8197 "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.0.tgz", 8225 "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.0.tgz",
...@@ -11983,9 +12011,9 @@ ...@@ -11983,9 +12011,9 @@
11983 "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==" 12011 "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA=="
11984 }, 12012 },
11985 "node_modules/json-schema-traverse": { 12013 "node_modules/json-schema-traverse": {
11986 "version": "0.4.1", 12014 "version": "1.0.0",
11987 "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", 12015 "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
11988 "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" 12016 "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
11989 }, 12017 },
11990 "node_modules/json-stable-stringify-without-jsonify": { 12018 "node_modules/json-stable-stringify-without-jsonify": {
11991 "version": "1.0.1", 12019 "version": "1.0.1",
...@@ -12373,21 +12401,6 @@ ...@@ -12373,21 +12401,6 @@
12373 "webpack": "^5.0.0" 12401 "webpack": "^5.0.0"
12374 } 12402 }
12375 }, 12403 },
12376 "node_modules/mini-css-extract-plugin/node_modules/ajv": {
12377 "version": "8.12.0",
12378 "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz",
12379 "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==",
12380 "dependencies": {
12381 "fast-deep-equal": "^3.1.1",
12382 "json-schema-traverse": "^1.0.0",
12383 "require-from-string": "^2.0.2",
12384 "uri-js": "^4.2.2"
12385 },
12386 "funding": {
12387 "type": "github",
12388 "url": "https://github.com/sponsors/epoberezkin"
12389 }
12390 },
12391 "node_modules/mini-css-extract-plugin/node_modules/ajv-keywords": { 12404 "node_modules/mini-css-extract-plugin/node_modules/ajv-keywords": {
12392 "version": "5.1.0", 12405 "version": "5.1.0",
12393 "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", 12406 "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz",
...@@ -12399,11 +12412,6 @@ ...@@ -12399,11 +12412,6 @@
12399 "ajv": "^8.8.2" 12412 "ajv": "^8.8.2"
12400 } 12413 }
12401 }, 12414 },
12402 "node_modules/mini-css-extract-plugin/node_modules/json-schema-traverse": {
12403 "version": "1.0.0",
12404 "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
12405 "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
12406 },
12407 "node_modules/mini-css-extract-plugin/node_modules/schema-utils": { 12415 "node_modules/mini-css-extract-plugin/node_modules/schema-utils": {
12408 "version": "4.0.0", 12416 "version": "4.0.0",
12409 "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz", 12417 "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz",
...@@ -15389,6 +15397,34 @@ ...@@ -15389,6 +15397,34 @@
15389 "url": "https://opencollective.com/webpack" 15397 "url": "https://opencollective.com/webpack"
15390 } 15398 }
15391 }, 15399 },
15400 "node_modules/schema-utils/node_modules/ajv": {
15401 "version": "6.12.6",
15402 "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
15403 "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
15404 "dependencies": {
15405 "fast-deep-equal": "^3.1.1",
15406 "fast-json-stable-stringify": "^2.0.0",
15407 "json-schema-traverse": "^0.4.1",
15408 "uri-js": "^4.2.2"
15409 },
15410 "funding": {
15411 "type": "github",
15412 "url": "https://github.com/sponsors/epoberezkin"
15413 }
15414 },
15415 "node_modules/schema-utils/node_modules/ajv-keywords": {
15416 "version": "3.5.2",
15417 "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz",
15418 "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==",
15419 "peerDependencies": {
15420 "ajv": "^6.9.1"
15421 }
15422 },
15423 "node_modules/schema-utils/node_modules/json-schema-traverse": {
15424 "version": "0.4.1",
15425 "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
15426 "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
15427 },
15392 "node_modules/select-hose": { 15428 "node_modules/select-hose": {
15393 "version": "2.0.0", 15429 "version": "2.0.0",
15394 "resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz", 15430 "resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz",
...@@ -16473,6 +16509,19 @@ ...@@ -16473,6 +16509,19 @@
16473 "is-typedarray": "^1.0.0" 16509 "is-typedarray": "^1.0.0"
16474 } 16510 }
16475 }, 16511 },
16512 "node_modules/typescript": {
16513 "version": "4.9.5",
16514 "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
16515 "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
16516 "peer": true,
16517 "bin": {
16518 "tsc": "bin/tsc",
16519 "tsserver": "bin/tsserver"
16520 },
16521 "engines": {
16522 "node": ">=4.2.0"
16523 }
16524 },
16476 "node_modules/unbox-primitive": { 16525 "node_modules/unbox-primitive": {
16477 "version": "1.0.2", 16526 "version": "1.0.2",
16478 "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", 16527 "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
...@@ -16796,21 +16845,6 @@ ...@@ -16796,21 +16845,6 @@
16796 "webpack": "^4.0.0 || ^5.0.0" 16845 "webpack": "^4.0.0 || ^5.0.0"
16797 } 16846 }
16798 }, 16847 },
16799 "node_modules/webpack-dev-middleware/node_modules/ajv": {
16800 "version": "8.12.0",
16801 "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz",
16802 "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==",
16803 "dependencies": {
16804 "fast-deep-equal": "^3.1.1",
16805 "json-schema-traverse": "^1.0.0",
16806 "require-from-string": "^2.0.2",
16807 "uri-js": "^4.2.2"
16808 },
16809 "funding": {
16810 "type": "github",
16811 "url": "https://github.com/sponsors/epoberezkin"
16812 }
16813 },
16814 "node_modules/webpack-dev-middleware/node_modules/ajv-keywords": { 16848 "node_modules/webpack-dev-middleware/node_modules/ajv-keywords": {
16815 "version": "5.1.0", 16849 "version": "5.1.0",
16816 "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", 16850 "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz",
...@@ -16822,11 +16856,6 @@ ...@@ -16822,11 +16856,6 @@
16822 "ajv": "^8.8.2" 16856 "ajv": "^8.8.2"
16823 } 16857 }
16824 }, 16858 },
16825 "node_modules/webpack-dev-middleware/node_modules/json-schema-traverse": {
16826 "version": "1.0.0",
16827 "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
16828 "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
16829 },
16830 "node_modules/webpack-dev-middleware/node_modules/schema-utils": { 16859 "node_modules/webpack-dev-middleware/node_modules/schema-utils": {
16831 "version": "4.0.0", 16860 "version": "4.0.0",
16832 "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz", 16861 "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz",
...@@ -16899,21 +16928,6 @@ ...@@ -16899,21 +16928,6 @@
16899 } 16928 }
16900 } 16929 }
16901 }, 16930 },
16902 "node_modules/webpack-dev-server/node_modules/ajv": {
16903 "version": "8.12.0",
16904 "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz",
16905 "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==",
16906 "dependencies": {
16907 "fast-deep-equal": "^3.1.1",
16908 "json-schema-traverse": "^1.0.0",
16909 "require-from-string": "^2.0.2",
16910 "uri-js": "^4.2.2"
16911 },
16912 "funding": {
16913 "type": "github",
16914 "url": "https://github.com/sponsors/epoberezkin"
16915 }
16916 },
16917 "node_modules/webpack-dev-server/node_modules/ajv-keywords": { 16931 "node_modules/webpack-dev-server/node_modules/ajv-keywords": {
16918 "version": "5.1.0", 16932 "version": "5.1.0",
16919 "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", 16933 "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz",
...@@ -16925,11 +16939,6 @@ ...@@ -16925,11 +16939,6 @@
16925 "ajv": "^8.8.2" 16939 "ajv": "^8.8.2"
16926 } 16940 }
16927 }, 16941 },
16928 "node_modules/webpack-dev-server/node_modules/json-schema-traverse": {
16929 "version": "1.0.0",
16930 "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
16931 "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
16932 },
16933 "node_modules/webpack-dev-server/node_modules/schema-utils": { 16942 "node_modules/webpack-dev-server/node_modules/schema-utils": {
16934 "version": "4.0.0", 16943 "version": "4.0.0",
16935 "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz", 16944 "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz",
...@@ -17222,21 +17231,6 @@ ...@@ -17222,21 +17231,6 @@
17222 "node": ">=10.0.0" 17231 "node": ">=10.0.0"
17223 } 17232 }
17224 }, 17233 },
17225 "node_modules/workbox-build/node_modules/ajv": {
17226 "version": "8.12.0",
17227 "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz",
17228 "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==",
17229 "dependencies": {
17230 "fast-deep-equal": "^3.1.1",
17231 "json-schema-traverse": "^1.0.0",
17232 "require-from-string": "^2.0.2",
17233 "uri-js": "^4.2.2"
17234 },
17235 "funding": {
17236 "type": "github",
17237 "url": "https://github.com/sponsors/epoberezkin"
17238 }
17239 },
17240 "node_modules/workbox-build/node_modules/fs-extra": { 17234 "node_modules/workbox-build/node_modules/fs-extra": {
17241 "version": "9.1.0", 17235 "version": "9.1.0",
17242 "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", 17236 "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
...@@ -17251,11 +17245,6 @@ ...@@ -17251,11 +17245,6 @@
17251 "node": ">=10" 17245 "node": ">=10"
17252 } 17246 }
17253 }, 17247 },
17254 "node_modules/workbox-build/node_modules/json-schema-traverse": {
17255 "version": "1.0.0",
17256 "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
17257 "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
17258 },
17259 "node_modules/workbox-build/node_modules/source-map": { 17248 "node_modules/workbox-build/node_modules/source-map": {
17260 "version": "0.8.0-beta.0", 17249 "version": "0.8.0-beta.0",
17261 "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.8.0-beta.0.tgz", 17250 "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.8.0-beta.0.tgz",
......
...@@ -28,9 +28,12 @@ function App() { ...@@ -28,9 +28,12 @@ function App() {
28 const [chatLogTurbo, setChatLogTurbo] = useState(defaultChatLogTurbo); 28 const [chatLogTurbo, setChatLogTurbo] = useState(defaultChatLogTurbo);
29 // 29 //
30 30
31 const [chatLogOpenSource, setChatLogOpenSource] = useState([]);
32
31 function clearChat(){ 33 function clearChat(){
32 setChatLog([]); 34 setChatLog([]);
33 setChatLogTurbo(defaultChatLogTurbo); 35 setChatLogTurbo(defaultChatLogTurbo);
36 setChatLogOpenSource([]);
34 setChatInput(""); 37 setChatInput("");
35 setStartedInteraction(false); 38 setStartedInteraction(false);
36 } 39 }
...@@ -94,12 +97,20 @@ function App() { ...@@ -94,12 +97,20 @@ function App() {
94 setChatLog(prevChatLog => [...prevChatLog, userMessage]); 97 setChatLog(prevChatLog => [...prevChatLog, userMessage]);
95 98
96 var messages = chatLogNew.map((message) => { if(message.user !== 'me') return message.message }).join("\n") 99 var messages = chatLogNew.map((message) => { if(message.user !== 'me') return message.message }).join("\n")
97 if(currentModel == GPTTurbo || currentModel == GPTTurbo0301) { 100 if(currentModel === GPTTurbo || currentModel === GPTTurbo0301) {
98 // "gpt-3.5-turbo" 101 // "gpt-3.5-turbo"
99 let chatLogTurboNew = [...chatLogTurbo, { role: "user", content: chatInput }]; 102 let chatLogTurboNew = [...chatLogTurbo, { role: "user", content: chatInput }];
100 setChatLogTurbo(chatLogTurboNew); 103 setChatLogTurbo(chatLogTurboNew);
101 messages = JSON.stringify(chatLogTurboNew); 104 messages = JSON.stringify(chatLogTurboNew);
102 } 105 }
106
107 if(currentModel === "openchat_3.5-GPTQ" || currentModel === "zephyr-7B-beta-GPTQ") {
108 // "gpt-3.5-turbo"
109 let chatLogOpenSourceNew = [...chatLogOpenSource, { role: "user", content: chatInput }];
110 setChatLogOpenSource(chatLogOpenSourceNew);
111 messages = JSON.stringify(chatLogOpenSourceNew);
112 }
113
103 let intervalId = startInterval(); 114 let intervalId = startInterval();
104 try { 115 try {
105 const response = await fetch(process.env.REACT_APP_SERVER_URL + "/api", { 116 const response = await fetch(process.env.REACT_APP_SERVER_URL + "/api", {
...@@ -117,6 +128,7 @@ function App() { ...@@ -117,6 +128,7 @@ function App() {
117 const parsedData = data.message.trim(); 128 const parsedData = data.message.trim();
118 // "gpt-3.5-turbo" 129 // "gpt-3.5-turbo"
119 let chatLogTurboNew = chatLogTurbo; 130 let chatLogTurboNew = chatLogTurbo;
131 let chatLogOpenSourceNew = chatLogOpenSource;
120 if(data.success === false) { 132 if(data.success === false) {
121 setChatLog(prevChatLog => { 133 setChatLog(prevChatLog => {
122 const lastMsg = prevChatLog[prevChatLog.length - 2]; 134 const lastMsg = prevChatLog[prevChatLog.length - 2];
...@@ -129,7 +141,11 @@ function App() { ...@@ -129,7 +141,11 @@ function App() {
129 } 141 }
130 chatLogTurboNew.push({ role: "user", content: userModifiedInput }); 142 chatLogTurboNew.push({ role: "user", content: userModifiedInput });
131 chatLogTurboNew.push({ role: "assistant", content: parsedData }); 143 chatLogTurboNew.push({ role: "assistant", content: parsedData });
144
145 chatLogOpenSourceNew.push({ role: "user", content: userModifiedInput });
146 chatLogOpenSourceNew.push({ role: "assistant", content: parsedData });
132 setChatLogTurbo(chatLogTurboNew); 147 setChatLogTurbo(chatLogTurboNew);
148 setChatLogOpenSource(chatLogOpenSourceNew);
133 // 149 //
134 clearInterval(intervalId); 150 clearInterval(intervalId);
135 const programmingKeywords = ['code', 'application', 'controller', 'rails' , 'PHP', 'java', 'javascript', 'script', 'console', 'python', 'programming', 'table']; 151 const programmingKeywords = ['code', 'application', 'controller', 'rails' , 'PHP', 'java', 'javascript', 'script', 'console', 'python', 'programming', 'table'];
......
1 OPENAI_API_ORG= 1 OPENAI_API_ORG=
2 OPENAI_API_KEY=
...\ No newline at end of file ...\ No newline at end of file
2 OPENAI_API_KEY=
3
4
5 OPENSOURCE_MODELS="openchat_3.5-GPTQ,zephyr-7B-beta-GPTQ"
6 OPENSOURCE_ENDPOINTS={"openchat_3.5-GPTQ": "https://openchat.llm.ai-pro.org/v1", "zephyr-7B-beta-GPTQ": "https://zephyr.llm.ai-pro.org/v1"}
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -49,8 +49,8 @@ const tiktokenModels = [ ...@@ -49,8 +49,8 @@ const tiktokenModels = [
49 // Open AI Configuration 49 // Open AI Configuration
50 // console.log(process.env.OPENAI_API_ORG) 50 // console.log(process.env.OPENAI_API_ORG)
51 const configuration = new Configuration({ 51 const configuration = new Configuration({
52 organization: process.env.OPENAI_API_ORG, 52 organization: process.env.OPENAI_API_ORG,
53 apiKey: process.env.OPENAI_API_KEY, 53 apiKey: process.env.OPENAI_API_KEY,
54 }); 54 });
55 const openai = new OpenAIApi(configuration); 55 const openai = new OpenAIApi(configuration);
56 56
...@@ -73,158 +73,235 @@ app.use(rateLimiter) ...@@ -73,158 +73,235 @@ app.use(rateLimiter)
73 73
74 // Primary Open AI Route 74 // Primary Open AI Route
75 app.post('/api', async (req, res) => { 75 app.post('/api', async (req, res) => {
76 const { message, currentModel, temperature } = req.body; 76 const { message, currentModel, temperature } = req.body;
77 77
78 if(currentModel == "gpt-3.5-turbo" || currentModel == "gpt-3.5-turbo-0301") { 78 if (currentModel == "gpt-3.5-turbo" || currentModel == "gpt-3.5-turbo-0301") {
79 runGPTTurbo(req,res); 79 runGPTTurbo(req, res);
80 return; 80 return;
81 } 81 }
82 82
83 let greetingPrompt = 'Hello, how can I assist you?' 83 if (currentModel == "openchat_3.5-GPTQ" || currentModel == "zephyr-7B-beta-GPTQ") {
84 const greetings = ['hi', 'hello', 'hey'] 84 runOpensource(req, res);
85 if (greetings.some((greeting) => message.toLowerCase().includes(greeting))) { 85 return;
86 greetingPrompt = 'Hello, how can I help you today?' 86 }
87 } 87
88 let query_prompt = `${greetingPrompt}\n${message}`; 88 let greetingPrompt = 'Hello, how can I assist you?'
89 str_length = req.body.message.split(' ').length; 89 const greetings = ['hi', 'hello', 'hey']
90 if (str_length>=800){ 90 if (greetings.some((greeting) => message.toLowerCase().includes(greeting))) {
91 arr_body = req.body.message.split("\n"); 91 greetingPrompt = 'Hello, how can I help you today?'
92 if (arr_body.length>=4){ 92 }
93 var i = arr_body.length-2 93 let query_prompt = `${greetingPrompt}\n${message}`;
94 while (i--) { 94 str_length = req.body.message.split(' ').length;
95 arr_body.splice(i, 1); 95 if (str_length >= 800) {
96 } 96 arr_body = req.body.message.split("\n");
97 query_prompt = arr_body.join("\n") 97 if (arr_body.length >= 4) {
98 } 98 var i = arr_body.length - 2
99 } 99 while (i--) {
100 const moderation = await axios.post("https://api.openai.com/v1/moderations", { 100 arr_body.splice(i, 1);
101 }
102 query_prompt = arr_body.join("\n")
103 }
104 }
105 const moderation = await axios.post("https://api.openai.com/v1/moderations", {
101 input: query_prompt 106 input: query_prompt
102 }, { headers: { 'content-type': 'application/json', 'Authorization': `Bearer ${process.env.OPENAI_API_KEY}` } }); 107 }, { headers: { 'content-type': 'application/json', 'Authorization': `Bearer ${process.env.OPENAI_API_KEY}` } });
103 108
104 if(moderation.data.results[0].flagged) { 109 if (moderation.data.results[0].flagged) {
105 res.json({ 110 res.json({
106 success: false, 111 success: false,
107 message: "I'm sorry, but I can't assist with that. We want everyone to use our tool safely and responsibly.\nIf you have any other questions or need advice on a different topic, feel free to ask." 112 message: "I'm sorry, but I can't assist with that. We want everyone to use our tool safely and responsibly.\nIf you have any other questions or need advice on a different topic, feel free to ask."
108 }); 113 });
109 res.end(); 114 res.end();
110 return; 115 return;
111 } 116 }
112 117
113 try { 118 try {
114 const response = await openai.createCompletion({ 119 const response = await openai.createCompletion({
115 model: `${currentModel}`,// "text-davinci-003", 120 model: `${currentModel}`,// "text-davinci-003",
116 prompt: query_prompt, 121 prompt: query_prompt,
117 max_tokens: 3000, 122 max_tokens: 3000,
118 temperature, 123 temperature,
119 }); 124 });
120 let input = response.data.choices[0].text; 125 let input = response.data.choices[0].text;
121 let usage = {}; 126 let usage = {};
122 let enc = null; 127 let enc = null;
123 try { 128 try {
124 enc = encodingForModel(tiktokenModels.includes(currentModel) ? currentModel : 'gpt-3.5-turbo'); 129 enc = encodingForModel(tiktokenModels.includes(currentModel) ? currentModel : 'gpt-3.5-turbo');
125 usage.prompt_tokens = (enc.encode(query_prompt)).length; 130 usage.prompt_tokens = (enc.encode(query_prompt)).length;
126 usage.completion_tokens = (enc.encode(input)).length; 131 usage.completion_tokens = (enc.encode(input)).length;
127 usage.total_tokens = usage.prompt_tokens + usage.completion_tokens; 132 usage.total_tokens = usage.prompt_tokens + usage.completion_tokens;
128 } catch (e) { 133 } catch (e) {
129 console.log('Error encoding prompt text', e); 134 console.log('Error encoding prompt text', e);
130 } 135 }
131 136
132 res.json({ 137 res.json({
133 usage: usage, 138 usage: usage,
134 message: anchorme({ 139 message: anchorme({
135 input, 140 input,
136 options: { 141 options: {
137 attributes: { 142 attributes: {
138 target: "_blank" 143 target: "_blank"
139 }, 144 },
140 } 145 }
141 }) 146 })
142 }) 147 })
143 } catch (e) { 148 } catch (e) {
144 let error_msg = e.response.data.error.message ? e.response.data.error.message : ''; 149 let error_msg = e.response.data.error.message ? e.response.data.error.message : '';
145 if (error_msg.indexOf('maximum context length')>=0){ 150 if (error_msg.indexOf('maximum context length') >= 0) {
146 res.json({ 151 res.json({
147 message: "The output for your prompt is too long for us to process. Please reduce your prompt and try again.", 152 message: "The output for your prompt is too long for us to process. Please reduce your prompt and try again.",
148 }) 153 })
149 }else{ 154 } else {
150 console.log(e.response); 155 console.log(e.response);
151 } 156 }
152 } finally { 157 } finally {
153 // console.log('We do cleanup here'); 158 // console.log('We do cleanup here');
154 } 159 }
155 }); 160 });
156 161
157 async function runGPTTurbo(req, res) { 162 async function runGPTTurbo(req, res) {
158 // "gpt-3.5-turbo" 163 // "gpt-3.5-turbo"
159 const { message, currentModel, temperature } = req.body; 164 const { message, currentModel, temperature } = req.body;
160 var input = ''; 165 var input = '';
161 const message_history = JSON.parse(message); 166 const message_history = JSON.parse(message);
162 const query_prompt = message_history.length ? message_history[message_history.length - 1].content : ""; 167 const query_prompt = message_history.length ? message_history[message_history.length - 1].content : "";
163 const moderation = await axios.post("https://api.openai.com/v1/moderations", { 168 const moderation = await axios.post("https://api.openai.com/v1/moderations", {
164 input: query_prompt 169 input: query_prompt
165 }, { headers: { 'content-type': 'application/json', 'Authorization': `Bearer ${process.env.OPENAI_API_KEY}` } }); 170 }, { headers: { 'content-type': 'application/json', 'Authorization': `Bearer ${process.env.OPENAI_API_KEY}` } });
166 171
167 if(moderation.data.results[0].flagged) { 172 if (moderation.data.results[0].flagged) {
168 res.json({ 173 res.json({
169 success: false, 174 success: false,
170 message: "I'm sorry, but I can't assist with that. We want everyone to use our tool safely and responsibly.\nIf you have any other questions or need advice on a different topic, feel free to ask." 175 message: "I'm sorry, but I can't assist with that. We want everyone to use our tool safely and responsibly.\nIf you have any other questions or need advice on a different topic, feel free to ask."
171 }); 176 });
172 res.end(); 177 res.end();
173 return; 178 return;
174 } 179 }
175 try { 180 try {
176 const response = await openai.createChatCompletion({ 181 const response = await openai.createChatCompletion({
177 model: `${currentModel}`, 182 model: `${currentModel}`,
178 messages: JSON.parse(message), 183 messages: JSON.parse(message),
179 max_tokens: 3000, 184 max_tokens: 3000,
180 temperature 185 temperature
181 }); 186 });
182 input = response.data.choices[0].message.content 187 input = response.data.choices[0].message.content
183 } catch (e) { 188 } catch (e) {
184 let error_msg = e.response.data.error.message ? e.response.data.error.message : ''; 189 let error_msg = e.response.data.error.message ? e.response.data.error.message : '';
185 if (error_msg.indexOf('maximum context length')>=0){ 190 if (error_msg.indexOf('maximum context length') >= 0) {
186 input = "The output for your prompt is too long for us to process. Please reduce your prompt and try again."; 191 input = "The output for your prompt is too long for us to process. Please reduce your prompt and try again.";
187 }else{ 192 } else {
188 console.log(e.response); 193 console.log(e.response);
189 } 194 }
190 } finally { 195 } finally {
191 196
192 let usage = {}; 197 let usage = {};
193 let enc = null; 198 let enc = null;
194 try { 199 try {
195 enc = encodingForModel(tiktokenModels.includes(currentModel) ? currentModel : 'gpt-3.5-turbo'); 200 enc = encodingForModel(tiktokenModels.includes(currentModel) ? currentModel : 'gpt-3.5-turbo');
196 usage.prompt_tokens = (enc.encode(query_prompt)).length; 201 usage.prompt_tokens = (enc.encode(query_prompt)).length;
197 usage.completion_tokens = (enc.encode(input)).length; 202 usage.completion_tokens = (enc.encode(input)).length;
198 usage.total_tokens = usage.prompt_tokens + usage.completion_tokens; 203 usage.total_tokens = usage.prompt_tokens + usage.completion_tokens;
199 } catch (e) { 204 } catch (e) {
200 console.log('Error encoding prompt text', e); 205 console.log('Error encoding prompt text', e);
201 } 206 }
202 207
203 res.json({ 208 res.json({
204 prompt: JSON.parse(message), 209 prompt: JSON.parse(message),
205 usage: usage, 210 usage: usage,
206 message: anchorme({ 211 message: anchorme({
207 input, 212 input,
208 options: { 213 options: {
209 attributes: { 214 attributes: {
210 target: "_blank" 215 target: "_blank"
211 }, 216 },
212 } 217 }
213 }) 218 })
214 }); 219 });
215 return; 220 return;
216 } 221 }
222 }
223
224 const get_endpoint_api_url = (currentModel) => {
225 const OPENSOURCE_ENDPOINTS = process.env.OPENSOURCE_ENDPOINTS;
226 const endpoints = JSON.parse(OPENSOURCE_ENDPOINTS);
227 const endpoint_api_url = endpoints?.[currentModel];
228 return endpoint_api_url
229 }
230 async function runOpensource(req, res) {
231 const { message, currentModel, temperature } = req.body;
232 var input = '';
233 const message_history = JSON.parse(message);
234 const query_prompt = message_history.length ? message_history[message_history.length - 1].content : "";
235
236 try {
237 const endpoint_api_url = get_endpoint_api_url(currentModel);
238 console.log('endpoint_api_url', endpoint_api_url);
239 const response = await axios.post(endpoint_api_url + '/chat/completions', {
240 messages: JSON.parse(message),
241 temperature
242 }, {
243 headers: {
244 'Content-Type': 'application/json',
245 // 'Authorization': `Bearer ${process.env.OPENSOURCE_API_KEY}`
246 },
247 });
248 console.log(" zephyr response", response.data.choices[0])
249 input = response.data.choices[0].message.content
250 } catch (e) {
251 let error_msg = e.response.data.error.message ? e.response.data.error.message : '';
252 if (error_msg.indexOf('maximum context length') >= 0) {
253 input = "The output for your prompt is too long for us to process. Please reduce your prompt and try again.";
254 } else {
255 console.log(e.response);
256 }
257 } finally {
258
259 let usage = {};
260 let enc = null;
261 try {
262 enc = encodingForModel('gpt-3.5-turbo');
263 usage.prompt_tokens = (enc.encode(query_prompt)).length;
264 usage.completion_tokens = (enc.encode(input)).length;
265 usage.total_tokens = usage.prompt_tokens + usage.completion_tokens;
266 } catch (e) {
267 console.log('Error encoding prompt text', e);
268 }
269
270 res.json({
271 prompt: JSON.parse(message),
272 usage: usage,
273 message: anchorme({
274 input,
275 options: {
276 attributes: {
277 target: "_blank"
278 },
279 }
280 })
281 });
282 return;
283 }
217 } 284 }
218 285
286
287
219 // Get Models Route 288 // Get Models Route
220 app.get('/models', async (req, res) => { 289 app.get('/models', async (req, res) => {
221 const response = await openai.listEngines(); 290 const response = await openai.listEngines();
222 res.json({ 291 const models = response.data;
223 models: response.data 292 const opensource_models = process.env.OPENSOURCE_MODELS ? process.env.OPENSOURCE_MODELS.split(',') : [];
224 }) 293 opensource_models.forEach((model) => {
294 models.data.push({
295 id: model,
296 });
297 })
298
299 res.json({
300 models
301 })
225 }); 302 });
226 303
227 // Start the server 304 // Start the server
228 app.listen(port, () => { 305 app.listen(port, () => {
229 console.log(`Example app listening at http://localhost:${port}`) 306 console.log(`Example app listening at http://localhost:${port}`)
230 }); 307 });
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -10,11 +10,15 @@ ...@@ -10,11 +10,15 @@
10 "license": "ISC", 10 "license": "ISC",
11 "dependencies": { 11 "dependencies": {
12 "anchorme": "^2.1.2", 12 "anchorme": "^2.1.2",
13 "axios": "^1.5.1",
13 "body-parser": "^1.20.1", 14 "body-parser": "^1.20.1",
15 "cookie": "0.5.0",
16 "cookie-parser": "1.4.6",
14 "cors": "^2.8.5", 17 "cors": "^2.8.5",
15 "dotenv": "^16.0.3", 18 "dotenv": "^16.0.3",
16 "express": "^4.18.2", 19 "express": "^4.18.2",
17 "express-rate-limit": "^6.7.0", 20 "express-rate-limit": "^6.7.0",
21 "js-tiktoken": "1.0.7",
18 "morgan": "^1.10.0", 22 "morgan": "^1.10.0",
19 "openai": "^3.2.0" 23 "openai": "^3.2.0"
20 } 24 }
...@@ -47,13 +51,34 @@ ...@@ -47,13 +51,34 @@
47 "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" 51 "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
48 }, 52 },
49 "node_modules/axios": { 53 "node_modules/axios": {
50 "version": "0.26.1", 54 "version": "1.6.2",
51 "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", 55 "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz",
52 "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", 56 "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==",
53 "dependencies": { 57 "dependencies": {
54 "follow-redirects": "^1.14.8" 58 "follow-redirects": "^1.15.0",
59 "form-data": "^4.0.0",
60 "proxy-from-env": "^1.1.0"
55 } 61 }
56 }, 62 },
63 "node_modules/base64-js": {
64 "version": "1.5.1",
65 "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
66 "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
67 "funding": [
68 {
69 "type": "github",
70 "url": "https://github.com/sponsors/feross"
71 },
72 {
73 "type": "patreon",
74 "url": "https://www.patreon.com/feross"
75 },
76 {
77 "type": "consulting",
78 "url": "https://feross.org/support"
79 }
80 ]
81 },
57 "node_modules/basic-auth": { 82 "node_modules/basic-auth": {
58 "version": "2.0.1", 83 "version": "2.0.1",
59 "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", 84 "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz",
...@@ -151,6 +176,26 @@ ...@@ -151,6 +176,26 @@
151 "node": ">= 0.6" 176 "node": ">= 0.6"
152 } 177 }
153 }, 178 },
179 "node_modules/cookie-parser": {
180 "version": "1.4.6",
181 "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.6.tgz",
182 "integrity": "sha512-z3IzaNjdwUC2olLIB5/ITd0/setiaFMLYiZJle7xg5Fe9KWAceil7xszYfHHBtDFYLSgJduS2Ty0P1uJdPDJeA==",
183 "dependencies": {
184 "cookie": "0.4.1",
185 "cookie-signature": "1.0.6"
186 },
187 "engines": {
188 "node": ">= 0.8.0"
189 }
190 },
191 "node_modules/cookie-parser/node_modules/cookie": {
192 "version": "0.4.1",
193 "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz",
194 "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==",
195 "engines": {
196 "node": ">= 0.6"
197 }
198 },
154 "node_modules/cookie-signature": { 199 "node_modules/cookie-signature": {
155 "version": "1.0.6", 200 "version": "1.0.6",
156 "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 201 "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
...@@ -431,6 +476,14 @@ ...@@ -431,6 +476,14 @@
431 "node": ">= 0.10" 476 "node": ">= 0.10"
432 } 477 }
433 }, 478 },
479 "node_modules/js-tiktoken": {
480 "version": "1.0.7",
481 "resolved": "https://registry.npmjs.org/js-tiktoken/-/js-tiktoken-1.0.7.tgz",
482 "integrity": "sha512-biba8u/clw7iesNEWLOLwrNGoBP2lA+hTaBLs/D45pJdUPFXyxD6nhcDVtADChghv4GgyAiMKYMiRx7x6h7Biw==",
483 "dependencies": {
484 "base64-js": "^1.5.1"
485 }
486 },
434 "node_modules/media-typer": { 487 "node_modules/media-typer": {
435 "version": "0.3.0", 488 "version": "0.3.0",
436 "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", 489 "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
...@@ -565,6 +618,14 @@ ...@@ -565,6 +618,14 @@
565 "form-data": "^4.0.0" 618 "form-data": "^4.0.0"
566 } 619 }
567 }, 620 },
621 "node_modules/openai/node_modules/axios": {
622 "version": "0.26.1",
623 "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz",
624 "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==",
625 "dependencies": {
626 "follow-redirects": "^1.14.8"
627 }
628 },
568 "node_modules/parseurl": { 629 "node_modules/parseurl": {
569 "version": "1.3.3", 630 "version": "1.3.3",
570 "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", 631 "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
...@@ -590,6 +651,11 @@ ...@@ -590,6 +651,11 @@
590 "node": ">= 0.10" 651 "node": ">= 0.10"
591 } 652 }
592 }, 653 },
654 "node_modules/proxy-from-env": {
655 "version": "1.1.0",
656 "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
657 "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
658 },
593 "node_modules/qs": { 659 "node_modules/qs": {
594 "version": "6.11.0", 660 "version": "6.11.0",
595 "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", 661 "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!