66c9f735 by Bryan Batac

- Added Redis

- Modifed the getmodel implementation
1 parent d6d461cd
...@@ -11,9 +11,11 @@ ...@@ -11,9 +11,11 @@
11 "@testing-library/jest-dom": "^5.16.5", 11 "@testing-library/jest-dom": "^5.16.5",
12 "@testing-library/react": "^13.4.0", 12 "@testing-library/react": "^13.4.0",
13 "@testing-library/user-event": "^13.5.0", 13 "@testing-library/user-event": "^13.5.0",
14 "js-cookie": "^3.0.5",
14 "react": "^18.2.0", 15 "react": "^18.2.0",
15 "react-dom": "^18.2.0", 16 "react-dom": "^18.2.0",
16 "react-scripts": "5.0.1", 17 "react-scripts": "5.0.1",
18 "serve": "^14.2.1",
17 "web-vitals": "^2.1.4" 19 "web-vitals": "^2.1.4"
18 }, 20 },
19 "devDependencies": { 21 "devDependencies": {
...@@ -4641,6 +4643,11 @@ ...@@ -4641,6 +4643,11 @@
4641 "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz", 4643 "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz",
4642 "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==" 4644 "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ=="
4643 }, 4645 },
4646 "node_modules/@zeit/schemas": {
4647 "version": "2.36.0",
4648 "resolved": "https://registry.npmjs.org/@zeit/schemas/-/schemas-2.36.0.tgz",
4649 "integrity": "sha512-7kjMwcChYEzMKjeex9ZFXkt1AyNov9R5HZtjBKVsmVpw7pa7ZtlCGvCBC2vnnXctaYN+aRI61HjIqeetZW5ROg=="
4650 },
4644 "node_modules/abab": { 4651 "node_modules/abab": {
4645 "version": "2.0.6", 4652 "version": "2.0.6",
4646 "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz", 4653 "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz",
...@@ -4796,6 +4803,14 @@ ...@@ -4796,6 +4803,14 @@
4796 } 4803 }
4797 } 4804 }
4798 }, 4805 },
4806 "node_modules/ansi-align": {
4807 "version": "3.0.1",
4808 "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.1.tgz",
4809 "integrity": "sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w==",
4810 "dependencies": {
4811 "string-width": "^4.1.0"
4812 }
4813 },
4799 "node_modules/ansi-escapes": { 4814 "node_modules/ansi-escapes": {
4800 "version": "4.3.2", 4815 "version": "4.3.2",
4801 "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", 4816 "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz",
...@@ -4866,6 +4881,25 @@ ...@@ -4866,6 +4881,25 @@
4866 "node": ">= 8" 4881 "node": ">= 8"
4867 } 4882 }
4868 }, 4883 },
4884 "node_modules/arch": {
4885 "version": "2.2.0",
4886 "resolved": "https://registry.npmjs.org/arch/-/arch-2.2.0.tgz",
4887 "integrity": "sha512-Of/R0wqp83cgHozfIYLbBMnej79U/SVGOOyuB3VVFv1NRM/PSFMK12x9KVtiYzJqmnU5WR2qp0Z5rHb7sWGnFQ==",
4888 "funding": [
4889 {
4890 "type": "github",
4891 "url": "https://github.com/sponsors/feross"
4892 },
4893 {
4894 "type": "patreon",
4895 "url": "https://www.patreon.com/feross"
4896 },
4897 {
4898 "type": "consulting",
4899 "url": "https://feross.org/support"
4900 }
4901 ]
4902 },
4869 "node_modules/arg": { 4903 "node_modules/arg": {
4870 "version": "5.0.2", 4904 "version": "5.0.2",
4871 "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", 4905 "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz",
...@@ -5456,6 +5490,128 @@ ...@@ -5456,6 +5490,128 @@
5456 "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", 5490 "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
5457 "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==" 5491 "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww=="
5458 }, 5492 },
5493 "node_modules/boxen": {
5494 "version": "7.0.0",
5495 "resolved": "https://registry.npmjs.org/boxen/-/boxen-7.0.0.tgz",
5496 "integrity": "sha512-j//dBVuyacJbvW+tvZ9HuH03fZ46QcaKvvhZickZqtB271DxJ7SNRSNxrV/dZX0085m7hISRZWbzWlJvx/rHSg==",
5497 "dependencies": {
5498 "ansi-align": "^3.0.1",
5499 "camelcase": "^7.0.0",
5500 "chalk": "^5.0.1",
5501 "cli-boxes": "^3.0.0",
5502 "string-width": "^5.1.2",
5503 "type-fest": "^2.13.0",
5504 "widest-line": "^4.0.1",
5505 "wrap-ansi": "^8.0.1"
5506 },
5507 "engines": {
5508 "node": ">=14.16"
5509 },
5510 "funding": {
5511 "url": "https://github.com/sponsors/sindresorhus"
5512 }
5513 },
5514 "node_modules/boxen/node_modules/ansi-regex": {
5515 "version": "6.1.0",
5516 "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz",
5517 "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==",
5518 "engines": {
5519 "node": ">=12"
5520 },
5521 "funding": {
5522 "url": "https://github.com/chalk/ansi-regex?sponsor=1"
5523 }
5524 },
5525 "node_modules/boxen/node_modules/ansi-styles": {
5526 "version": "6.2.1",
5527 "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz",
5528 "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==",
5529 "engines": {
5530 "node": ">=12"
5531 },
5532 "funding": {
5533 "url": "https://github.com/chalk/ansi-styles?sponsor=1"
5534 }
5535 },
5536 "node_modules/boxen/node_modules/camelcase": {
5537 "version": "7.0.1",
5538 "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-7.0.1.tgz",
5539 "integrity": "sha512-xlx1yCK2Oc1APsPXDL2LdlNP6+uu8OCDdhOBSVT279M/S+y75O30C2VuD8T2ogdePBBl7PfPF4504tnLgX3zfw==",
5540 "engines": {
5541 "node": ">=14.16"
5542 },
5543 "funding": {
5544 "url": "https://github.com/sponsors/sindresorhus"
5545 }
5546 },
5547 "node_modules/boxen/node_modules/chalk": {
5548 "version": "5.3.0",
5549 "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz",
5550 "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==",
5551 "engines": {
5552 "node": "^12.17.0 || ^14.13 || >=16.0.0"
5553 },
5554 "funding": {
5555 "url": "https://github.com/chalk/chalk?sponsor=1"
5556 }
5557 },
5558 "node_modules/boxen/node_modules/string-width": {
5559 "version": "5.1.2",
5560 "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",
5561 "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==",
5562 "dependencies": {
5563 "eastasianwidth": "^0.2.0",
5564 "emoji-regex": "^9.2.2",
5565 "strip-ansi": "^7.0.1"
5566 },
5567 "engines": {
5568 "node": ">=12"
5569 },
5570 "funding": {
5571 "url": "https://github.com/sponsors/sindresorhus"
5572 }
5573 },
5574 "node_modules/boxen/node_modules/strip-ansi": {
5575 "version": "7.1.0",
5576 "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz",
5577 "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==",
5578 "dependencies": {
5579 "ansi-regex": "^6.0.1"
5580 },
5581 "engines": {
5582 "node": ">=12"
5583 },
5584 "funding": {
5585 "url": "https://github.com/chalk/strip-ansi?sponsor=1"
5586 }
5587 },
5588 "node_modules/boxen/node_modules/type-fest": {
5589 "version": "2.19.0",
5590 "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz",
5591 "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==",
5592 "engines": {
5593 "node": ">=12.20"
5594 },
5595 "funding": {
5596 "url": "https://github.com/sponsors/sindresorhus"
5597 }
5598 },
5599 "node_modules/boxen/node_modules/wrap-ansi": {
5600 "version": "8.1.0",
5601 "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz",
5602 "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==",
5603 "dependencies": {
5604 "ansi-styles": "^6.1.0",
5605 "string-width": "^5.0.1",
5606 "strip-ansi": "^7.0.1"
5607 },
5608 "engines": {
5609 "node": ">=12"
5610 },
5611 "funding": {
5612 "url": "https://github.com/chalk/wrap-ansi?sponsor=1"
5613 }
5614 },
5459 "node_modules/brace-expansion": { 5615 "node_modules/brace-expansion": {
5460 "version": "1.1.11", 5616 "version": "1.1.11",
5461 "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 5617 "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
...@@ -5639,6 +5795,35 @@ ...@@ -5639,6 +5795,35 @@
5639 "node": ">=8" 5795 "node": ">=8"
5640 } 5796 }
5641 }, 5797 },
5798 "node_modules/chalk-template": {
5799 "version": "0.4.0",
5800 "resolved": "https://registry.npmjs.org/chalk-template/-/chalk-template-0.4.0.tgz",
5801 "integrity": "sha512-/ghrgmhfY8RaSdeo43hNXxpoHAtxdbskUHjPpfqUWGttFgycUhYPGx3YZBCnUCvOa7Doivn1IZec3DEGFoMgLg==",
5802 "dependencies": {
5803 "chalk": "^4.1.2"
5804 },
5805 "engines": {
5806 "node": ">=12"
5807 },
5808 "funding": {
5809 "url": "https://github.com/chalk/chalk-template?sponsor=1"
5810 }
5811 },
5812 "node_modules/chalk-template/node_modules/chalk": {
5813 "version": "4.1.2",
5814 "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
5815 "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
5816 "dependencies": {
5817 "ansi-styles": "^4.1.0",
5818 "supports-color": "^7.1.0"
5819 },
5820 "engines": {
5821 "node": ">=10"
5822 },
5823 "funding": {
5824 "url": "https://github.com/chalk/chalk?sponsor=1"
5825 }
5826 },
5642 "node_modules/char-regex": { 5827 "node_modules/char-regex": {
5643 "version": "1.0.2", 5828 "version": "1.0.2",
5644 "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", 5829 "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz",
...@@ -5735,6 +5920,33 @@ ...@@ -5735,6 +5920,33 @@
5735 "node": ">=0.10.0" 5920 "node": ">=0.10.0"
5736 } 5921 }
5737 }, 5922 },
5923 "node_modules/cli-boxes": {
5924 "version": "3.0.0",
5925 "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-3.0.0.tgz",
5926 "integrity": "sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g==",
5927 "engines": {
5928 "node": ">=10"
5929 },
5930 "funding": {
5931 "url": "https://github.com/sponsors/sindresorhus"
5932 }
5933 },
5934 "node_modules/clipboardy": {
5935 "version": "3.0.0",
5936 "resolved": "https://registry.npmjs.org/clipboardy/-/clipboardy-3.0.0.tgz",
5937 "integrity": "sha512-Su+uU5sr1jkUy1sGRpLKjKrvEOVXgSgiSInwa/qeID6aJ07yh+5NWc3h2QfjHjBnfX4LhtFcuAWKUsJ3r+fjbg==",
5938 "dependencies": {
5939 "arch": "^2.2.0",
5940 "execa": "^5.1.1",
5941 "is-wsl": "^2.2.0"
5942 },
5943 "engines": {
5944 "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
5945 },
5946 "funding": {
5947 "url": "https://github.com/sponsors/sindresorhus"
5948 }
5949 },
5738 "node_modules/cliui": { 5950 "node_modules/cliui": {
5739 "version": "7.0.4", 5951 "version": "7.0.4",
5740 "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", 5952 "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz",
...@@ -6501,6 +6713,14 @@ ...@@ -6501,6 +6713,14 @@
6501 "url": "https://github.com/sponsors/ljharb" 6713 "url": "https://github.com/sponsors/ljharb"
6502 } 6714 }
6503 }, 6715 },
6716 "node_modules/deep-extend": {
6717 "version": "0.6.0",
6718 "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz",
6719 "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==",
6720 "engines": {
6721 "node": ">=4.0.0"
6722 }
6723 },
6504 "node_modules/deep-is": { 6724 "node_modules/deep-is": {
6505 "version": "0.1.4", 6725 "version": "0.1.4",
6506 "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", 6726 "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
...@@ -6818,6 +7038,11 @@ ...@@ -6818,6 +7038,11 @@
6818 "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", 7038 "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz",
6819 "integrity": "sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==" 7039 "integrity": "sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg=="
6820 }, 7040 },
7041 "node_modules/eastasianwidth": {
7042 "version": "0.2.0",
7043 "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
7044 "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA=="
7045 },
6821 "node_modules/ee-first": { 7046 "node_modules/ee-first": {
6822 "version": "1.1.1", 7047 "version": "1.1.1",
6823 "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 7048 "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
...@@ -7902,6 +8127,19 @@ ...@@ -7902,6 +8127,19 @@
7902 "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", 8127 "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
7903 "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==" 8128 "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw=="
7904 }, 8129 },
8130 "node_modules/fast-url-parser": {
8131 "version": "1.1.3",
8132 "resolved": "https://registry.npmjs.org/fast-url-parser/-/fast-url-parser-1.1.3.tgz",
8133 "integrity": "sha512-5jOCVXADYNuRkKFzNJ0dCCewsZiYo0dz8QNYljkOpFC6r2U4OBmKtvm/Tsuh4w1YYdDqDb31a8TVhBJ2OJKdqQ==",
8134 "dependencies": {
8135 "punycode": "^1.3.2"
8136 }
8137 },
8138 "node_modules/fast-url-parser/node_modules/punycode": {
8139 "version": "1.4.1",
8140 "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
8141 "integrity": "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ=="
8142 },
7905 "node_modules/fastq": { 8143 "node_modules/fastq": {
7906 "version": "1.15.0", 8144 "version": "1.15.0",
7907 "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", 8145 "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz",
...@@ -9293,6 +9531,17 @@ ...@@ -9293,6 +9531,17 @@
9293 "url": "https://github.com/sponsors/sindresorhus" 9531 "url": "https://github.com/sponsors/sindresorhus"
9294 } 9532 }
9295 }, 9533 },
9534 "node_modules/is-port-reachable": {
9535 "version": "4.0.0",
9536 "resolved": "https://registry.npmjs.org/is-port-reachable/-/is-port-reachable-4.0.0.tgz",
9537 "integrity": "sha512-9UoipoxYmSk6Xy7QFgRv2HDyaysmgSG75TFQs6S+3pDM7ZhKTF/bskZV+0UlABHzKjNVhPjYCLfeZUEg1wXxig==",
9538 "engines": {
9539 "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
9540 },
9541 "funding": {
9542 "url": "https://github.com/sponsors/sindresorhus"
9543 }
9544 },
9296 "node_modules/is-potential-custom-element-name": { 9545 "node_modules/is-potential-custom-element-name": {
9297 "version": "1.0.1", 9546 "version": "1.0.1",
9298 "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", 9547 "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
...@@ -11918,6 +12167,14 @@ ...@@ -11918,6 +12167,14 @@
11918 "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" 12167 "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
11919 } 12168 }
11920 }, 12169 },
12170 "node_modules/js-cookie": {
12171 "version": "3.0.5",
12172 "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.5.tgz",
12173 "integrity": "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==",
12174 "engines": {
12175 "node": ">=14"
12176 }
12177 },
11921 "node_modules/js-sdsl": { 12178 "node_modules/js-sdsl": {
11922 "version": "4.3.0", 12179 "version": "4.3.0",
11923 "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.3.0.tgz", 12180 "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.3.0.tgz",
...@@ -12948,6 +13205,11 @@ ...@@ -12948,6 +13205,11 @@
12948 "node": ">=0.10.0" 13205 "node": ">=0.10.0"
12949 } 13206 }
12950 }, 13207 },
13208 "node_modules/path-is-inside": {
13209 "version": "1.0.2",
13210 "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz",
13211 "integrity": "sha512-DUWJr3+ULp4zXmol/SZkFf3JGsS9/SIv+Y3Rt93/UjPpDpklB5f1er4O3POIbUuUJ3FXgqte2Q7SrU6zAqwk8w=="
13212 },
12951 "node_modules/path-key": { 13213 "node_modules/path-key": {
12952 "version": "3.1.1", 13214 "version": "3.1.1",
12953 "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", 13215 "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
...@@ -14599,6 +14861,28 @@ ...@@ -14599,6 +14861,28 @@
14599 "node": ">= 0.8" 14861 "node": ">= 0.8"
14600 } 14862 }
14601 }, 14863 },
14864 "node_modules/rc": {
14865 "version": "1.2.8",
14866 "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz",
14867 "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==",
14868 "dependencies": {
14869 "deep-extend": "^0.6.0",
14870 "ini": "~1.3.0",
14871 "minimist": "^1.2.0",
14872 "strip-json-comments": "~2.0.1"
14873 },
14874 "bin": {
14875 "rc": "cli.js"
14876 }
14877 },
14878 "node_modules/rc/node_modules/strip-json-comments": {
14879 "version": "2.0.1",
14880 "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
14881 "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==",
14882 "engines": {
14883 "node": ">=0.10.0"
14884 }
14885 },
14602 "node_modules/react": { 14886 "node_modules/react": {
14603 "version": "18.2.0", 14887 "version": "18.2.0",
14604 "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", 14888 "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz",
...@@ -14928,6 +15212,26 @@ ...@@ -14928,6 +15212,26 @@
14928 "node": ">=4" 15212 "node": ">=4"
14929 } 15213 }
14930 }, 15214 },
15215 "node_modules/registry-auth-token": {
15216 "version": "3.3.2",
15217 "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.3.2.tgz",
15218 "integrity": "sha512-JL39c60XlzCVgNrO+qq68FoNb56w/m7JYvGR2jT5iR1xBrUA3Mfx5Twk5rqTThPmQKMWydGmq8oFtDlxfrmxnQ==",
15219 "dependencies": {
15220 "rc": "^1.1.6",
15221 "safe-buffer": "^5.0.1"
15222 }
15223 },
15224 "node_modules/registry-url": {
15225 "version": "3.1.0",
15226 "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-3.1.0.tgz",
15227 "integrity": "sha512-ZbgR5aZEdf4UKZVBPYIgaglBmSF2Hi94s2PcIHhRGFjKYu+chjJdYfHn4rt3hB6eCKLJ8giVIIfgMa1ehDfZKA==",
15228 "dependencies": {
15229 "rc": "^1.0.1"
15230 },
15231 "engines": {
15232 "node": ">=0.10.0"
15233 }
15234 },
14931 "node_modules/regjsgen": { 15235 "node_modules/regjsgen": {
14932 "version": "0.7.1", 15236 "version": "0.7.1",
14933 "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.7.1.tgz", 15237 "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.7.1.tgz",
...@@ -15520,6 +15824,85 @@ ...@@ -15520,6 +15824,85 @@
15520 "randombytes": "^2.1.0" 15824 "randombytes": "^2.1.0"
15521 } 15825 }
15522 }, 15826 },
15827 "node_modules/serve": {
15828 "version": "14.2.3",
15829 "resolved": "https://registry.npmjs.org/serve/-/serve-14.2.3.tgz",
15830 "integrity": "sha512-VqUFMC7K3LDGeGnJM9h56D3XGKb6KGgOw0cVNtA26yYXHCcpxf3xwCTUaQoWlVS7i8Jdh3GjQkOB23qsXyjoyQ==",
15831 "dependencies": {
15832 "@zeit/schemas": "2.36.0",
15833 "ajv": "8.12.0",
15834 "arg": "5.0.2",
15835 "boxen": "7.0.0",
15836 "chalk": "5.0.1",
15837 "chalk-template": "0.4.0",
15838 "clipboardy": "3.0.0",
15839 "compression": "1.7.4",
15840 "is-port-reachable": "4.0.0",
15841 "serve-handler": "6.1.5",
15842 "update-check": "1.5.4"
15843 },
15844 "bin": {
15845 "serve": "build/main.js"
15846 },
15847 "engines": {
15848 "node": ">= 14"
15849 }
15850 },
15851 "node_modules/serve-handler": {
15852 "version": "6.1.5",
15853 "resolved": "https://registry.npmjs.org/serve-handler/-/serve-handler-6.1.5.tgz",
15854 "integrity": "sha512-ijPFle6Hwe8zfmBxJdE+5fta53fdIY0lHISJvuikXB3VYFafRjMRpOffSPvCYsbKyBA7pvy9oYr/BT1O3EArlg==",
15855 "dependencies": {
15856 "bytes": "3.0.0",
15857 "content-disposition": "0.5.2",
15858 "fast-url-parser": "1.1.3",
15859 "mime-types": "2.1.18",
15860 "minimatch": "3.1.2",
15861 "path-is-inside": "1.0.2",
15862 "path-to-regexp": "2.2.1",
15863 "range-parser": "1.2.0"
15864 }
15865 },
15866 "node_modules/serve-handler/node_modules/content-disposition": {
15867 "version": "0.5.2",
15868 "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz",
15869 "integrity": "sha512-kRGRZw3bLlFISDBgwTSA1TMBFN6J6GWDeubmDE3AF+3+yXL8hTWv8r5rkLbqYXY4RjPk/EzHnClI3zQf1cFmHA==",
15870 "engines": {
15871 "node": ">= 0.6"
15872 }
15873 },
15874 "node_modules/serve-handler/node_modules/mime-db": {
15875 "version": "1.33.0",
15876 "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz",
15877 "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==",
15878 "engines": {
15879 "node": ">= 0.6"
15880 }
15881 },
15882 "node_modules/serve-handler/node_modules/mime-types": {
15883 "version": "2.1.18",
15884 "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz",
15885 "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==",
15886 "dependencies": {
15887 "mime-db": "~1.33.0"
15888 },
15889 "engines": {
15890 "node": ">= 0.6"
15891 }
15892 },
15893 "node_modules/serve-handler/node_modules/path-to-regexp": {
15894 "version": "2.2.1",
15895 "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-2.2.1.tgz",
15896 "integrity": "sha512-gu9bD6Ta5bwGrrU8muHzVOBFFREpp2iRkVfhBJahwJ6p6Xw20SjT0MxLnwkjOibQmGSYhiUnf2FLe7k+jcFmGQ=="
15897 },
15898 "node_modules/serve-handler/node_modules/range-parser": {
15899 "version": "1.2.0",
15900 "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz",
15901 "integrity": "sha512-kA5WQoNVo4t9lNx2kQNFCxKeBl5IbbSNBl1M/tLkw9WCn+hxNBAW5Qh8gdhs63CJnhjJ2zQWFoqPJP2sK1AV5A==",
15902 "engines": {
15903 "node": ">= 0.6"
15904 }
15905 },
15523 "node_modules/serve-index": { 15906 "node_modules/serve-index": {
15524 "version": "1.9.1", 15907 "version": "1.9.1",
15525 "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", 15908 "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz",
...@@ -15604,6 +15987,17 @@ ...@@ -15604,6 +15987,17 @@
15604 "node": ">= 0.8.0" 15987 "node": ">= 0.8.0"
15605 } 15988 }
15606 }, 15989 },
15990 "node_modules/serve/node_modules/chalk": {
15991 "version": "5.0.1",
15992 "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.0.1.tgz",
15993 "integrity": "sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w==",
15994 "engines": {
15995 "node": "^12.17.0 || ^14.13 || >=16.0.0"
15996 },
15997 "funding": {
15998 "url": "https://github.com/chalk/chalk?sponsor=1"
15999 }
16000 },
15607 "node_modules/setprototypeof": { 16001 "node_modules/setprototypeof": {
15608 "version": "1.2.0", 16002 "version": "1.2.0",
15609 "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", 16003 "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
...@@ -16638,6 +17032,15 @@ ...@@ -16638,6 +17032,15 @@
16638 "browserslist": ">= 4.21.0" 17032 "browserslist": ">= 4.21.0"
16639 } 17033 }
16640 }, 17034 },
17035 "node_modules/update-check": {
17036 "version": "1.5.4",
17037 "resolved": "https://registry.npmjs.org/update-check/-/update-check-1.5.4.tgz",
17038 "integrity": "sha512-5YHsflzHP4t1G+8WGPlvKbJEbAJGCgw+Em+dGR1KmBUbr1J36SJBqlHLjR7oob7sco5hWHGQVcr9B2poIVDDTQ==",
17039 "dependencies": {
17040 "registry-auth-token": "3.3.2",
17041 "registry-url": "3.1.0"
17042 }
17043 },
16641 "node_modules/uri-js": { 17044 "node_modules/uri-js": {
16642 "version": "4.4.1", 17045 "version": "4.4.1",
16643 "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", 17046 "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
...@@ -17159,6 +17562,61 @@ ...@@ -17159,6 +17562,61 @@
17159 "url": "https://github.com/sponsors/ljharb" 17562 "url": "https://github.com/sponsors/ljharb"
17160 } 17563 }
17161 }, 17564 },
17565 "node_modules/widest-line": {
17566 "version": "4.0.1",
17567 "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-4.0.1.tgz",
17568 "integrity": "sha512-o0cyEG0e8GPzT4iGHphIOh0cJOV8fivsXxddQasHPHfoZf1ZexrfeA21w2NaEN1RHE+fXlfISmOE8R9N3u3Qig==",
17569 "dependencies": {
17570 "string-width": "^5.0.1"
17571 },
17572 "engines": {
17573 "node": ">=12"
17574 },
17575 "funding": {
17576 "url": "https://github.com/sponsors/sindresorhus"
17577 }
17578 },
17579 "node_modules/widest-line/node_modules/ansi-regex": {
17580 "version": "6.1.0",
17581 "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz",
17582 "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==",
17583 "engines": {
17584 "node": ">=12"
17585 },
17586 "funding": {
17587 "url": "https://github.com/chalk/ansi-regex?sponsor=1"
17588 }
17589 },
17590 "node_modules/widest-line/node_modules/string-width": {
17591 "version": "5.1.2",
17592 "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",
17593 "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==",
17594 "dependencies": {
17595 "eastasianwidth": "^0.2.0",
17596 "emoji-regex": "^9.2.2",
17597 "strip-ansi": "^7.0.1"
17598 },
17599 "engines": {
17600 "node": ">=12"
17601 },
17602 "funding": {
17603 "url": "https://github.com/sponsors/sindresorhus"
17604 }
17605 },
17606 "node_modules/widest-line/node_modules/strip-ansi": {
17607 "version": "7.1.0",
17608 "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz",
17609 "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==",
17610 "dependencies": {
17611 "ansi-regex": "^6.0.1"
17612 },
17613 "engines": {
17614 "node": ">=12"
17615 },
17616 "funding": {
17617 "url": "https://github.com/chalk/strip-ansi?sponsor=1"
17618 }
17619 },
17162 "node_modules/word-wrap": { 17620 "node_modules/word-wrap": {
17163 "version": "1.2.3", 17621 "version": "1.2.3",
17164 "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", 17622 "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
......
...@@ -17,7 +17,6 @@ function App() { ...@@ -17,7 +17,6 @@ function App() {
17 const [models, setModels] = useState([]); 17 const [models, setModels] = useState([]);
18 const [temperature, setTemperature] = useState(0.7); 18 const [temperature, setTemperature] = useState(0.7);
19 const GPTTurbo = "gpt-3.5-turbo"; 19 const GPTTurbo = "gpt-3.5-turbo";
20 const GPTTurbo0301 = "gpt-3.5-turbo-0301";
21 const [currentModel, setCurrentModel] = useState(GPTTurbo); 20 const [currentModel, setCurrentModel] = useState(GPTTurbo);
22 const [chatLog, setChatLog] = useState([{ 21 const [chatLog, setChatLog] = useState([{
23 user: "gpt", 22 user: "gpt",
...@@ -79,6 +78,11 @@ function App() { ...@@ -79,6 +78,11 @@ function App() {
79 submitPrompt(); 78 submitPrompt();
80 } 79 }
81 80
81 const getEndpoint = (modelName) => {
82 const model = models.find((m) => m.id === modelName);
83 return model ? model.endpoint : null;
84 };
85
82 async function submitPrompt() { 86 async function submitPrompt() {
83 87
84 const TPLogicRun = window.TPLogicRun; 88 const TPLogicRun = window.TPLogicRun;
...@@ -112,16 +116,13 @@ function App() { ...@@ -112,16 +116,13 @@ function App() {
112 setChatLog(prevChatLog => [...prevChatLog, userMessage]); 116 setChatLog(prevChatLog => [...prevChatLog, userMessage]);
113 117
114 var messages = chatLogNew.map((message) => { if(message.user !== 'me') return message.message }).join("\n") 118 var messages = chatLogNew.map((message) => { if(message.user !== 'me') return message.message }).join("\n")
115 if(currentModel === GPTTurbo || currentModel === GPTTurbo0301) { 119 let endpoint = getEndpoint(currentModel);
116 // "gpt-3.5-turbo" 120 if(endpoint === "openAI") {
117 let chatLogTurboNew = [...chatLogTurbo, { role: "user", content: chatInput }]; 121 let chatLogTurboNew = [...chatLogTurbo, { role: "user", content: chatInput }];
118 setChatLogTurbo(chatLogTurboNew); 122 setChatLogTurbo(chatLogTurboNew);
119 messages = JSON.stringify(chatLogTurboNew); 123 messages = JSON.stringify(chatLogTurboNew);
120 } 124 }
121 125 if(endpoint === "Llama" || endpoint === "Opensource") {
122 if(currentModel === "openchat_3.5" || currentModel === "zephyr-7B-beta"
123 || currentModel === "meta-llama/Llama-3-8b-chat-hf" || currentModel === "google/gemma-2-9b-it") {
124 // "gpt-3.5-turbo"
125 let chatLogOpenSourceNew = [...chatLogOpenSource, { role: "user", content: chatInput }]; 126 let chatLogOpenSourceNew = [...chatLogOpenSource, { role: "user", content: chatInput }];
126 setChatLogOpenSource(chatLogOpenSourceNew); 127 setChatLogOpenSource(chatLogOpenSourceNew);
127 messages = JSON.stringify(chatLogOpenSourceNew); 128 messages = JSON.stringify(chatLogOpenSourceNew);
......
...@@ -3,6 +3,7 @@ const express = require('express') ...@@ -3,6 +3,7 @@ const express = require('express')
3 const bodyParser = require('body-parser') 3 const bodyParser = require('body-parser')
4 const cookieParser = require("cookie-parser") 4 const cookieParser = require("cookie-parser")
5 const cors = require('cors') 5 const cors = require('cors')
6 const { createClient } = require('redis')
6 require('dotenv').config() 7 require('dotenv').config()
7 const rateLimit = require('express-rate-limit') 8 const rateLimit = require('express-rate-limit')
8 const fetch = require('node-fetch'); 9 const fetch = require('node-fetch');
...@@ -48,6 +49,10 @@ const tiktokenModels = [ ...@@ -48,6 +49,10 @@ const tiktokenModels = [
48 'gpt-3.5-turbo-0301' 49 'gpt-3.5-turbo-0301'
49 ]; 50 ];
50 51
52 let client;
53 let filteredModels = {};
54 const allowedEndpoints = ["openAI", "Opensource", "Llama"];
55
51 // Open AI Configuration 56 // Open AI Configuration
52 // console.log(process.env.OPENAI_API_ORG) 57 // console.log(process.env.OPENAI_API_ORG)
53 const configuration = new Configuration({ 58 const configuration = new Configuration({
...@@ -85,18 +90,20 @@ app.post('/api', async (req, res) => { ...@@ -85,18 +90,20 @@ app.post('/api', async (req, res) => {
85 return; 90 return;
86 } 91 }
87 const { message, currentModel, temperature } = req.body; 92 const { message, currentModel, temperature } = req.body;
93 const getEndpoint = (modelName) => {
94 const model = Object.values(filteredModels).find(m => m.model === modelName);
95 return model ? model.endpoint : 'Endpoint not found';
96 };
88 97
89 if (currentModel == "gpt-3.5-turbo" || currentModel == "gpt-3.5-turbo-0301") { 98 const endpoint = getEndpoint(currentModel);
90 runGPTTurbo(req, res);
91 99
100 if (endpoint == "openAI") {
101 runGPTTurbo(req, res);
92 return; 102 return;
93 } 103 }
94 104
95 if (currentModel == "openchat_3.5" || currentModel == "zephyr-7B-beta" 105 if (endpoint == "Llama" || endpoint == "Opensource") {
96 || currentModel == "google/gemma-2-9b-it" || currentModel == "meta-llama/Llama-3-8b-chat-hf"
97 ) {
98 runOpensource(req, res); 106 runOpensource(req, res);
99
100 return; 107 return;
101 } 108 }
102 109
...@@ -267,18 +274,6 @@ async function runGPTTurbo(req, res) { ...@@ -267,18 +274,6 @@ async function runGPTTurbo(req, res) {
267 } 274 }
268 } 275 }
269 276
270 const get_endpoint_api_url = (currentModel) => {
271 const OPENSOURCE_ENDPOINTS = process.env.OPENSOURCE_ENDPOINTS;
272 const endpoints = JSON.parse(OPENSOURCE_ENDPOINTS);
273 const endpoint_api_url = endpoints?.[currentModel];
274 return endpoint_api_url
275 }
276 const get_endpoint_api_key = (currentModel) => {
277 const OPENSOURCE_API_KEY = process.env.OPENSOURCE_API_KEY;
278 const api_keys = JSON.parse(OPENSOURCE_API_KEY);
279 const key = api_keys?.[currentModel];
280 return key
281 }
282 async function runOpensource(req, res) { 277 async function runOpensource(req, res) {
283 const { message, currentModel, temperature, P6XcW47o: together_ai_response = null } = req.body; 278 const { message, currentModel, temperature, P6XcW47o: together_ai_response = null } = req.body;
284 var input = ''; 279 var input = '';
...@@ -294,9 +289,9 @@ async function runOpensource(req, res) { ...@@ -294,9 +289,9 @@ async function runOpensource(req, res) {
294 289
295 try { 290 try {
296 let error_msg = ""; 291 let error_msg = "";
297 const endpoint_api_url = get_endpoint_api_url(currentModel); 292 const endpoint_api_url = process.env.OPENSOURCE_ENDPOINTS;
298 const api_key = get_endpoint_api_key(currentModel); 293 const api_key = OPENSOURCE_API_KEY;
299 const response = await axios.post(endpoint_api_url + '/chat/completions', { 294 const response = await axios.post(endpoint_api_url, {
300 model: currentModel, 295 model: currentModel,
301 messages: JSON.parse(message), 296 messages: JSON.parse(message),
302 max_tokens: 2048, 297 max_tokens: 2048,
...@@ -525,31 +520,17 @@ const getClientIP = (req) => { ...@@ -525,31 +520,17 @@ const getClientIP = (req) => {
525 520
526 // Get Models Route 521 // Get Models Route
527 app.get('/models', async (req, res) => { 522 app.get('/models', async (req, res) => {
528 const openai_models = process.env.OPENAI_MODELS ? JSON.parse(process.env.OPENAI_MODELS) : [{"value": "gpt-3.5-turbo", "label": "GPT-3.5"}]; 523 await getModels()
529 const opensource_models = process.env.OPENSOURCE_MODELS ? JSON.parse(process.env.OPENSOURCE_MODELS) : [];
530
531 const models = { 524 const models = {
532 data: [] 525 data: Object.values(filteredModels).map((model) => ({
526 id: model.model,
527 label: model.name,
528 name: model.name,
529 beta: model.isBeta,
530 endpoint: model.endpoint
531 }))
533 }; 532 };
534 533
535 openai_models.forEach((model) => {
536 models.data.push({
537 id: model.value,
538 label: model.label,
539 name: model.label,
540 beta: false,
541 });
542 })
543
544 opensource_models.forEach((model) => {
545 models.data.push({
546 id: model.value,
547 label: model.label,
548 name: model.label,
549 beta: true,
550 });
551 })
552
553 res.json({ 534 res.json({
554 models 535 models
555 }) 536 })
...@@ -558,4 +539,53 @@ app.get('/models', async (req, res) => { ...@@ -558,4 +539,53 @@ app.get('/models', async (req, res) => {
558 // Start the server 539 // Start the server
559 app.listen(port, () => { 540 app.listen(port, () => {
560 console.log(`Example app listening at http://localhost:${port}`) 541 console.log(`Example app listening at http://localhost:${port}`)
561 });
...\ No newline at end of file ...\ No newline at end of file
542 });
543
544 const initializeRedisClient = () => {
545 const newClient = createClient({
546 socket: {
547 host: process.env.REDIS_HOST,
548 port: process.env.REDIS_PORT,
549 },
550 username: process.env.REDIS_USER,
551 password: process.env.REDIS_PASS,
552 });
553
554 newClient.on('error', (err) => {
555 console.error('Redis error:', err);
556 });
557
558 return newClient;
559 };
560
561 const fetchAndFilterModels = async (client) => {
562 try {
563 await client.select(process.env.REDIS_DB);
564 const models = await client.get('model');
565
566 return Object.entries(JSON.parse(models))
567 .filter(([_, value]) => allowedEndpoints.includes(value.endpoint))
568 .reduce((acc, [key, value]) => {
569 acc[key] = value;
570 return acc;
571 }, {});
572 } catch (err) {
573 console.error('Error fetching and filtering models:', err);
574 throw err;
575 }
576 };
577
578 const getModels = async () => {
579 if (!client) {
580 client = initializeRedisClient();
581
582 try {
583 await client.connect();
584 filteredModels = await fetchAndFilterModels(client);
585 console.log('Connected to Redis successfully');
586 } catch (err) {
587 console.error('Error connecting to Redis:', err);
588 throw err;
589 }
590 }
591 };
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -21,7 +21,61 @@ ...@@ -21,7 +21,61 @@
21 "js-tiktoken": "1.0.7", 21 "js-tiktoken": "1.0.7",
22 "morgan": "^1.10.0", 22 "morgan": "^1.10.0",
23 "node-fetch": "^2.7.0", 23 "node-fetch": "^2.7.0",
24 "openai": "^3.2.0" 24 "openai": "^3.2.0",
25 "redis": "^4.7.0"
26 }
27 },
28 "node_modules/@redis/bloom": {
29 "version": "1.2.0",
30 "resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-1.2.0.tgz",
31 "integrity": "sha512-HG2DFjYKbpNmVXsa0keLHp/3leGJz1mjh09f2RLGGLQZzSHpkmZWuwJbAvo3QcRY8p80m5+ZdXZdYOSBLlp7Cg==",
32 "peerDependencies": {
33 "@redis/client": "^1.0.0"
34 }
35 },
36 "node_modules/@redis/client": {
37 "version": "1.6.0",
38 "resolved": "https://registry.npmjs.org/@redis/client/-/client-1.6.0.tgz",
39 "integrity": "sha512-aR0uffYI700OEEH4gYnitAnv3vzVGXCFvYfdpu/CJKvk4pHfLPEy/JSZyrpQ+15WhXe1yJRXLtfQ84s4mEXnPg==",
40 "dependencies": {
41 "cluster-key-slot": "1.1.2",
42 "generic-pool": "3.9.0",
43 "yallist": "4.0.0"
44 },
45 "engines": {
46 "node": ">=14"
47 }
48 },
49 "node_modules/@redis/graph": {
50 "version": "1.1.1",
51 "resolved": "https://registry.npmjs.org/@redis/graph/-/graph-1.1.1.tgz",
52 "integrity": "sha512-FEMTcTHZozZciLRl6GiiIB4zGm5z5F3F6a6FZCyrfxdKOhFlGkiAqlexWMBzCi4DcRoyiOsuLfW+cjlGWyExOw==",
53 "peerDependencies": {
54 "@redis/client": "^1.0.0"
55 }
56 },
57 "node_modules/@redis/json": {
58 "version": "1.0.7",
59 "resolved": "https://registry.npmjs.org/@redis/json/-/json-1.0.7.tgz",
60 "integrity": "sha512-6UyXfjVaTBTJtKNG4/9Z8PSpKE6XgSyEb8iwaqDcy+uKrd/DGYHTWkUdnQDyzm727V7p21WUMhsqz5oy65kPcQ==",
61 "peerDependencies": {
62 "@redis/client": "^1.0.0"
63 }
64 },
65 "node_modules/@redis/search": {
66 "version": "1.2.0",
67 "resolved": "https://registry.npmjs.org/@redis/search/-/search-1.2.0.tgz",
68 "integrity": "sha512-tYoDBbtqOVigEDMAcTGsRlMycIIjwMCgD8eR2t0NANeQmgK/lvxNAvYyb6bZDD4frHRhIHkJu2TBRvB0ERkOmw==",
69 "peerDependencies": {
70 "@redis/client": "^1.0.0"
71 }
72 },
73 "node_modules/@redis/time-series": {
74 "version": "1.1.0",
75 "resolved": "https://registry.npmjs.org/@redis/time-series/-/time-series-1.1.0.tgz",
76 "integrity": "sha512-c1Q99M5ljsIuc4YdaCwfUEXsofakb9c8+Zse2qxTadu8TalLXuAESzLvFAvNVbkmSlvlzIQOLpBCmWI9wTOt+g==",
77 "peerDependencies": {
78 "@redis/client": "^1.0.0"
25 } 79 }
26 }, 80 },
27 "node_modules/accepts": { 81 "node_modules/accepts": {
...@@ -145,6 +199,14 @@ ...@@ -145,6 +199,14 @@
145 "url": "https://github.com/sponsors/ljharb" 199 "url": "https://github.com/sponsors/ljharb"
146 } 200 }
147 }, 201 },
202 "node_modules/cluster-key-slot": {
203 "version": "1.1.2",
204 "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz",
205 "integrity": "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==",
206 "engines": {
207 "node": ">=0.10.0"
208 }
209 },
148 "node_modules/combined-stream": { 210 "node_modules/combined-stream": {
149 "version": "1.0.8", 211 "version": "1.0.8",
150 "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 212 "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
...@@ -458,6 +520,14 @@ ...@@ -458,6 +520,14 @@
458 "url": "https://github.com/sponsors/ljharb" 520 "url": "https://github.com/sponsors/ljharb"
459 } 521 }
460 }, 522 },
523 "node_modules/generic-pool": {
524 "version": "3.9.0",
525 "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.9.0.tgz",
526 "integrity": "sha512-hymDOu5B53XvN4QT9dBmZxPX4CWhBPPLguTZ9MMFeFa/Kg0xWVfylOVNlJji/E7yTZWFd/q9GO5TxDLq156D7g==",
527 "engines": {
528 "node": ">= 4"
529 }
530 },
461 "node_modules/get-intrinsic": { 531 "node_modules/get-intrinsic": {
462 "version": "1.2.4", 532 "version": "1.2.4",
463 "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", 533 "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz",
...@@ -805,6 +875,22 @@ ...@@ -805,6 +875,22 @@
805 "node": ">= 0.8" 875 "node": ">= 0.8"
806 } 876 }
807 }, 877 },
878 "node_modules/redis": {
879 "version": "4.7.0",
880 "resolved": "https://registry.npmjs.org/redis/-/redis-4.7.0.tgz",
881 "integrity": "sha512-zvmkHEAdGMn+hMRXuMBtu4Vo5P6rHQjLoHftu+lBqq8ZTA3RCVC/WzD790bkKKiNFp7d5/9PcSD19fJyyRvOdQ==",
882 "workspaces": [
883 "./packages/*"
884 ],
885 "dependencies": {
886 "@redis/bloom": "1.2.0",
887 "@redis/client": "1.6.0",
888 "@redis/graph": "1.1.1",
889 "@redis/json": "1.0.7",
890 "@redis/search": "1.2.0",
891 "@redis/time-series": "1.1.0"
892 }
893 },
808 "node_modules/safe-buffer": { 894 "node_modules/safe-buffer": {
809 "version": "5.2.1", 895 "version": "5.2.1",
810 "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", 896 "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
...@@ -979,6 +1065,11 @@ ...@@ -979,6 +1065,11 @@
979 "tr46": "~0.0.3", 1065 "tr46": "~0.0.3",
980 "webidl-conversions": "^3.0.0" 1066 "webidl-conversions": "^3.0.0"
981 } 1067 }
1068 },
1069 "node_modules/yallist": {
1070 "version": "4.0.0",
1071 "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
1072 "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
982 } 1073 }
983 } 1074 }
984 } 1075 }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
22 "js-tiktoken": "1.0.7", 22 "js-tiktoken": "1.0.7",
23 "morgan": "^1.10.0", 23 "morgan": "^1.10.0",
24 "node-fetch": "^2.7.0", 24 "node-fetch": "^2.7.0",
25 "openai": "^3.2.0" 25 "openai": "^3.2.0",
26 "redis": "^4.7.0"
26 } 27 }
27 } 28 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!