diff --git a/.env b/.env index 54f675a9c5..68ec291aa2 100644 --- a/.env +++ b/.env @@ -4,7 +4,7 @@ VITE_GLOB_API_URL=/api VITE_APP_API_BASE_URL=http://localhost:3002/ # Whether long replies are supported, which may result in higher API fees -VITE_GLOB_OPEN_LONG_REPLY=false +VITE_GLOB_OPEN_LONG_REPLY=true # When you want to use PWA VITE_GLOB_APP_PWA=false diff --git a/service/package.json b/service/package.json index 4089b9ea09..e509a35879 100644 --- a/service/package.json +++ b/service/package.json @@ -24,6 +24,7 @@ "common:cleanup": "rimraf node_modules && rimraf pnpm-lock.yaml" }, "dependencies": { + "@keyv/redis": "^2.5.6", "axios": "^1.3.4", "chatgpt": "^5.1.2", "dotenv": "^16.0.3", @@ -32,6 +33,7 @@ "express-rate-limit": "^6.7.0", "https-proxy-agent": "^5.0.1", "isomorphic-fetch": "^3.0.0", + "keyv": "^4.5.2", "node-fetch": "^3.3.0", "socks-proxy-agent": "^7.0.0" }, diff --git a/service/pnpm-lock.yaml b/service/pnpm-lock.yaml index 1e143b155d..5cf15a8c20 100644 --- a/service/pnpm-lock.yaml +++ b/service/pnpm-lock.yaml @@ -1,7 +1,8 @@ -lockfileVersion: 5.3 +lockfileVersion: 5.4 specifiers: '@antfu/eslint-config': ^0.35.3 + '@keyv/redis': ^2.5.6 '@types/express': ^4.17.17 '@types/node': ^18.14.6 axios: ^1.3.4 @@ -13,6 +14,7 @@ specifiers: express-rate-limit: ^6.7.0 https-proxy-agent: ^5.0.1 isomorphic-fetch: ^3.0.0 + keyv: ^4.5.2 node-fetch: ^3.3.0 rimraf: ^4.3.0 socks-proxy-agent: ^7.0.0 @@ -20,6 +22,7 @@ specifiers: typescript: ^4.9.5 dependencies: + '@keyv/redis': 2.5.6 axios: 1.3.4 chatgpt: 5.1.2 dotenv: 16.0.3 @@ -28,11 +31,12 @@ dependencies: express-rate-limit: 6.7.0_express@4.18.2 https-proxy-agent: 5.0.1 isomorphic-fetch: 3.0.0 + keyv: 4.5.2 node-fetch: 3.3.0 socks-proxy-agent: 7.0.0 devDependencies: - '@antfu/eslint-config': 0.35.3_eslint@8.35.0+typescript@4.9.5 + '@antfu/eslint-config': 0.35.3_ycpbpc6yetojsgtrx3mwntkhsu '@types/express': 4.17.17 '@types/node': 18.14.6 eslint: 8.35.0 @@ -42,78 +46,86 @@ devDependencies: packages: - /@antfu/eslint-config-basic/0.35.3_01224e37e2fe1b57fb4026d072de963d: + /@antfu/eslint-config-basic/0.35.3_y46c5jzhegju5ppnhbs6d4llxi: resolution: {integrity: sha512-NbWJKNgd3Ky3/ok2Z88cXNme/6I9otkiaB+FYLFgQE81sfMAhKpLKXtTSwzdcKMzhKDqUchAijt0BxjE/mcTJg==} peerDependencies: eslint: '>=7.4.0' dependencies: eslint: 8.35.0 - eslint-plugin-antfu: 0.35.3_eslint@8.35.0+typescript@4.9.5 + eslint-plugin-antfu: 0.35.3_ycpbpc6yetojsgtrx3mwntkhsu eslint-plugin-eslint-comments: 3.2.0_eslint@8.35.0 eslint-plugin-html: 7.1.0 - eslint-plugin-import: 2.27.5_eslint@8.35.0 + eslint-plugin-import: 2.27.5_ajyizmi44oc3hrc35l6ndh7p4e eslint-plugin-jsonc: 2.6.0_eslint@8.35.0 eslint-plugin-markdown: 3.0.0_eslint@8.35.0 eslint-plugin-n: 15.6.1_eslint@8.35.0 eslint-plugin-no-only-tests: 3.1.0 eslint-plugin-promise: 6.1.1_eslint@8.35.0 eslint-plugin-unicorn: 45.0.2_eslint@8.35.0 - eslint-plugin-unused-imports: 2.0.0_3ae9a992b529133426b1a5274123d156 + eslint-plugin-unused-imports: 2.0.0_hlu2tevvfejtijvruutuci6rky eslint-plugin-yml: 1.5.0_eslint@8.35.0 jsonc-eslint-parser: 2.1.0 yaml-eslint-parser: 1.1.0 transitivePeerDependencies: - '@typescript-eslint/eslint-plugin' + - '@typescript-eslint/parser' + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack - supports-color - typescript dev: true - /@antfu/eslint-config-ts/0.35.3_eslint@8.35.0+typescript@4.9.5: + /@antfu/eslint-config-ts/0.35.3_ycpbpc6yetojsgtrx3mwntkhsu: resolution: {integrity: sha512-FS5hir2ghXYlJWAiB2bpT9oAr0kpSNmYbaJWWkztocJG95AORl4tWzxMTkLT+TxaOmhuwJszcrMTHy5RgHL8/w==} peerDependencies: eslint: '>=7.4.0' typescript: '>=3.9' dependencies: - '@antfu/eslint-config-basic': 0.35.3_01224e37e2fe1b57fb4026d072de963d - '@typescript-eslint/eslint-plugin': 5.54.0_f313ab61f51b54d267eab4b4d28cd47a - '@typescript-eslint/parser': 5.54.0_eslint@8.35.0+typescript@4.9.5 + '@antfu/eslint-config-basic': 0.35.3_y46c5jzhegju5ppnhbs6d4llxi + '@typescript-eslint/eslint-plugin': 5.54.0_6mj2wypvdnknez7kws2nfdgupi + '@typescript-eslint/parser': 5.54.0_ycpbpc6yetojsgtrx3mwntkhsu eslint: 8.35.0 - eslint-plugin-jest: 27.2.1_01224e37e2fe1b57fb4026d072de963d + eslint-plugin-jest: 27.2.1_aere4n7c7ynvp62ae3ihfxuwhu typescript: 4.9.5 transitivePeerDependencies: + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack - jest - supports-color dev: true - /@antfu/eslint-config-vue/0.35.3_01224e37e2fe1b57fb4026d072de963d: + /@antfu/eslint-config-vue/0.35.3_y46c5jzhegju5ppnhbs6d4llxi: resolution: {integrity: sha512-BA3vGLyuzqtEUb9gfgE7YzBT+a4oUnQuUPasIUfN/BVXaEhRVYlMmUgxN4ekQLuzOgUjUH13lqplXtkLJ62t9g==} peerDependencies: eslint: '>=7.4.0' dependencies: - '@antfu/eslint-config-basic': 0.35.3_01224e37e2fe1b57fb4026d072de963d - '@antfu/eslint-config-ts': 0.35.3_eslint@8.35.0+typescript@4.9.5 + '@antfu/eslint-config-basic': 0.35.3_y46c5jzhegju5ppnhbs6d4llxi + '@antfu/eslint-config-ts': 0.35.3_ycpbpc6yetojsgtrx3mwntkhsu eslint: 8.35.0 eslint-plugin-vue: 9.9.0_eslint@8.35.0 local-pkg: 0.4.3 transitivePeerDependencies: - '@typescript-eslint/eslint-plugin' + - '@typescript-eslint/parser' + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack - jest - supports-color - typescript dev: true - /@antfu/eslint-config/0.35.3_eslint@8.35.0+typescript@4.9.5: + /@antfu/eslint-config/0.35.3_ycpbpc6yetojsgtrx3mwntkhsu: resolution: {integrity: sha512-wd0ry/TNqaZmniqkKtZKoCvpl55x9YbHgL5Ug3H9rVuUSqaNi9G9AjYlynQqn4/M1EhYYWO597Lu7f/fC+csrg==} peerDependencies: eslint: '>=7.4.0' dependencies: - '@antfu/eslint-config-vue': 0.35.3_01224e37e2fe1b57fb4026d072de963d - '@typescript-eslint/eslint-plugin': 5.54.0_f313ab61f51b54d267eab4b4d28cd47a - '@typescript-eslint/parser': 5.54.0_eslint@8.35.0+typescript@4.9.5 + '@antfu/eslint-config-vue': 0.35.3_y46c5jzhegju5ppnhbs6d4llxi + '@typescript-eslint/eslint-plugin': 5.54.0_6mj2wypvdnknez7kws2nfdgupi + '@typescript-eslint/parser': 5.54.0_ycpbpc6yetojsgtrx3mwntkhsu eslint: 8.35.0 eslint-plugin-eslint-comments: 3.2.0_eslint@8.35.0 eslint-plugin-html: 7.1.0 - eslint-plugin-import: 2.27.5_eslint@8.35.0 + eslint-plugin-import: 2.27.5_ajyizmi44oc3hrc35l6ndh7p4e eslint-plugin-jsonc: 2.6.0_eslint@8.35.0 eslint-plugin-n: 15.6.1_eslint@8.35.0 eslint-plugin-promise: 6.1.1_eslint@8.35.0 @@ -123,6 +135,8 @@ packages: jsonc-eslint-parser: 2.1.0 yaml-eslint-parser: 1.1.0 transitivePeerDependencies: + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack - jest - supports-color - typescript @@ -399,6 +413,19 @@ packages: resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==} dev: true + /@ioredis/commands/1.2.0: + resolution: {integrity: sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==} + dev: false + + /@keyv/redis/2.5.6: + resolution: {integrity: sha512-WxR9x/TjGptVM5Vi1IyMqtZ+iAPMY8jh2NkGrHWnvrtGUDll4PyY2GbXkOTC0msGVXuV1JqPEHIM7M648O+Pfg==} + engines: {node: '>= 12'} + dependencies: + ioredis: 5.3.1 + transitivePeerDependencies: + - supports-color + dev: false + /@nodelib/fs.scandir/2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -498,7 +525,7 @@ packages: resolution: {integrity: sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==} dev: true - /@typescript-eslint/eslint-plugin/5.54.0_f313ab61f51b54d267eab4b4d28cd47a: + /@typescript-eslint/eslint-plugin/5.54.0_6mj2wypvdnknez7kws2nfdgupi: resolution: {integrity: sha512-+hSN9BdSr629RF02d7mMtXhAJvDTyCbprNYJKrXETlul/Aml6YZwd90XioVbjejQeHbb3R8Dg0CkRgoJDxo8aw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -509,10 +536,10 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.54.0_eslint@8.35.0+typescript@4.9.5 + '@typescript-eslint/parser': 5.54.0_ycpbpc6yetojsgtrx3mwntkhsu '@typescript-eslint/scope-manager': 5.54.0 - '@typescript-eslint/type-utils': 5.54.0_eslint@8.35.0+typescript@4.9.5 - '@typescript-eslint/utils': 5.54.0_eslint@8.35.0+typescript@4.9.5 + '@typescript-eslint/type-utils': 5.54.0_ycpbpc6yetojsgtrx3mwntkhsu + '@typescript-eslint/utils': 5.54.0_ycpbpc6yetojsgtrx3mwntkhsu debug: 4.3.4 eslint: 8.35.0 grapheme-splitter: 1.0.4 @@ -526,7 +553,7 @@ packages: - supports-color dev: true - /@typescript-eslint/parser/5.54.0_eslint@8.35.0+typescript@4.9.5: + /@typescript-eslint/parser/5.54.0_ycpbpc6yetojsgtrx3mwntkhsu: resolution: {integrity: sha512-aAVL3Mu2qTi+h/r04WI/5PfNWvO6pdhpeMRWk9R7rEV4mwJNzoWf5CCU5vDKBsPIFQFjEq1xg7XBI2rjiMXQbQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -554,7 +581,7 @@ packages: '@typescript-eslint/visitor-keys': 5.54.0 dev: true - /@typescript-eslint/type-utils/5.54.0_eslint@8.35.0+typescript@4.9.5: + /@typescript-eslint/type-utils/5.54.0_ycpbpc6yetojsgtrx3mwntkhsu: resolution: {integrity: sha512-WI+WMJ8+oS+LyflqsD4nlXMsVdzTMYTxl16myXPaCXnSgc7LWwMsjxQFZCK/rVmTZ3FN71Ct78ehO9bRC7erYQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -565,7 +592,7 @@ packages: optional: true dependencies: '@typescript-eslint/typescript-estree': 5.54.0_typescript@4.9.5 - '@typescript-eslint/utils': 5.54.0_eslint@8.35.0+typescript@4.9.5 + '@typescript-eslint/utils': 5.54.0_ycpbpc6yetojsgtrx3mwntkhsu debug: 4.3.4 eslint: 8.35.0 tsutils: 3.21.0_typescript@4.9.5 @@ -600,7 +627,7 @@ packages: - supports-color dev: true - /@typescript-eslint/utils/5.54.0_eslint@8.35.0+typescript@4.9.5: + /@typescript-eslint/utils/5.54.0_ycpbpc6yetojsgtrx3mwntkhsu: resolution: {integrity: sha512-cuwm8D/Z/7AuyAeJ+T0r4WZmlnlxQ8wt7C7fLpFlKMR+dY6QO79Cq1WpJhvZbMA4ZeZGHiRWnht7ZJ8qkdAunw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -811,6 +838,8 @@ packages: raw-body: 2.5.1 type-is: 1.6.18 unpipe: 1.0.0 + transitivePeerDependencies: + - supports-color dev: false /boolbase/1.0.0: @@ -953,6 +982,11 @@ packages: escape-string-regexp: 1.0.5 dev: true + /cluster-key-slot/1.1.2: + resolution: {integrity: sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==} + engines: {node: '>=0.10.0'} + dev: false + /color-convert/1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} dependencies: @@ -1052,12 +1086,22 @@ packages: /debug/2.6.9: resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true dependencies: ms: 2.0.0 dev: false /debug/3.2.7: resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true dependencies: ms: 2.1.3 dev: true @@ -1090,6 +1134,11 @@ packages: engines: {node: '>=0.4.0'} dev: false + /denque/2.1.0: + resolution: {integrity: sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==} + engines: {node: '>=0.10'} + dev: false + /depd/2.0.0: resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==} engines: {node: '>= 0.8'} @@ -1295,25 +1344,43 @@ packages: debug: 3.2.7 is-core-module: 2.11.0 resolve: 1.22.1 + transitivePeerDependencies: + - supports-color dev: true - /eslint-module-utils/2.7.4_eslint@8.35.0: + /eslint-module-utils/2.7.4_qynxowrxvm2kj5rbowcxf5maga: resolution: {integrity: sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==} engines: {node: '>=4'} peerDependencies: + '@typescript-eslint/parser': '*' eslint: '*' + eslint-import-resolver-node: '*' + eslint-import-resolver-typescript: '*' + eslint-import-resolver-webpack: '*' peerDependenciesMeta: + '@typescript-eslint/parser': + optional: true eslint: optional: true + eslint-import-resolver-node: + optional: true + eslint-import-resolver-typescript: + optional: true + eslint-import-resolver-webpack: + optional: true dependencies: + '@typescript-eslint/parser': 5.54.0_ycpbpc6yetojsgtrx3mwntkhsu debug: 3.2.7 eslint: 8.35.0 + eslint-import-resolver-node: 0.3.7 + transitivePeerDependencies: + - supports-color dev: true - /eslint-plugin-antfu/0.35.3_eslint@8.35.0+typescript@4.9.5: + /eslint-plugin-antfu/0.35.3_ycpbpc6yetojsgtrx3mwntkhsu: resolution: {integrity: sha512-90Xct24s2n3aQhuuFFcPLhF5E6lU5s225B0VXupSjvDTuF+CmSQQLQG6KcqcdpA8O6dMbeXB9zy3SJ4aO7lndw==} dependencies: - '@typescript-eslint/utils': 5.54.0_eslint@8.35.0+typescript@4.9.5 + '@typescript-eslint/utils': 5.54.0_ycpbpc6yetojsgtrx3mwntkhsu transitivePeerDependencies: - eslint - supports-color @@ -1348,12 +1415,17 @@ packages: htmlparser2: 8.0.1 dev: true - /eslint-plugin-import/2.27.5_eslint@8.35.0: + /eslint-plugin-import/2.27.5_ajyizmi44oc3hrc35l6ndh7p4e: resolution: {integrity: sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==} engines: {node: '>=4'} peerDependencies: + '@typescript-eslint/parser': '*' eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 + peerDependenciesMeta: + '@typescript-eslint/parser': + optional: true dependencies: + '@typescript-eslint/parser': 5.54.0_ycpbpc6yetojsgtrx3mwntkhsu array-includes: 3.1.6 array.prototype.flat: 1.3.1 array.prototype.flatmap: 1.3.1 @@ -1361,7 +1433,7 @@ packages: doctrine: 2.1.0 eslint: 8.35.0 eslint-import-resolver-node: 0.3.7 - eslint-module-utils: 2.7.4_eslint@8.35.0 + eslint-module-utils: 2.7.4_qynxowrxvm2kj5rbowcxf5maga has: 1.0.3 is-core-module: 2.11.0 is-glob: 4.0.3 @@ -1370,9 +1442,13 @@ packages: resolve: 1.22.1 semver: 6.3.0 tsconfig-paths: 3.14.2 + transitivePeerDependencies: + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack + - supports-color dev: true - /eslint-plugin-jest/27.2.1_01224e37e2fe1b57fb4026d072de963d: + /eslint-plugin-jest/27.2.1_aere4n7c7ynvp62ae3ihfxuwhu: resolution: {integrity: sha512-l067Uxx7ZT8cO9NJuf+eJHvt6bqJyz2Z29wykyEdz/OtmcELQl2MQGQLX8J94O1cSJWAwUSEvCjwjA7KEK3Hmg==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} peerDependencies: @@ -1385,8 +1461,8 @@ packages: jest: optional: true dependencies: - '@typescript-eslint/eslint-plugin': 5.54.0_f313ab61f51b54d267eab4b4d28cd47a - '@typescript-eslint/utils': 5.54.0_eslint@8.35.0+typescript@4.9.5 + '@typescript-eslint/eslint-plugin': 5.54.0_6mj2wypvdnknez7kws2nfdgupi + '@typescript-eslint/utils': 5.54.0_ycpbpc6yetojsgtrx3mwntkhsu eslint: 8.35.0 transitivePeerDependencies: - supports-color @@ -1473,7 +1549,7 @@ packages: strip-indent: 3.0.0 dev: true - /eslint-plugin-unused-imports/2.0.0_3ae9a992b529133426b1a5274123d156: + /eslint-plugin-unused-imports/2.0.0_hlu2tevvfejtijvruutuci6rky: resolution: {integrity: sha512-3APeS/tQlTrFa167ThtP0Zm0vctjr4M44HMpeg1P4bK6wItarumq0Ma82xorMKdFsWpphQBlRPzw/pxiVELX1A==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1483,7 +1559,7 @@ packages: '@typescript-eslint/eslint-plugin': optional: true dependencies: - '@typescript-eslint/eslint-plugin': 5.54.0_f313ab61f51b54d267eab4b4d28cd47a + '@typescript-eslint/eslint-plugin': 5.54.0_6mj2wypvdnknez7kws2nfdgupi eslint: 8.35.0 eslint-rule-composer: 0.3.0 dev: true @@ -1737,6 +1813,8 @@ packages: type-is: 1.6.18 utils-merge: 1.0.1 vary: 1.1.2 + transitivePeerDependencies: + - supports-color dev: false /fast-deep-equal/3.1.3: @@ -1800,6 +1878,8 @@ packages: parseurl: 1.3.3 statuses: 2.0.1 unpipe: 1.0.0 + transitivePeerDependencies: + - supports-color dev: false /find-up/4.1.0: @@ -2150,6 +2230,23 @@ packages: side-channel: 1.0.4 dev: true + /ioredis/5.3.1: + resolution: {integrity: sha512-C+IBcMysM6v52pTLItYMeV4Hz7uriGtoJdz7SSBDX6u+zwSYGirLdQh3L7t/OItWITcw3gTFMjJReYUwS4zihg==} + engines: {node: '>=12.22.0'} + dependencies: + '@ioredis/commands': 1.2.0 + cluster-key-slot: 1.1.2 + debug: 4.3.4 + denque: 2.1.0 + lodash.defaults: 4.2.0 + lodash.isarguments: 3.1.0 + redis-errors: 1.2.0 + redis-parser: 3.0.0 + standard-as-callback: 2.1.0 + transitivePeerDependencies: + - supports-color + dev: false + /ip/2.0.0: resolution: {integrity: sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==} dev: false @@ -2454,6 +2551,14 @@ packages: p-locate: 6.0.0 dev: false + /lodash.defaults/4.2.0: + resolution: {integrity: sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==} + dev: false + + /lodash.isarguments/3.1.0: + resolution: {integrity: sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==} + dev: false + /lodash.merge/4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} dev: true @@ -3007,6 +3112,18 @@ packages: picomatch: 2.3.1 dev: true + /redis-errors/1.2.0: + resolution: {integrity: sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==} + engines: {node: '>=4'} + dev: false + + /redis-parser/3.0.0: + resolution: {integrity: sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==} + engines: {node: '>=4'} + dependencies: + redis-errors: 1.2.0 + dev: false + /regexp-tree/0.1.24: resolution: {integrity: sha512-s2aEVuLhvnVJW6s/iPgEGK6R+/xngd2jNQ+xy4bXNDKxZKJH6jpPHY6kVeVv1IeLCHgswRj+Kl3ELaDjG6V1iw==} hasBin: true @@ -3147,6 +3264,8 @@ packages: on-finished: 2.4.1 range-parser: 1.2.1 statuses: 2.0.1 + transitivePeerDependencies: + - supports-color dev: false /serve-static/1.15.0: @@ -3157,6 +3276,8 @@ packages: escape-html: 1.0.3 parseurl: 1.3.3 send: 0.18.0 + transitivePeerDependencies: + - supports-color dev: false /setprototypeof/1.2.0: @@ -3252,6 +3373,10 @@ packages: /spdx-license-ids/3.0.12: resolution: {integrity: sha512-rr+VVSXtRhO4OHbXUiAF7xW3Bo9DuuF6C5jH+q/x15j2jniycgKbxU09Hr0WqlSLUs4i4ltHGXqTe7VHclYWyA==} + /standard-as-callback/2.1.0: + resolution: {integrity: sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==} + dev: false + /statuses/2.0.1: resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==} engines: {node: '>= 0.8'} diff --git a/service/src/chatgpt/index.ts b/service/src/chatgpt/index.ts index bc2980a9e7..d1483a60e7 100644 --- a/service/src/chatgpt/index.ts +++ b/service/src/chatgpt/index.ts @@ -6,6 +6,8 @@ import { SocksProxyAgent } from 'socks-proxy-agent' import { HttpsProxyAgent } from 'https-proxy-agent' import fetch from 'node-fetch' import axios from 'axios' +import Keyv from 'keyv' +import KeyvRedis from '@keyv/redis' import { sendResponse } from '../utils' import { isNotEmptyString } from '../utils/is' import type { ApiModel, ChatContext, ChatGPTUnofficialProxyAPIOptions, ModelConfig } from '../types' @@ -58,6 +60,10 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI } } + if (isNotEmptyString(process.env.REDIS_URL)) { + const store = new KeyvRedis(process.env.REDIS_URL) + options.messageStore = new Keyv({ store, namespace: 'chatgpt-web' }) + } if (isNotEmptyString(process.env.SYSTEM_MESSAGE)) { let now = new Date() now = new Date(now.getTime() - (now.getTimezoneOffset()*60*1000)) diff --git a/src/components/common/Setting/Advanced.vue b/src/components/common/Setting/Advanced.vue index 62c5851881..3493282e09 100644 --- a/src/components/common/Setting/Advanced.vue +++ b/src/components/common/Setting/Advanced.vue @@ -29,7 +29,7 @@ function handleReset() {
` } @@ -97,6 +111,7 @@ defineExpose({ textRef }) type="textarea" :autosize="{ minRows: 5 }" @input="handleInput" + @keypress="handleEnter" />${lang}${t('chat.copyCode')}${str}
- {{ dateTime }} + {{ userInfo.aiName }} + {{ dateTime }} + {{ userInfo.name }}