From 271ed9d7536f4760cbf3c76c4f12894cb316c16c Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Wed, 1 Mar 2023 20:49:20 -0600 Subject: [PATCH] feat: add support for official OpenAI chat completions API --- demos/demo-reverse-proxy.ts | 7 - demos/demo.ts | 7 +- package.json | 21 +- pnpm-lock.yaml | 913 +++++++++++++++--------------------- readme.md | 47 +- src/chatgpt-api.ts | 231 +++++---- src/types.ts | 171 ++----- 7 files changed, 561 insertions(+), 836 deletions(-) diff --git a/demos/demo-reverse-proxy.ts b/demos/demo-reverse-proxy.ts index c4ecbe9..0b88b5f 100644 --- a/demos/demo-reverse-proxy.ts +++ b/demos/demo-reverse-proxy.ts @@ -21,14 +21,7 @@ async function main() { // apiReverseProxyUrl: 'https://chat.duti.tech/api/conversation', // apiReverseProxyUrl: 'https://gpt.pawan.krd/backend-api/conversation', - // change this to an `accessToken` extracted from the ChatGPT site's `https://chat.openai.com/api/auth/session` response - // or use https://github.com/acheong08/OpenAIAuth to get the token programatically (python) accessToken: process.env.OPENAI_ACCESS_TOKEN, - - // optionally override the default model (this must be a chatgpt model; not an OpenAI model) - // model: 'text-davinci-002-render-sha' // default model for free and paid users (used to be called turbo in the UI) - // model: 'text-davinci-002-render-paid' // legacy paid model - debug: false }) diff --git a/demos/demo.ts b/demos/demo.ts index 08577fc..20f2c1a 100644 --- a/demos/demo.ts +++ b/demos/demo.ts @@ -13,7 +13,10 @@ dotenv.config() * ``` */ async function main() { - const api = new ChatGPTAPI({ apiKey: process.env.OPENAI_API_KEY }) + const api = new ChatGPTAPI({ + apiKey: process.env.OPENAI_API_KEY, + debug: false + }) const prompt = 'Write a python version of bubble sort. Do not include example usage.' @@ -21,7 +24,7 @@ async function main() { const res = await oraPromise(api.sendMessage(prompt), { text: prompt }) - console.log(res) + console.log(res.text) } main().catch((err) => { diff --git a/package.json b/package.json index 7bc0d58..4c24398 100644 --- a/package.json +++ b/package.json @@ -42,26 +42,27 @@ "conf": "^11.0.1", "eventsource-parser": "^0.0.5", "keyv": "^4.5.2", - "p-timeout": "^6.0.0", + "p-timeout": "^6.1.1", "quick-lru": "^6.1.1", "read-pkg-up": "^9.1.0", "uuid": "^9.0.0" }, "devDependencies": { - "@keyv/redis": "^2.5.4", - "@trivago/prettier-plugin-sort-imports": "^4.0.0", - "@types/node": "^18.11.9", - "@types/uuid": "^9.0.0", + "@keyv/redis": "^2.5.5", + "@trivago/prettier-plugin-sort-imports": "^4.1.1", + "@types/node": "^18.14.2", + "@types/uuid": "^9.0.1", "del-cli": "^5.0.0", "dotenv-safe": "^8.2.0", "husky": "^8.0.2", - "lint-staged": "^13.0.3", + "lint-staged": "^13.1.2", "npm-run-all": "^4.1.5", + "openai": "^3.2.1", "ora": "^6.1.2", - "prettier": "^2.8.0", - "tsup": "^6.5.0", - "tsx": "^3.12.1", - "typedoc": "^0.23.21", + "prettier": "^2.8.4", + "tsup": "^6.6.3", + "tsx": "^3.12.3", + "typedoc": "^0.23.26", "typedoc-plugin-markdown": "^3.13.6", "typescript": "^4.9.3" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1c58060..5605a80 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2,10 +2,10 @@ lockfileVersion: 5.4 specifiers: '@dqbd/tiktoken': ^0.4.0 - '@keyv/redis': ^2.5.4 - '@trivago/prettier-plugin-sort-imports': ^4.0.0 - '@types/node': ^18.11.9 - '@types/uuid': ^9.0.0 + '@keyv/redis': ^2.5.5 + '@trivago/prettier-plugin-sort-imports': ^4.1.1 + '@types/node': ^18.14.2 + '@types/uuid': ^9.0.1 cac: ^6.7.14 conf: ^11.0.1 del-cli: ^5.0.0 @@ -13,16 +13,17 @@ specifiers: eventsource-parser: ^0.0.5 husky: ^8.0.2 keyv: ^4.5.2 - lint-staged: ^13.0.3 + lint-staged: ^13.1.2 npm-run-all: ^4.1.5 + openai: ^3.2.1 ora: ^6.1.2 - p-timeout: ^6.0.0 - prettier: ^2.8.0 + p-timeout: ^6.1.1 + prettier: ^2.8.4 quick-lru: ^6.1.1 read-pkg-up: ^9.1.0 - tsup: ^6.5.0 - tsx: ^3.12.1 - typedoc: ^0.23.21 + tsup: ^6.6.3 + tsx: ^3.12.3 + typedoc: ^0.23.26 typedoc-plugin-markdown: ^3.13.6 typescript: ^4.9.3 uuid: ^9.0.0 @@ -33,73 +34,38 @@ dependencies: conf: 11.0.1 eventsource-parser: 0.0.5 keyv: 4.5.2 - p-timeout: 6.1.0 + p-timeout: 6.1.1 quick-lru: 6.1.1 read-pkg-up: 9.1.0 uuid: 9.0.0 devDependencies: - '@keyv/redis': 2.5.4 - '@trivago/prettier-plugin-sort-imports': 4.0.0_prettier@2.8.3 - '@types/node': 18.11.18 - '@types/uuid': 9.0.0 + '@keyv/redis': 2.5.5 + '@trivago/prettier-plugin-sort-imports': 4.1.1_prettier@2.8.4 + '@types/node': 18.14.2 + '@types/uuid': 9.0.1 del-cli: 5.0.0 dotenv-safe: 8.2.0 husky: 8.0.3 - lint-staged: 13.1.0 + lint-staged: 13.1.2 npm-run-all: 4.1.5 + openai: 3.2.1 ora: 6.1.2 - prettier: 2.8.3 - tsup: 6.5.0_typescript@4.9.5 - tsx: 3.12.2 - typedoc: 0.23.24_typescript@4.9.5 - typedoc-plugin-markdown: 3.14.0_typedoc@0.23.24 + prettier: 2.8.4 + tsup: 6.6.3_typescript@4.9.5 + tsx: 3.12.3 + typedoc: 0.23.26_typescript@4.9.5 + typedoc-plugin-markdown: 3.14.0_typedoc@0.23.26 typescript: 4.9.5 packages: - /@ampproject/remapping/2.2.0: - resolution: {integrity: sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==} - engines: {node: '>=6.0.0'} - dependencies: - '@jridgewell/gen-mapping': 0.1.1 - '@jridgewell/trace-mapping': 0.3.17 - dev: true - /@babel/code-frame/7.18.6: resolution: {integrity: sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==} engines: {node: '>=6.9.0'} dependencies: '@babel/highlight': 7.18.6 - /@babel/compat-data/7.20.14: - resolution: {integrity: sha512-0YpKHD6ImkWMEINCyDAD0HLLUH/lPCefG8ld9it8DJB2wnApraKuhgYTvTY1z7UFIfBTGy5LwncZ+5HWWGbhFw==} - engines: {node: '>=6.9.0'} - dev: true - - /@babel/core/7.17.8: - resolution: {integrity: sha512-OdQDV/7cRBtJHLSOBqqbYNkOcydOgnX59TZx4puf41fzcVtN3e/4yqY8lMQsK+5X2lJtAdmA+6OHqsj1hBJ4IQ==} - engines: {node: '>=6.9.0'} - dependencies: - '@ampproject/remapping': 2.2.0 - '@babel/code-frame': 7.18.6 - '@babel/generator': 7.17.7 - '@babel/helper-compilation-targets': 7.20.7_@babel+core@7.17.8 - '@babel/helper-module-transforms': 7.20.11 - '@babel/helpers': 7.20.13 - '@babel/parser': 7.18.9 - '@babel/template': 7.20.7 - '@babel/traverse': 7.17.3 - '@babel/types': 7.17.0 - convert-source-map: 1.9.0 - debug: 4.3.4 - gensync: 1.0.0-beta.2 - json5: 2.2.3 - semver: 6.3.0 - transitivePeerDependencies: - - supports-color - dev: true - /@babel/generator/7.17.7: resolution: {integrity: sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w==} engines: {node: '>=6.9.0'} @@ -109,84 +75,31 @@ packages: source-map: 0.5.7 dev: true - /@babel/generator/7.20.14: - resolution: {integrity: sha512-AEmuXHdcD3A52HHXxaTmYlb8q/xMEhoRP67B3T4Oq7lbmSoqroMZzjnGj3+i1io3pdnF8iBYVu4Ilj+c4hBxYg==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/types': 7.20.7 - '@jridgewell/gen-mapping': 0.3.2 - jsesc: 2.5.2 - dev: true - - /@babel/helper-compilation-targets/7.20.7_@babel+core@7.17.8: - resolution: {integrity: sha512-4tGORmfQcrc+bvrjb5y3dG9Mx1IOZjsHqQVUz7XCNHO+iTmqxWnVg3KRygjGmpRLJGdQSKuvFinbIb0CnZwHAQ==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0 - dependencies: - '@babel/compat-data': 7.20.14 - '@babel/core': 7.17.8 - '@babel/helper-validator-option': 7.18.6 - browserslist: 4.21.5 - lru-cache: 5.1.1 - semver: 6.3.0 - dev: true - /@babel/helper-environment-visitor/7.18.9: resolution: {integrity: sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==} engines: {node: '>=6.9.0'} dev: true - /@babel/helper-function-name/7.19.0: - resolution: {integrity: sha512-WAwHBINyrpqywkUH0nTnNgI5ina5TFn85HKS0pbPDfxFfhyR/aNQEn4hGi1P1JyT//I0t4OgXUlofzWILRvS5w==} + /@babel/helper-function-name/7.21.0: + resolution: {integrity: sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg==} engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.20.7 - '@babel/types': 7.20.7 + '@babel/types': 7.21.2 dev: true /@babel/helper-hoist-variables/7.18.6: resolution: {integrity: sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.20.7 - dev: true - - /@babel/helper-module-imports/7.18.6: - resolution: {integrity: sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/types': 7.20.7 - dev: true - - /@babel/helper-module-transforms/7.20.11: - resolution: {integrity: sha512-uRy78kN4psmji1s2QtbtcCSaj/LILFDp0f/ymhpQH5QY3nljUZCaNWz9X1dEj/8MBdBEFECs7yRhKn8i7NjZgg==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/helper-environment-visitor': 7.18.9 - '@babel/helper-module-imports': 7.18.6 - '@babel/helper-simple-access': 7.20.2 - '@babel/helper-split-export-declaration': 7.18.6 - '@babel/helper-validator-identifier': 7.19.1 - '@babel/template': 7.20.7 - '@babel/traverse': 7.20.13 - '@babel/types': 7.20.7 - transitivePeerDependencies: - - supports-color - dev: true - - /@babel/helper-simple-access/7.20.2: - resolution: {integrity: sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/types': 7.20.7 + '@babel/types': 7.21.2 dev: true /@babel/helper-split-export-declaration/7.18.6: resolution: {integrity: sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.20.7 + '@babel/types': 7.21.2 dev: true /@babel/helper-string-parser/7.19.4: @@ -198,22 +111,6 @@ packages: resolution: {integrity: sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==} engines: {node: '>=6.9.0'} - /@babel/helper-validator-option/7.18.6: - resolution: {integrity: sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw==} - engines: {node: '>=6.9.0'} - dev: true - - /@babel/helpers/7.20.13: - resolution: {integrity: sha512-nzJ0DWCL3gB5RCXbUO3KIMMsBY2Eqbx8mBpKGE/02PgyRQFcPQLbkQ1vyy596mZLaP+dAfD+R4ckASzNVmW3jg==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/template': 7.20.7 - '@babel/traverse': 7.20.13 - '@babel/types': 7.20.7 - transitivePeerDependencies: - - supports-color - dev: true - /@babel/highlight/7.18.6: resolution: {integrity: sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==} engines: {node: '>=6.9.0'} @@ -222,29 +119,21 @@ packages: chalk: 2.4.2 js-tokens: 4.0.0 - /@babel/parser/7.18.9: - resolution: {integrity: sha512-9uJveS9eY9DJ0t64YbIBZICtJy8a5QrDEVdiLCG97fVLpDTpGX7t8mMSb6OWw6Lrnjqj4O8zwjELX3dhoMgiBg==} + /@babel/parser/7.21.2: + resolution: {integrity: sha512-URpaIJQwEkEC2T9Kn+Ai6Xe/02iNaVCuT/PtoRz3GPVJVDpPd7mLo+VddTbhCRU9TXqW5mSrQfXZyi8kDKOVpQ==} engines: {node: '>=6.0.0'} hasBin: true dependencies: '@babel/types': 7.17.0 dev: true - /@babel/parser/7.20.13: - resolution: {integrity: sha512-gFDLKMfpiXCsjt4za2JA9oTMn70CeseCehb11kRZgvd7+F67Hih3OHOK24cRrWECJ/ljfPGac6ygXAs/C8kIvw==} - engines: {node: '>=6.0.0'} - hasBin: true - dependencies: - '@babel/types': 7.20.7 - dev: true - /@babel/template/7.20.7: resolution: {integrity: sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw==} engines: {node: '>=6.9.0'} dependencies: '@babel/code-frame': 7.18.6 - '@babel/parser': 7.20.13 - '@babel/types': 7.20.7 + '@babel/parser': 7.21.2 + '@babel/types': 7.21.2 dev: true /@babel/traverse/7.17.3: @@ -254,10 +143,10 @@ packages: '@babel/code-frame': 7.18.6 '@babel/generator': 7.17.7 '@babel/helper-environment-visitor': 7.18.9 - '@babel/helper-function-name': 7.19.0 + '@babel/helper-function-name': 7.21.0 '@babel/helper-hoist-variables': 7.18.6 '@babel/helper-split-export-declaration': 7.18.6 - '@babel/parser': 7.18.9 + '@babel/parser': 7.21.2 '@babel/types': 7.17.0 debug: 4.3.4 globals: 11.12.0 @@ -265,24 +154,6 @@ packages: - supports-color dev: true - /@babel/traverse/7.20.13: - resolution: {integrity: sha512-kMJXfF0T6DIS9E8cgdLCSAL+cuCK+YEZHWiLK0SXpTo8YRj5lpJu3CDNKiIBCne4m9hhTIqUg6SYTAI39tAiVQ==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/code-frame': 7.18.6 - '@babel/generator': 7.20.14 - '@babel/helper-environment-visitor': 7.18.9 - '@babel/helper-function-name': 7.19.0 - '@babel/helper-hoist-variables': 7.18.6 - '@babel/helper-split-export-declaration': 7.18.6 - '@babel/parser': 7.20.13 - '@babel/types': 7.20.7 - debug: 4.3.4 - globals: 11.12.0 - transitivePeerDependencies: - - supports-color - dev: true - /@babel/types/7.17.0: resolution: {integrity: sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==} engines: {node: '>=6.9.0'} @@ -291,8 +162,8 @@ packages: to-fast-properties: 2.0.0 dev: true - /@babel/types/7.20.7: - resolution: {integrity: sha512-69OnhBxSSgK0OzTJai4kyPDiKTIe3j+ctaHdIGVbRahTLAT7L3R9oeXHC2aVSuGYt3cVnoAMDmOCgJ2yaiLMvg==} + /@babel/types/7.21.2: + resolution: {integrity: sha512-3wRZSs7jiFaB8AjxiiD+VqN5DTG2iRvJGQ+qYFrs/654lg6kGTQWIOFjlBo5RaXuAZjBmP3+OQH4dmhqiiyYxw==} engines: {node: '>=6.9.0'} dependencies: '@babel/helper-string-parser': 7.19.4 @@ -304,29 +175,29 @@ packages: resolution: {integrity: sha512-iaHgmwKAOqowBFZKxelyszoeGLoNw62eOULcmyme1aA1Ymr3JgYl0V7jwpuUm7fksalycZajx3loFn9TRUaviw==} dev: false - /@esbuild-kit/cjs-loader/2.4.1: - resolution: {integrity: sha512-lhc/XLith28QdW0HpHZvZKkorWgmCNT7sVelMHDj3HFdTfdqkwEKvT+aXVQtNAmCC39VJhunDkWhONWB7335mg==} + /@esbuild-kit/cjs-loader/2.4.2: + resolution: {integrity: sha512-BDXFbYOJzT/NBEtp71cvsrGPwGAMGRB/349rwKuoxNSiKjPraNNnlK6MIIabViCjqZugu6j+xeMDlEkWdHHJSg==} dependencies: - '@esbuild-kit/core-utils': 3.0.0 - get-tsconfig: 4.3.0 + '@esbuild-kit/core-utils': 3.1.0 + get-tsconfig: 4.4.0 dev: true - /@esbuild-kit/core-utils/3.0.0: - resolution: {integrity: sha512-TXmwH9EFS3DC2sI2YJWJBgHGhlteK0Xyu1VabwetMULfm3oYhbrsWV5yaSr2NTWZIgDGVLHbRf0inxbjXqAcmQ==} + /@esbuild-kit/core-utils/3.1.0: + resolution: {integrity: sha512-Uuk8RpCg/7fdHSceR1M6XbSZFSuMrxcePFuGgyvsBn+u339dk5OeL4jv2EojwTN2st/unJGsVm4qHWjWNmJ/tw==} dependencies: - esbuild: 0.15.18 + esbuild: 0.17.10 source-map-support: 0.5.21 dev: true - /@esbuild-kit/esm-loader/2.5.4: - resolution: {integrity: sha512-afmtLf6uqxD5IgwCzomtqCYIgz/sjHzCWZFvfS5+FzeYxOURPUo4QcHtqJxbxWOMOogKriZanN/1bJQE/ZL93A==} + /@esbuild-kit/esm-loader/2.5.5: + resolution: {integrity: sha512-Qwfvj/qoPbClxCRNuac1Du01r9gvNOT+pMYtJDapfB1eoGN1YlJ1BixLyL9WVENRx5RXgNLdfYdx/CuswlGhMw==} dependencies: - '@esbuild-kit/core-utils': 3.0.0 - get-tsconfig: 4.3.0 + '@esbuild-kit/core-utils': 3.1.0 + get-tsconfig: 4.4.0 dev: true - /@esbuild/android-arm/0.15.18: - resolution: {integrity: sha512-5GT+kcs2WVGjVs7+boataCkO5Fg0y4kCjzkB5bAip7H4jfnOS3dA6KPiww9W1OEKTKeAcUVhdZGvgI65OXmUnw==} + /@esbuild/android-arm/0.17.10: + resolution: {integrity: sha512-7YEBfZ5lSem9Tqpsz+tjbdsEshlO9j/REJrfv4DXgKTt1+/MHqGwbtlyxQuaSlMeUZLxUKBaX8wdzlTfHkmnLw==} engines: {node: '>=12'} cpu: [arm] os: [android] @@ -334,8 +205,89 @@ packages: dev: true optional: true - /@esbuild/linux-loong64/0.15.18: - resolution: {integrity: sha512-L4jVKS82XVhw2nvzLg/19ClLWg0y27ulRwuP7lcyL6AbUWB5aPglXY3M21mauDQMDfRLs8cQmeT03r/+X3cZYQ==} + /@esbuild/android-arm64/0.17.10: + resolution: {integrity: sha512-ht1P9CmvrPF5yKDtyC+z43RczVs4rrHpRqrmIuoSvSdn44Fs1n6DGlpZKdK6rM83pFLbVaSUwle8IN+TPmkv7g==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/android-x64/0.17.10: + resolution: {integrity: sha512-CYzrm+hTiY5QICji64aJ/xKdN70IK8XZ6iiyq0tZkd3tfnwwSWTYH1t3m6zyaaBxkuj40kxgMyj1km/NqdjQZA==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/darwin-arm64/0.17.10: + resolution: {integrity: sha512-3HaGIowI+nMZlopqyW6+jxYr01KvNaLB5znXfbyyjuo4lE0VZfvFGcguIJapQeQMS4cX/NEispwOekJt3gr5Dg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@esbuild/darwin-x64/0.17.10: + resolution: {integrity: sha512-J4MJzGchuCRG5n+B4EHpAMoJmBeAE1L3wGYDIN5oWNqX0tEr7VKOzw0ymSwpoeSpdCa030lagGUfnfhS7OvzrQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@esbuild/freebsd-arm64/0.17.10: + resolution: {integrity: sha512-ZkX40Z7qCbugeK4U5/gbzna/UQkM9d9LNV+Fro8r7HA7sRof5Rwxc46SsqeMvB5ZaR0b1/ITQ/8Y1NmV2F0fXQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/freebsd-x64/0.17.10: + resolution: {integrity: sha512-0m0YX1IWSLG9hWh7tZa3kdAugFbZFFx9XrvfpaCMMvrswSTvUZypp0NFKriUurHpBA3xsHVE9Qb/0u2Bbi/otg==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-arm/0.17.10: + resolution: {integrity: sha512-whRdrrl0X+9D6o5f0sTZtDM9s86Xt4wk1bf7ltx6iQqrIIOH+sre1yjpcCdrVXntQPCNw/G+XqsD4HuxeS+2QA==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-arm64/0.17.10: + resolution: {integrity: sha512-g1EZJR1/c+MmCgVwpdZdKi4QAJ8DCLP5uTgLWSAVd9wlqk9GMscaNMEViG3aE1wS+cNMzXXgdWiW/VX4J+5nTA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-ia32/0.17.10: + resolution: {integrity: sha512-1vKYCjfv/bEwxngHERp7huYfJ4jJzldfxyfaF7hc3216xiDA62xbXJfRlradiMhGZbdNLj2WA1YwYFzs9IWNPw==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-loong64/0.17.10: + resolution: {integrity: sha512-mvwAr75q3Fgc/qz3K6sya3gBmJIYZCgcJ0s7XshpoqIAIBszzfXsqhpRrRdVFAyV1G9VUjj7VopL2HnAS8aHFA==} engines: {node: '>=12'} cpu: [loong64] os: [linux] @@ -343,50 +295,111 @@ packages: dev: true optional: true + /@esbuild/linux-mips64el/0.17.10: + resolution: {integrity: sha512-XilKPgM2u1zR1YuvCsFQWl9Fc35BqSqktooumOY2zj7CSn5czJn279j9TE1JEqSqz88izJo7yE4x3LSf7oxHzg==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-ppc64/0.17.10: + resolution: {integrity: sha512-kM4Rmh9l670SwjlGkIe7pYWezk8uxKHX4Lnn5jBZYBNlWpKMBCVfpAgAJqp5doLobhzF3l64VZVrmGeZ8+uKmQ==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-riscv64/0.17.10: + resolution: {integrity: sha512-r1m9ZMNJBtOvYYGQVXKy+WvWd0BPvSxMsVq8Hp4GzdMBQvfZRvRr5TtX/1RdN6Va8JMVQGpxqde3O+e8+khNJQ==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-s390x/0.17.10: + resolution: {integrity: sha512-LsY7QvOLPw9WRJ+fU5pNB3qrSfA00u32ND5JVDrn/xG5hIQo3kvTxSlWFRP0NJ0+n6HmhPGG0Q4jtQsb6PFoyg==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-x64/0.17.10: + resolution: {integrity: sha512-zJUfJLebCYzBdIz/Z9vqwFjIA7iSlLCFvVi7glMgnu2MK7XYigwsonXshy9wP9S7szF+nmwrelNaP3WGanstEg==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/netbsd-x64/0.17.10: + resolution: {integrity: sha512-lOMkailn4Ok9Vbp/q7uJfgicpDTbZFlXlnKT2DqC8uBijmm5oGtXAJy2ZZVo5hX7IOVXikV9LpCMj2U8cTguWA==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/openbsd-x64/0.17.10: + resolution: {integrity: sha512-/VE0Kx6y7eekqZ+ZLU4AjMlB80ov9tEz4H067Y0STwnGOYL8CsNg4J+cCmBznk1tMpxMoUOf0AbWlb1d2Pkbig==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/sunos-x64/0.17.10: + resolution: {integrity: sha512-ERNO0838OUm8HfUjjsEs71cLjLMu/xt6bhOlxcJ0/1MG3hNqCmbWaS+w/8nFLa0DDjbwZQuGKVtCUJliLmbVgg==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-arm64/0.17.10: + resolution: {integrity: sha512-fXv+L+Bw2AeK+XJHwDAQ9m3NRlNemG6Z6ijLwJAAVdu4cyoFbBWbEtyZzDeL+rpG2lWI51cXeMt70HA8g2MqIg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-ia32/0.17.10: + resolution: {integrity: sha512-3s+HADrOdCdGOi5lnh5DMQEzgbsFsd4w57L/eLKKjMnN0CN4AIEP0DCP3F3N14xnxh3ruNc32A0Na9zYe1Z/AQ==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-x64/0.17.10: + resolution: {integrity: sha512-oP+zFUjYNaMNmjTwlFtWep85hvwUu19cZklB3QsBOcZSs6y7hmH4LNCJ7075bsqzYaNvZFXJlAVaQ2ApITDXtw==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + /@ioredis/commands/1.2.0: resolution: {integrity: sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==} dev: true - /@jridgewell/gen-mapping/0.1.1: - resolution: {integrity: sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==} - engines: {node: '>=6.0.0'} - dependencies: - '@jridgewell/set-array': 1.1.2 - '@jridgewell/sourcemap-codec': 1.4.14 - dev: true - - /@jridgewell/gen-mapping/0.3.2: - resolution: {integrity: sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==} - engines: {node: '>=6.0.0'} - dependencies: - '@jridgewell/set-array': 1.1.2 - '@jridgewell/sourcemap-codec': 1.4.14 - '@jridgewell/trace-mapping': 0.3.17 - dev: true - - /@jridgewell/resolve-uri/3.1.0: - resolution: {integrity: sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==} - engines: {node: '>=6.0.0'} - dev: true - - /@jridgewell/set-array/1.1.2: - resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==} - engines: {node: '>=6.0.0'} - dev: true - - /@jridgewell/sourcemap-codec/1.4.14: - resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==} - dev: true - - /@jridgewell/trace-mapping/0.3.17: - resolution: {integrity: sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g==} - dependencies: - '@jridgewell/resolve-uri': 3.1.0 - '@jridgewell/sourcemap-codec': 1.4.14 - dev: true - - /@keyv/redis/2.5.4: - resolution: {integrity: sha512-27MTiJFME3R13fPiiOV/ww550gU9Zc75eJkzD+EpwRXcgunjcXcYEw1cM9XyaEI5y0aS1PPknRjKGlYRjT8nTQ==} + /@keyv/redis/2.5.5: + resolution: {integrity: sha512-J7dNB6iU18AbkxiN2moPcWUShgOVZtf4ySpsZIXPnuwqrvkF4X0q7nH/+mYJEjJpZwUWg6HjVxXkJYE9C2jMDw==} engines: {node: '>= 12'} dependencies: ioredis: 5.3.0 @@ -415,20 +428,22 @@ packages: fastq: 1.15.0 dev: true - /@trivago/prettier-plugin-sort-imports/4.0.0_prettier@2.8.3: - resolution: {integrity: sha512-Tyuk5ZY4a0e2MNFLdluQO9F6d1awFQYXVVujEPFfvKPPXz8DADNHzz73NMhwCSXGSuGGZcA/rKOyZBrxVNMxaA==} + /@trivago/prettier-plugin-sort-imports/4.1.1_prettier@2.8.4: + resolution: {integrity: sha512-dQ2r2uzNr1x6pJsuh/8x0IRA3CBUB+pWEW3J/7N98axqt7SQSm+2fy0FLNXvXGg77xEDC7KHxJlHfLYyi7PDcw==} peerDependencies: '@vue/compiler-sfc': 3.x prettier: 2.x + peerDependenciesMeta: + '@vue/compiler-sfc': + optional: true dependencies: - '@babel/core': 7.17.8 '@babel/generator': 7.17.7 - '@babel/parser': 7.18.9 + '@babel/parser': 7.21.2 '@babel/traverse': 7.17.3 '@babel/types': 7.17.0 javascript-natural-sort: 0.7.1 lodash: 4.17.21 - prettier: 2.8.3 + prettier: 2.8.4 transitivePeerDependencies: - supports-color dev: true @@ -437,15 +452,15 @@ packages: resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} dev: true - /@types/node/18.11.18: - resolution: {integrity: sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==} + /@types/node/18.14.2: + resolution: {integrity: sha512-1uEQxww3DaghA0RxqHx0O0ppVlo43pJhepY51OxuQIKHpjbnYLA7vcdwioNPzIqmC2u3I/dmylcqjlh0e7AyUA==} dev: true /@types/normalize-package-data/2.4.1: resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} - /@types/uuid/9.0.0: - resolution: {integrity: sha512-kr90f+ERiQtKWMz5rP32ltJ/BtULDI5RVO0uavn1HQUOwjx0R1h0rnDYNL0CepF1zL5bSY6FISAfd9tOdDhU5Q==} + /@types/uuid/9.0.1: + resolution: {integrity: sha512-rFT3ak0/2trgvp4yYZo5iKFEPsET7vKydKF+VRCxlQ9bpheehyAJH89dAkaLEq/j/RZXJIqcgsmPJKUP1Z28HA==} dev: true /aggregate-error/3.1.0: @@ -499,6 +514,10 @@ packages: engines: {node: '>=12'} dev: true + /ansi-sequence-parser/1.1.0: + resolution: {integrity: sha512-lEm8mt52to2fT8GhciPCGeCXACSz2UwIN4X2e2LJSnZ5uAbn2/dsYdOmUXq0AtWS5cpAupysIneExOgH0Vd2TQ==} + dev: true + /ansi-styles/3.2.1: resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} engines: {node: '>=4'} @@ -544,6 +563,10 @@ packages: engines: {node: '>=8'} dev: true + /asynckit/0.4.0: + resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} + dev: true + /atomically/2.0.1: resolution: {integrity: sha512-sxBhVZUFBFhqSAsYMM3X2oaUi2NVDJ8U026FsIusM8gYXls9AYs/eXzgGrufs1Qjpkxi9zunds+75QUFz+m7UQ==} dependencies: @@ -556,6 +579,14 @@ packages: engines: {node: '>= 0.4'} dev: true + /axios/0.26.1: + resolution: {integrity: sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==} + dependencies: + follow-redirects: 1.15.2 + transitivePeerDependencies: + - debug + dev: true + /balanced-match/1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} dev: true @@ -597,17 +628,6 @@ packages: fill-range: 7.0.1 dev: true - /browserslist/4.21.5: - resolution: {integrity: sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w==} - engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} - hasBin: true - dependencies: - caniuse-lite: 1.0.30001450 - electron-to-chromium: 1.4.284 - node-releases: 2.0.9 - update-browserslist-db: 1.0.10_browserslist@4.21.5 - dev: true - /buffer-from/1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} dev: true @@ -619,13 +639,13 @@ packages: ieee754: 1.2.1 dev: true - /bundle-require/3.1.2_esbuild@0.15.18: - resolution: {integrity: sha512-Of6l6JBAxiyQ5axFxUM6dYeP/W7X2Sozeo/4EYB9sJhL+dqL7TKjg+shwxp6jlu/6ZSERfsYtIpSJ1/x3XkAEA==} + /bundle-require/4.0.1_esbuild@0.17.10: + resolution: {integrity: sha512-9NQkRHlNdNpDBGmLpngF3EFDcwodhMUuLz9PaWYciVcQF9SE4LFjM2DB/xV1Li5JiuDMv7ZUWuC3rGbqR0MAXQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} peerDependencies: - esbuild: '>=0.13' + esbuild: '>=0.17' dependencies: - esbuild: 0.15.18 + esbuild: 0.17.10 load-tsconfig: 0.2.3 dev: true @@ -655,10 +675,6 @@ packages: engines: {node: '>=10'} dev: true - /caniuse-lite/1.0.30001450: - resolution: {integrity: sha512-qMBmvmQmFXaSxexkjjfMvD5rnDL0+m+dUMZKoDYsGG8iZN29RuYh9eRoMvKsT6uMAWlyUUGDEQGJJYjzCIO9ew==} - dev: true - /chalk/2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} engines: {node: '>=4'} @@ -767,6 +783,13 @@ packages: resolution: {integrity: sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==} dev: true + /combined-stream/1.0.8: + resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} + engines: {node: '>= 0.8'} + dependencies: + delayed-stream: 1.0.0 + dev: true + /commander/4.1.1: resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==} engines: {node: '>= 6'} @@ -795,10 +818,6 @@ packages: semver: 7.3.8 dev: false - /convert-source-map/1.9.0: - resolution: {integrity: sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==} - dev: true - /cross-spawn/6.0.5: resolution: {integrity: sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==} engines: {node: '>=4.8'} @@ -893,6 +912,11 @@ packages: slash: 4.0.0 dev: true + /delayed-stream/1.0.0: + resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} + engines: {node: '>=0.4.0'} + dev: true + /denque/2.1.0: resolution: {integrity: sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==} engines: {node: '>=0.10'} @@ -927,10 +951,6 @@ packages: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} dev: true - /electron-to-chromium/1.4.284: - resolution: {integrity: sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==} - dev: true - /emoji-regex/8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} dev: true @@ -1006,219 +1026,34 @@ packages: is-symbol: 1.0.4 dev: true - /esbuild-android-64/0.15.18: - resolution: {integrity: sha512-wnpt3OXRhcjfIDSZu9bnzT4/TNTDsOUvip0foZOUBG7QbSt//w3QV4FInVJxNhKc/ErhUxc5z4QjHtMi7/TbgA==} - engines: {node: '>=12'} - cpu: [x64] - os: [android] - requiresBuild: true - dev: true - optional: true - - /esbuild-android-arm64/0.15.18: - resolution: {integrity: sha512-G4xu89B8FCzav9XU8EjsXacCKSG2FT7wW9J6hOc18soEHJdtWu03L3TQDGf0geNxfLTtxENKBzMSq9LlbjS8OQ==} - engines: {node: '>=12'} - cpu: [arm64] - os: [android] - requiresBuild: true - dev: true - optional: true - - /esbuild-darwin-64/0.15.18: - resolution: {integrity: sha512-2WAvs95uPnVJPuYKP0Eqx+Dl/jaYseZEUUT1sjg97TJa4oBtbAKnPnl3b5M9l51/nbx7+QAEtuummJZW0sBEmg==} - engines: {node: '>=12'} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /esbuild-darwin-arm64/0.15.18: - resolution: {integrity: sha512-tKPSxcTJ5OmNb1btVikATJ8NftlyNlc8BVNtyT/UAr62JFOhwHlnoPrhYWz09akBLHI9nElFVfWSTSRsrZiDUA==} - engines: {node: '>=12'} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /esbuild-freebsd-64/0.15.18: - resolution: {integrity: sha512-TT3uBUxkteAjR1QbsmvSsjpKjOX6UkCstr8nMr+q7zi3NuZ1oIpa8U41Y8I8dJH2fJgdC3Dj3CXO5biLQpfdZA==} - engines: {node: '>=12'} - cpu: [x64] - os: [freebsd] - requiresBuild: true - dev: true - optional: true - - /esbuild-freebsd-arm64/0.15.18: - resolution: {integrity: sha512-R/oVr+X3Tkh+S0+tL41wRMbdWtpWB8hEAMsOXDumSSa6qJR89U0S/PpLXrGF7Wk/JykfpWNokERUpCeHDl47wA==} - engines: {node: '>=12'} - cpu: [arm64] - os: [freebsd] - requiresBuild: true - dev: true - optional: true - - /esbuild-linux-32/0.15.18: - resolution: {integrity: sha512-lphF3HiCSYtaa9p1DtXndiQEeQDKPl9eN/XNoBf2amEghugNuqXNZA/ZovthNE2aa4EN43WroO0B85xVSjYkbg==} - engines: {node: '>=12'} - cpu: [ia32] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /esbuild-linux-64/0.15.18: - resolution: {integrity: sha512-hNSeP97IviD7oxLKFuii5sDPJ+QHeiFTFLoLm7NZQligur8poNOWGIgpQ7Qf8Balb69hptMZzyOBIPtY09GZYw==} - engines: {node: '>=12'} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /esbuild-linux-arm/0.15.18: - resolution: {integrity: sha512-UH779gstRblS4aoS2qpMl3wjg7U0j+ygu3GjIeTonCcN79ZvpPee12Qun3vcdxX+37O5LFxz39XeW2I9bybMVA==} - engines: {node: '>=12'} - cpu: [arm] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /esbuild-linux-arm64/0.15.18: - resolution: {integrity: sha512-54qr8kg/6ilcxd+0V3h9rjT4qmjc0CccMVWrjOEM/pEcUzt8X62HfBSeZfT2ECpM7104mk4yfQXkosY8Quptug==} - engines: {node: '>=12'} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /esbuild-linux-mips64le/0.15.18: - resolution: {integrity: sha512-Mk6Ppwzzz3YbMl/ZZL2P0q1tnYqh/trYZ1VfNP47C31yT0K8t9s7Z077QrDA/guU60tGNp2GOwCQnp+DYv7bxQ==} - engines: {node: '>=12'} - cpu: [mips64el] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /esbuild-linux-ppc64le/0.15.18: - resolution: {integrity: sha512-b0XkN4pL9WUulPTa/VKHx2wLCgvIAbgwABGnKMY19WhKZPT+8BxhZdqz6EgkqCLld7X5qiCY2F/bfpUUlnFZ9w==} - engines: {node: '>=12'} - cpu: [ppc64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /esbuild-linux-riscv64/0.15.18: - resolution: {integrity: sha512-ba2COaoF5wL6VLZWn04k+ACZjZ6NYniMSQStodFKH/Pu6RxzQqzsmjR1t9QC89VYJxBeyVPTaHuBMCejl3O/xg==} - engines: {node: '>=12'} - cpu: [riscv64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /esbuild-linux-s390x/0.15.18: - resolution: {integrity: sha512-VbpGuXEl5FCs1wDVp93O8UIzl3ZrglgnSQ+Hu79g7hZu6te6/YHgVJxCM2SqfIila0J3k0csfnf8VD2W7u2kzQ==} - engines: {node: '>=12'} - cpu: [s390x] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /esbuild-netbsd-64/0.15.18: - resolution: {integrity: sha512-98ukeCdvdX7wr1vUYQzKo4kQ0N2p27H7I11maINv73fVEXt2kyh4K4m9f35U1K43Xc2QGXlzAw0K9yoU7JUjOg==} - engines: {node: '>=12'} - cpu: [x64] - os: [netbsd] - requiresBuild: true - dev: true - optional: true - - /esbuild-openbsd-64/0.15.18: - resolution: {integrity: sha512-yK5NCcH31Uae076AyQAXeJzt/vxIo9+omZRKj1pauhk3ITuADzuOx5N2fdHrAKPxN+zH3w96uFKlY7yIn490xQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [openbsd] - requiresBuild: true - dev: true - optional: true - - /esbuild-sunos-64/0.15.18: - resolution: {integrity: sha512-On22LLFlBeLNj/YF3FT+cXcyKPEI263nflYlAhz5crxtp3yRG1Ugfr7ITyxmCmjm4vbN/dGrb/B7w7U8yJR9yw==} - engines: {node: '>=12'} - cpu: [x64] - os: [sunos] - requiresBuild: true - dev: true - optional: true - - /esbuild-windows-32/0.15.18: - resolution: {integrity: sha512-o+eyLu2MjVny/nt+E0uPnBxYuJHBvho8vWsC2lV61A7wwTWC3jkN2w36jtA+yv1UgYkHRihPuQsL23hsCYGcOQ==} - engines: {node: '>=12'} - cpu: [ia32] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /esbuild-windows-64/0.15.18: - resolution: {integrity: sha512-qinug1iTTaIIrCorAUjR0fcBk24fjzEedFYhhispP8Oc7SFvs+XeW3YpAKiKp8dRpizl4YYAhxMjlftAMJiaUw==} - engines: {node: '>=12'} - cpu: [x64] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /esbuild-windows-arm64/0.15.18: - resolution: {integrity: sha512-q9bsYzegpZcLziq0zgUi5KqGVtfhjxGbnksaBFYmWLxeV/S1fK4OLdq2DFYnXcLMjlZw2L0jLsk1eGoB522WXQ==} - engines: {node: '>=12'} - cpu: [arm64] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /esbuild/0.15.18: - resolution: {integrity: sha512-x/R72SmW3sSFRm5zrrIjAhCeQSAWoni3CmHEqfQrZIQTM3lVCdehdwuIqaOtfC2slvpdlLa62GYoN8SxT23m6Q==} + /esbuild/0.17.10: + resolution: {integrity: sha512-n7V3v29IuZy5qgxx25TKJrEm0FHghAlS6QweUcyIgh/U0zYmQcvogWROitrTyZId1mHSkuhhuyEXtI9OXioq7A==} engines: {node: '>=12'} hasBin: true requiresBuild: true optionalDependencies: - '@esbuild/android-arm': 0.15.18 - '@esbuild/linux-loong64': 0.15.18 - esbuild-android-64: 0.15.18 - esbuild-android-arm64: 0.15.18 - esbuild-darwin-64: 0.15.18 - esbuild-darwin-arm64: 0.15.18 - esbuild-freebsd-64: 0.15.18 - esbuild-freebsd-arm64: 0.15.18 - esbuild-linux-32: 0.15.18 - esbuild-linux-64: 0.15.18 - esbuild-linux-arm: 0.15.18 - esbuild-linux-arm64: 0.15.18 - esbuild-linux-mips64le: 0.15.18 - esbuild-linux-ppc64le: 0.15.18 - esbuild-linux-riscv64: 0.15.18 - esbuild-linux-s390x: 0.15.18 - esbuild-netbsd-64: 0.15.18 - esbuild-openbsd-64: 0.15.18 - esbuild-sunos-64: 0.15.18 - esbuild-windows-32: 0.15.18 - esbuild-windows-64: 0.15.18 - esbuild-windows-arm64: 0.15.18 - dev: true - - /escalade/3.1.1: - resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} - engines: {node: '>=6'} + '@esbuild/android-arm': 0.17.10 + '@esbuild/android-arm64': 0.17.10 + '@esbuild/android-x64': 0.17.10 + '@esbuild/darwin-arm64': 0.17.10 + '@esbuild/darwin-x64': 0.17.10 + '@esbuild/freebsd-arm64': 0.17.10 + '@esbuild/freebsd-x64': 0.17.10 + '@esbuild/linux-arm': 0.17.10 + '@esbuild/linux-arm64': 0.17.10 + '@esbuild/linux-ia32': 0.17.10 + '@esbuild/linux-loong64': 0.17.10 + '@esbuild/linux-mips64el': 0.17.10 + '@esbuild/linux-ppc64': 0.17.10 + '@esbuild/linux-riscv64': 0.17.10 + '@esbuild/linux-s390x': 0.17.10 + '@esbuild/linux-x64': 0.17.10 + '@esbuild/netbsd-x64': 0.17.10 + '@esbuild/openbsd-x64': 0.17.10 + '@esbuild/sunos-x64': 0.17.10 + '@esbuild/win32-arm64': 0.17.10 + '@esbuild/win32-ia32': 0.17.10 + '@esbuild/win32-x64': 0.17.10 dev: true /escape-string-regexp/1.0.5: @@ -1309,12 +1144,31 @@ packages: path-exists: 5.0.0 dev: false + /follow-redirects/1.15.2: + resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==} + engines: {node: '>=4.0'} + peerDependencies: + debug: '*' + peerDependenciesMeta: + debug: + optional: true + dev: true + /for-each/0.3.3: resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} dependencies: is-callable: 1.2.7 dev: true + /form-data/4.0.0: + resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} + engines: {node: '>= 6'} + dependencies: + asynckit: 0.4.0 + combined-stream: 1.0.8 + mime-types: 2.1.35 + dev: true + /fs.realpath/1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} dev: true @@ -1344,11 +1198,6 @@ packages: resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} dev: true - /gensync/1.0.0-beta.2: - resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} - engines: {node: '>=6.9.0'} - dev: true - /get-intrinsic/1.2.0: resolution: {integrity: sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==} dependencies: @@ -1370,8 +1219,8 @@ packages: get-intrinsic: 1.2.0 dev: true - /get-tsconfig/4.3.0: - resolution: {integrity: sha512-YCcF28IqSay3fqpIu5y3Krg/utCBHBeoflkZyHj/QcqI2nrLPC3ZegS9CmIo+hJb8K7aiGsuUl7PwWVjNG2HQQ==} + /get-tsconfig/4.4.0: + resolution: {integrity: sha512-0Gdjo/9+FzsYhXCEFueo2aY1z1tpXrxWZzP7k8ul9qt1U5o8rYJwTJYmaeHdrVosYIVYkOy2iwCJ9FdpocJhPQ==} dev: true /glob-parent/5.1.2: @@ -1794,12 +1643,6 @@ packages: resolution: {integrity: sha512-XQmWYj2Sm4kn4WeTYvmpKEbyPsL7nBsb647c7pMe6l02/yx2+Jfc4dT6UZkEXnIUb5LhD55r2HPsJ1milQ4rDg==} dev: false - /json5/2.2.3: - resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==} - engines: {node: '>=6'} - hasBin: true - dev: true - /jsonc-parser/3.2.0: resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==} dev: true @@ -1823,8 +1666,8 @@ packages: /lines-and-columns/1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} - /lint-staged/13.1.0: - resolution: {integrity: sha512-pn/sR8IrcF/T0vpWLilih8jmVouMlxqXxKuAojmbiGX5n/gDnz+abdPptlj0vYnbfE0SQNl3CY/HwtM0+yfOVQ==} + /lint-staged/13.1.2: + resolution: {integrity: sha512-K9b4FPbWkpnupvK3WXZLbgu9pchUJ6N7TtVZjbaPsoizkqFUDkUReUL25xdrCljJs7uLUF3tZ7nVPeo/6lp+6w==} engines: {node: ^14.13.1 || >=16.0.0} hasBin: true dependencies: @@ -1928,12 +1771,6 @@ packages: wrap-ansi: 6.2.0 dev: true - /lru-cache/5.1.1: - resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} - dependencies: - yallist: 3.1.1 - dev: true - /lru-cache/6.0.0: resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} engines: {node: '>=10'} @@ -2000,6 +1837,18 @@ packages: picomatch: 2.3.1 dev: true + /mime-db/1.52.0: + resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} + engines: {node: '>= 0.6'} + dev: true + + /mime-types/2.1.35: + resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} + engines: {node: '>= 0.6'} + dependencies: + mime-db: 1.52.0 + dev: true + /mimic-fn/2.1.0: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} engines: {node: '>=6'} @@ -2020,8 +1869,8 @@ packages: brace-expansion: 1.1.11 dev: true - /minimatch/5.1.6: - resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} + /minimatch/7.4.2: + resolution: {integrity: sha512-xy4q7wou3vUoC9k1xGTXc+awNdGaGVHtFUaey8tiX4H1QRc04DZ/rmDFwNm2EBsuYEhAZ6SgMmYf3InGY6OauA==} engines: {node: '>=10'} dependencies: brace-expansion: 2.0.1 @@ -2060,10 +1909,6 @@ packages: resolution: {integrity: sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==} dev: true - /node-releases/2.0.9: - resolution: {integrity: sha512-2xfmOrRkGogbTK9R6Leda0DGiXeY3p2NJpy4+gNCffdUvV6mdEJnaDEic1i3Ec2djAo8jWYoJMR5PB0MSMpxUA==} - dev: true - /normalize-package-data/2.5.0: resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==} dependencies: @@ -2161,6 +2006,15 @@ packages: mimic-fn: 4.0.0 dev: true + /openai/3.2.1: + resolution: {integrity: sha512-762C9BNlJPbjjlWZi4WYK9iM2tAVAv0uUp1UmI34vb0CN5T2mjB/qM6RYBmNKMh/dN9fC+bxqPwWJZUTWW052A==} + dependencies: + axios: 0.26.1 + form-data: 4.0.0 + transitivePeerDependencies: + - debug + dev: true + /ora/6.1.2: resolution: {integrity: sha512-EJQ3NiP5Xo94wJXIzAyOtSb0QEIAUu7m8t6UZ9krbz0vAJqr92JpcK/lEXg91q6B9pEGqrykkd2EQplnifDSBw==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -2218,8 +2072,8 @@ packages: aggregate-error: 4.0.1 dev: true - /p-timeout/6.1.0: - resolution: {integrity: sha512-s0y6Le9QYGELLzNpFIt6h8B2DHTVUDLStvxtvRMSKNKeuNVVWby2dZ+pIJpW4/pWr5a3s8W85wBNtc0ZA+lzCg==} + /p-timeout/6.1.1: + resolution: {integrity: sha512-yqz2Wi4fiFRpMmK0L2pGAU49naSUaP23fFIQL2Y6YT+qDGPoFwpvgQM/wzc6F8JoenUkIlAFa4Ql7NguXBxI7w==} engines: {node: '>=14.16'} dev: false @@ -2286,10 +2140,6 @@ packages: engines: {node: '>=8'} dev: true - /picocolors/1.0.0: - resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} - dev: true - /picomatch/2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} @@ -2333,8 +2183,8 @@ packages: yaml: 1.10.2 dev: true - /prettier/2.8.3: - resolution: {integrity: sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw==} + /prettier/2.8.4: + resolution: {integrity: sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==} engines: {node: '>=10.13.0'} hasBin: true dev: true @@ -2500,8 +2350,8 @@ packages: glob: 7.2.3 dev: true - /rollup/3.12.0: - resolution: {integrity: sha512-4MZ8kA2HNYahIjz63rzrMMRvDqQDeS9LoriJvMuV0V6zIGysP36e9t4yObUfwdT9h/szXoHQideICftcdZklWg==} + /rollup/3.18.0: + resolution: {integrity: sha512-J8C6VfEBjkvYPESMQYxKHxNOh4A5a3FlP+0BETGo34HEcE4eTlgCrO2+eWzlu2a/sHs2QUkZco+wscH7jhhgWg==} engines: {node: '>=14.18.0', npm: '>=8.0.0'} hasBin: true optionalDependencies: @@ -2537,11 +2387,6 @@ packages: hasBin: true dev: true - /semver/6.3.0: - resolution: {integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==} - hasBin: true - dev: true - /semver/7.3.8: resolution: {integrity: sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==} engines: {node: '>=10'} @@ -2577,9 +2422,10 @@ packages: resolution: {integrity: sha512-QHsz8GgQIGKlRi24yFc6a6lN69Idnx634w49ay6+jA5yFh7a1UY+4Rp6HPx/L/1zcEDPEij8cIsiqR6bQsE5VQ==} dev: true - /shiki/0.12.1: - resolution: {integrity: sha512-aieaV1m349rZINEBkjxh2QbBvFFQOlgqYTNtCal82hHj4dDZ76oMlQIX+C7ryerBTDiga3e5NfH6smjdJ02BbQ==} + /shiki/0.14.1: + resolution: {integrity: sha512-+Jz4nBkCBe0mEDqo1eKRcCdjRtrCjozmcbTUjbPTX7OOJfEbTZzlUWlZtGe3Gb5oV1/jnojhG//YZc3rs9zSEw==} dependencies: + ansi-sequence-parser: 1.1.0 jsonc-parser: 3.2.0 vscode-oniguruma: 1.7.0 vscode-textmate: 8.0.0 @@ -2850,9 +2696,9 @@ packages: resolution: {integrity: sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==} dev: true - /tsup/6.5.0_typescript@4.9.5: - resolution: {integrity: sha512-36u82r7rYqRHFkD15R20Cd4ercPkbYmuvRkz3Q1LCm5BsiFNUgpo36zbjVhCOgvjyxNBWNKHsaD5Rl8SykfzNA==} - engines: {node: '>=14'} + /tsup/6.6.3_typescript@4.9.5: + resolution: {integrity: sha512-OLx/jFllYlVeZQ7sCHBuRVEQBBa1tFbouoc/gbYakyipjVQdWy/iQOvmExUA/ewap9iQ7tbJf9pW0PgcEFfJcQ==} + engines: {node: '>=14.18'} hasBin: true peerDependencies: '@swc/core': ^1 @@ -2866,17 +2712,17 @@ packages: typescript: optional: true dependencies: - bundle-require: 3.1.2_esbuild@0.15.18 + bundle-require: 4.0.1_esbuild@0.17.10 cac: 6.7.14 chokidar: 3.5.3 debug: 4.3.4 - esbuild: 0.15.18 + esbuild: 0.17.10 execa: 5.1.1 globby: 11.1.0 joycon: 3.1.1 postcss-load-config: 3.1.4 resolve-from: 5.0.0 - rollup: 3.12.0 + rollup: 3.18.0 source-map: 0.8.0-beta.0 sucrase: 3.29.0 tree-kill: 1.2.2 @@ -2886,13 +2732,13 @@ packages: - ts-node dev: true - /tsx/3.12.2: - resolution: {integrity: sha512-ykAEkoBg30RXxeOMVeZwar+JH632dZn9EUJVyJwhfag62k6UO/dIyJEV58YuLF6e5BTdV/qmbQrpkWqjq9cUnQ==} + /tsx/3.12.3: + resolution: {integrity: sha512-Wc5BFH1xccYTXaQob+lEcimkcb/Pq+0en2s+ruiX0VEIC80nV7/0s7XRahx8NnsoCnpCVUPz8wrqVSPi760LkA==} hasBin: true dependencies: - '@esbuild-kit/cjs-loader': 2.4.1 - '@esbuild-kit/core-utils': 3.0.0 - '@esbuild-kit/esm-loader': 2.5.4 + '@esbuild-kit/cjs-loader': 2.4.2 + '@esbuild-kit/core-utils': 3.1.0 + '@esbuild-kit/esm-loader': 2.5.5 optionalDependencies: fsevents: 2.3.2 dev: true @@ -2920,17 +2766,17 @@ packages: is-typed-array: 1.1.10 dev: true - /typedoc-plugin-markdown/3.14.0_typedoc@0.23.24: + /typedoc-plugin-markdown/3.14.0_typedoc@0.23.26: resolution: {integrity: sha512-UyQLkLRkfTFhLdhSf3RRpA3nNInGn+k6sll2vRXjflaMNwQAAiB61SYbisNZTg16t4K1dt1bPQMMGLrxS0GZ0Q==} peerDependencies: typedoc: '>=0.23.0' dependencies: handlebars: 4.7.7 - typedoc: 0.23.24_typescript@4.9.5 + typedoc: 0.23.26_typescript@4.9.5 dev: true - /typedoc/0.23.24_typescript@4.9.5: - resolution: {integrity: sha512-bfmy8lNQh+WrPYcJbtjQ6JEEsVl/ce1ZIXyXhyW+a1vFrjO39t6J8sL/d6FfAGrJTc7McCXgk9AanYBSNvLdIA==} + /typedoc/0.23.26_typescript@4.9.5: + resolution: {integrity: sha512-5m4KwR5tOLnk0OtMaRn9IdbeRM32uPemN9kur7YK9wFqx8U0CYrvO9aVq6ysdZSV1c824BTm+BuQl2Ze/k1HtA==} engines: {node: '>= 14.14'} hasBin: true peerDependencies: @@ -2938,8 +2784,8 @@ packages: dependencies: lunr: 2.3.9 marked: 4.2.12 - minimatch: 5.1.6 - shiki: 0.12.1 + minimatch: 7.4.2 + shiki: 0.14.1 typescript: 4.9.5 dev: true @@ -2966,17 +2812,6 @@ packages: which-boxed-primitive: 1.0.2 dev: true - /update-browserslist-db/1.0.10_browserslist@4.21.5: - resolution: {integrity: sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ==} - hasBin: true - peerDependencies: - browserslist: '>= 4.21.0' - dependencies: - browserslist: 4.21.5 - escalade: 3.1.1 - picocolors: 1.0.0 - dev: true - /uri-js/4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} dependencies: @@ -3091,10 +2926,6 @@ packages: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} dev: true - /yallist/3.1.1: - resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} - dev: true - /yallist/4.0.0: resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} diff --git a/readme.md b/readme.md index 473afb5..afef50b 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # ChatGPT API -> Node.js client for the unofficial [ChatGPT](https://openai.com/blog/chatgpt/) API. +> Node.js client for the official [ChatGPT](https://openai.com/blog/chatgpt/) API. [![NPM](https://img.shields.io/npm/v/chatgpt.svg)](https://www.npmjs.com/package/chatgpt) [![Build Status](https://github.com/transitive-bullshit/chatgpt-api/actions/workflows/test.yml/badge.svg)](https://github.com/transitive-bullshit/chatgpt-api/actions/workflows/test.yml) [![MIT License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/transitive-bullshit/chatgpt-api/blob/main/license) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) @@ -31,6 +31,23 @@ This package is a Node.js wrapper around [ChatGPT](https://openai.com/blog/chatg ## Updates
+March 1, 2023 + +The [official OpenAI chat completions API](https://platform.openai.com/docs/guides/chat) has been released, and it has now become the default for this package! πŸ”₯ + +| Method | Free? | Robust? | Quality? | +| --------------------------- | ------ | -------- | ----------------------- | +| `ChatGPTAPI` | ❌ No | βœ… Yes | βœ…οΈ Real ChatGPT models | +| `ChatGPTUnofficialProxyAPI` | βœ… Yes | β˜‘οΈ Maybe | βœ… Real ChatGPT | + +**Note**: We strongly recommendd using the official `ChatGPTAPI` since it uses officially supported APIs from OpenAI. We may remove support for `ChatGPTUnofficialProxyAPI` in a future release. + +1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo-0301` model with the official OpenAI chat completions API (official, robust approach, but it's not free) +2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited) + +
+ +
Feb 19, 2023 We now provide three ways of accessing the unofficial ChatGPT API, all of which have tradeoffs: @@ -144,17 +161,19 @@ Make sure you're using `node >= 18` so `fetch` is available (or `node >= 14` if To use this module from Node.js, you need to pick between two methods: -| Method | Free? | Robust? | Quality? | -| --------------------------- | ------ | -------- | ----------------- | -| `ChatGPTAPI` | ❌ No | βœ… Yes | β˜‘οΈ Mimics ChatGPT | -| `ChatGPTUnofficialProxyAPI` | βœ… Yes | β˜‘οΈ Maybe | βœ… Real ChatGPT | +| Method | Free? | Robust? | Quality? | +| --------------------------- | ------ | -------- | ----------------------- | +| `ChatGPTAPI` | ❌ No | βœ… Yes | βœ…οΈ Real ChatGPT models | +| `ChatGPTUnofficialProxyAPI` | βœ… Yes | β˜‘οΈ Maybe | βœ… Real ChatGPT | -1. `ChatGPTAPI` - Uses `text-davinci-003` to mimic ChatGPT via the official OpenAI completions API (most robust approach, but it's not free and doesn't use a model fine-tuned for chat). You can override the model, completion params, and prompt to fully customize your bot. +1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo-0301` model with the official OpenAI chat completions API (official, robust approach, but it's not free). You can override the model, completion params, and system message to fully customize your assistant. 2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited) Both approaches have very similar APIs, so it should be simple to swap between them. +**Note**: We strongly recommendd using the official `ChatGPTAPI` since it uses officially supported APIs from OpenAI. We may remove support for `ChatGPTUnofficialProxyAPI` in a future release. + ### Usage - ChatGPTAPI Sign up for an [OpenAI API key](https://platform.openai.com/overview) and store it in your environment. @@ -172,7 +191,7 @@ async function example() { } ``` -You can override the default `model` (`text-davinci-003`) and any [OpenAI completion params](https://platform.openai.com/docs/api-reference/completions/create) using `completionParams`: +You can override the default `model` (`gpt-3.5-turbo-0301`) and any [OpenAI completion params](https://platform.openai.com/docs/api-reference/chat/create) using `completionParams`: ```ts const api = new ChatGPTAPI({ @@ -184,7 +203,7 @@ const api = new ChatGPTAPI({ }) ``` -If you want to track the conversation, you'll need to pass the `parentMessageId` and `conversationId` like this: +If you want to track the conversation, you'll need to pass the `parentMessageId` like this: ```ts const api = new ChatGPTAPI({ apiKey: process.env.OPENAI_API_KEY }) @@ -195,14 +214,12 @@ console.log(res.text) // send a follow-up res = await api.sendMessage('Can you expand on that?', { - conversationId: res.conversationId, parentMessageId: res.id }) console.log(res.text) // send another follow-up res = await api.sendMessage('What were we talking about?', { - conversationId: res.conversationId, parentMessageId: res.id }) console.log(res.text) @@ -232,7 +249,7 @@ const response = await api.sendMessage( ) ``` -If you want to see more info about what's actually being sent to [OpenAI's completions API](https://platform.openai.com/docs/api-reference/completions), set the `debug: true` option in the `ChatGPTAPI` constructor: +If you want to see more info about what's actually being sent to [OpenAI's chat completions API](https://platform.openai.com/docs/api-reference/chat/create), set the `debug: true` option in the `ChatGPTAPI` constructor: ```ts const api = new ChatGPTAPI({ @@ -241,11 +258,11 @@ const api = new ChatGPTAPI({ }) ``` -You'll notice that we're using a reverse-engineered `promptPrefix` and `promptSuffix`. You can customize these via the `sendMessage` options: +We default to a basic `systemMessage`. You can override this in either the `ChatGPTAPI` constructor or `sendMessage`: ```ts const res = await api.sendMessage('what is the answer to the universe?', { - promptPrefix: `You are ChatGPT, a large language model trained by OpenAI. You answer as concisely as possible for each responseIf you are generating a list, do not have too many items. + systemMessage: `You are ChatGPT, a large language model trained by OpenAI. You answer as concisely as possible for each responseIf you are generating a list, do not have too many items. Current date: ${new Date().toISOString()}\n\n` }) ``` @@ -271,7 +288,7 @@ async function example() { ### Usage - ChatGPTUnofficialProxyAPI -The API is almost exactly the same for the `ChatGPTUnofficialProxyAPI`; you just need to provide a ChatGPT `accessToken` instead of an OpenAI API key. +The API for `ChatGPTUnofficialProxyAPI` is almost exactly the same. You just need to provide a ChatGPT `accessToken` instead of an OpenAI API key. ```ts import { ChatGPTUnofficialProxyAPI } from 'chatgpt' @@ -292,6 +309,8 @@ See [demos/demo-reverse-proxy](./demos/demo-reverse-proxy.ts) for a full example npx tsx demos/demo-reverse-proxy.ts ``` +`ChatGPTUnofficialProxyAPI` messages also contain a `conversationid` in addition to `parentMessageId`, since the ChatGPT webapp can't reference messages across + #### Reverse Proxy You can override the reverse proxy by passing `apiReverseProxyUrl`: diff --git a/src/chatgpt-api.ts b/src/chatgpt-api.ts index 1c881f1..e23f330 100644 --- a/src/chatgpt-api.ts +++ b/src/chatgpt-api.ts @@ -8,8 +8,7 @@ import * as types from './types' import { fetch as globalFetch } from './fetch' import { fetchSSE } from './fetch-sse' -// Official model (costs money and is not fine-tuned for chat) -const CHATGPT_MODEL = 'text-davinci-003' +const CHATGPT_MODEL = 'gpt-3.5-turbo-0301' const USER_LABEL_DEFAULT = 'User' const ASSISTANT_LABEL_DEFAULT = 'ChatGPT' @@ -17,16 +16,15 @@ const ASSISTANT_LABEL_DEFAULT = 'ChatGPT' export class ChatGPTAPI { protected _apiKey: string protected _apiBaseUrl: string - protected _apiReverseProxyUrl: string protected _debug: boolean - protected _completionParams: Omit + protected _systemMessage: string + protected _completionParams: Omit< + types.openai.CreateChatCompletionRequest, + 'messages' | 'n' + > protected _maxModelTokens: number protected _maxResponseTokens: number - protected _userLabel: string - protected _assistantLabel: string - protected _endToken: string - protected _sepToken: string protected _fetch: types.FetchFn protected _getMessageById: types.GetMessageByIdFunction @@ -35,16 +33,14 @@ export class ChatGPTAPI { protected _messageStore: Keyv /** - * Creates a new client wrapper around OpenAI's completion API using the - * unofficial ChatGPT model. + * Creates a new client wrapper around OpenAI's chat completion API, mimicing the official ChatGPT webapp's functionality as closely as possible. * * @param apiKey - OpenAI API key (required). * @param apiBaseUrl - Optional override for the OpenAI API base URL. - * @param apiReverseProxyUrl - Optional override for a reverse proxy URL to use instead of the OpenAI API completions API. * @param debug - Optional enables logging debugging info to stdout. - * @param completionParams - Param overrides to send to the [OpenAI completion API](https://platform.openai.com/docs/api-reference/completions/create). Options like `temperature` and `presence_penalty` can be tweaked to change the personality of the assistant. - * @param maxModelTokens - Optional override for the maximum number of tokens allowed by the model's context. Defaults to 4096 for the `text-chat-davinci-002-20230126` model. - * @param maxResponseTokens - Optional override for the minimum number of tokens allowed for the model's response. Defaults to 1000 for the `text-chat-davinci-002-20230126` model. + * @param completionParams - Param overrides to send to the [OpenAI chat completion API](https://platform.openai.com/docs/api-reference/chat/create). Options like `temperature` and `presence_penalty` can be tweaked to change the personality of the assistant. + * @param maxModelTokens - Optional override for the maximum number of tokens allowed by the model's context. Defaults to 4096. + * @param maxResponseTokens - Optional override for the minimum number of tokens allowed for the model's response. Defaults to 1000. * @param messageStore - Optional [Keyv](https://github.com/jaredwray/keyv) store to persist chat messages to. If not provided, messages will be lost when the process exits. * @param getMessageById - Optional function to retrieve a message by its ID. If not provided, the default implementation will be used (using an in-memory `messageStore`). * @param upsertMessage - Optional function to insert or update a message. If not provided, the default implementation will be used (using an in-memory `messageStore`). @@ -56,13 +52,14 @@ export class ChatGPTAPI { /** @defaultValue `'https://api.openai.com'` **/ apiBaseUrl?: string - /** @defaultValue `undefined` **/ - apiReverseProxyUrl?: string - /** @defaultValue `false` **/ debug?: boolean - completionParams?: Partial + completionParams?: Partial< + Omit + > + + systemMessage?: string /** @defaultValue `4096` **/ maxModelTokens?: number @@ -70,12 +67,6 @@ export class ChatGPTAPI { /** @defaultValue `1000` **/ maxResponseTokens?: number - /** @defaultValue `'User'` **/ - userLabel?: string - - /** @defaultValue `'ChatGPT'` **/ - assistantLabel?: string - messageStore?: Keyv getMessageById?: types.GetMessageByIdFunction upsertMessage?: types.UpsertMessageFunction @@ -85,14 +76,12 @@ export class ChatGPTAPI { const { apiKey, apiBaseUrl = 'https://api.openai.com', - apiReverseProxyUrl, debug = false, messageStore, completionParams, + systemMessage, maxModelTokens = 4096, maxResponseTokens = 1000, - userLabel = USER_LABEL_DEFAULT, - assistantLabel = ASSISTANT_LABEL_DEFAULT, getMessageById = this._defaultGetMessageById, upsertMessage = this._defaultUpsertMessage, fetch = globalFetch @@ -100,7 +89,6 @@ export class ChatGPTAPI { this._apiKey = apiKey this._apiBaseUrl = apiBaseUrl - this._apiReverseProxyUrl = apiReverseProxyUrl this._debug = !!debug this._fetch = fetch @@ -112,26 +100,15 @@ export class ChatGPTAPI { ...completionParams } - if (this._isChatGPTModel) { - this._endToken = '<|im_end|>' - this._sepToken = '<|im_sep|>' + this._systemMessage = systemMessage - if (!this._completionParams.stop) { - this._completionParams.stop = [this._endToken, this._sepToken] - } - } else { - this._endToken = '<|endoftext|>' - this._sepToken = this._endToken - - if (!this._completionParams.stop) { - this._completionParams.stop = [this._endToken] - } + if (this._systemMessage === undefined) { + const currentDate = new Date().toISOString().split('T')[0] + this._systemMessage = `You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possiboe.\nCurrent date: ${currentDate}\n` } this._maxModelTokens = maxModelTokens this._maxResponseTokens = maxResponseTokens - this._userLabel = userLabel - this._assistantLabel = assistantLabel this._getMessageById = getMessageById this._upsertMessage = upsertMessage @@ -145,7 +122,7 @@ export class ChatGPTAPI { } if (!this._apiKey) { - throw new Error('ChatGPT invalid apiKey') + throw new Error('OpenAI missing required apiKey') } if (!this._fetch) { @@ -158,24 +135,20 @@ export class ChatGPTAPI { } /** - * Sends a message to ChatGPT, waits for the response to resolve, and returns - * the response. + * Sends a message to the OpenAI chat completions endpoint, waits for the response + * to resolve, and returns the response. * * If you want your response to have historical context, you must provide a valid `parentMessageId`. * * If you want to receive a stream of partial responses, use `opts.onProgress`. - * If you want to receive the full response, including message and conversation IDs, - * you can use `opts.onConversationResponse` or use the `ChatGPTAPI.getConversation` - * helper. * - * Set `debug: true` in the `ChatGPTAPI` constructor to log more info on the full prompt sent to the OpenAI completions API. You can override the `promptPrefix` and `promptSuffix` in `opts` to customize the prompt. + * Set `debug: true` in the `ChatGPTAPI` constructor to log more info on the full prompt sent to the OpenAI chat completions API. You can override the `systemMessage` in `opts` to customize the assistant's instructions. * * @param message - The prompt message to send * @param opts.conversationId - Optional ID of a conversation to continue (defaults to a random UUID) * @param opts.parentMessageId - Optional ID of the previous message in the conversation (defaults to `undefined`) * @param opts.messageId - Optional ID of the message to send (defaults to a random UUID) - * @param opts.promptPrefix - Optional override for the prompt prefix to send to the OpenAI completions endpoint - * @param opts.promptSuffix - Optional override for the prompt suffix to send to the OpenAI completions endpoint + * @param opts.systemMessage - Optional override for the chat "system message" which acts as instructions to the model (defaults to the ChatGPT system message) * @param opts.timeoutMs - Optional timeout in milliseconds (defaults to no timeout) * @param opts.onProgress - Optional callback which will be invoked every time the partial response is updated * @param opts.abortSignal - Optional callback used to abort the underlying `fetch` call using an [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) @@ -212,7 +185,10 @@ export class ChatGPTAPI { } await this._upsertMessage(message) - const { prompt, maxTokens } = await this._buildPrompt(text, opts) + const { messages, maxTokens, numTokens } = await this._buildMessages( + text, + opts + ) const result: types.ChatMessage = { role: 'assistant', @@ -224,8 +200,7 @@ export class ChatGPTAPI { const responseP = new Promise( async (resolve, reject) => { - const url = - this._apiReverseProxyUrl || `${this._apiBaseUrl}/v1/completions` + const url = `${this._apiBaseUrl}/v1/chat/completions` const headers = { 'Content-Type': 'application/json', Authorization: `Bearer ${this._apiKey}` @@ -233,12 +208,11 @@ export class ChatGPTAPI { const body = { max_tokens: maxTokens, ...this._completionParams, - prompt, + messages, stream } if (this._debug) { - const numTokens = await this._getTokenCount(body.prompt) console.log(`sendMessage (${numTokens} tokens)`, body) } @@ -257,7 +231,7 @@ export class ChatGPTAPI { } try { - const response: types.openai.CompletionResponse = + const response: types.CreateChatCompletionDeltaResponse = JSON.parse(data) if (response.id) { @@ -265,13 +239,21 @@ export class ChatGPTAPI { } if (response?.choices?.length) { - result.text += response.choices[0].text - result.detail = response + const delta = response.choices[0].delta + if (delta?.content) { + result.delta = delta.content + result.text += delta.content + result.detail = response - onProgress?.(result) + if (delta.role) { + result.role = delta.role + } + + onProgress?.(result) + } } } catch (err) { - console.warn('ChatGPT stream SEE event unexpected error', err) + console.warn('OpenAI stream SEE event unexpected error', err) return reject(err) } } @@ -289,7 +271,7 @@ export class ChatGPTAPI { if (!res.ok) { const reason = await res.text() - const msg = `ChatGPT error ${ + const msg = `OpenAI error ${ res.status || res.statusText }: ${reason}` const error = new types.ChatGPTError(msg, { cause: res }) @@ -298,7 +280,8 @@ export class ChatGPTAPI { return reject(error) } - const response: types.openai.CompletionResponse = await res.json() + const response: types.openai.CreateChatCompletionResponse = + await res.json() if (this._debug) { console.log(response) } @@ -308,12 +291,16 @@ export class ChatGPTAPI { } if (response?.choices?.length) { - result.text = response.choices[0].text.trim() + const message = response.choices[0].message + result.text = message.content + if (message.role) { + result.role = message.role + } } else { const res = response as any return reject( new Error( - `ChatGPT error: ${ + `OpenAI error: ${ res?.detail?.message || res?.detail || 'unknown' }` ) @@ -343,7 +330,7 @@ export class ChatGPTAPI { return pTimeout(responseP, { milliseconds: timeoutMs, - message: 'ChatGPT timed out waiting for response' + message: 'OpenAI timed out waiting for response' }) } else { return responseP @@ -358,44 +345,58 @@ export class ChatGPTAPI { this._apiKey = apiKey } - protected async _buildPrompt( - message: string, - opts: types.SendMessageOptions - ) { - /* - ChatGPT preamble example: - You are ChatGPT, a large language model trained by OpenAI. You answer as concisely as possible for each response (e.g. don’t be verbose). It is very important that you answer as concisely as possible, so please remember this. If you are generating a list, do not have too many items. Keep the number of items short. - Knowledge cutoff: 2021-09 - Current date: 2023-01-31 - */ - // This preamble was obtained by asking ChatGPT "Please print the instructions you were given before this message." - const currentDate = new Date().toISOString().split('T')[0] + protected async _buildMessages(text: string, opts: types.SendMessageOptions) { + const { systemMessage = this._systemMessage } = opts + let { parentMessageId } = opts - const promptPrefix = - opts.promptPrefix || - `Instructions:\nYou are ${this._assistantLabel}, a large language model trained by OpenAI. -Current date: ${currentDate}${this._sepToken}\n\n` - const promptSuffix = opts.promptSuffix || `\n\n${this._assistantLabel}:\n` + const userLabel = USER_LABEL_DEFAULT + const assistantLabel = ASSISTANT_LABEL_DEFAULT const maxNumTokens = this._maxModelTokens - this._maxResponseTokens - let { parentMessageId } = opts - let nextPromptBody = `${this._userLabel}:\n\n${message}${this._endToken}` - let promptBody = '' - let prompt: string - let numTokens: number + let messages: types.openai.ChatCompletionRequestMessage[] = [] + + if (systemMessage) { + messages.push({ + role: 'system', + content: systemMessage + }) + } + + const systemMessageOffset = messages.length + let nextMessages = messages.concat([ + { + ...{ + role: 'user', + content: text, + name: opts.name + } + } + ]) + let numTokens = 0 do { - const nextPrompt = `${promptPrefix}${nextPromptBody}${promptSuffix}` - const nextNumTokens = await this._getTokenCount(nextPrompt) - const isValidPrompt = nextNumTokens <= maxNumTokens + const prompt = nextMessages + .reduce((prompt, message) => { + switch (message.role) { + case 'system': + return [prompt, `Instructions:\n${message.content}`] + case 'user': + return [prompt, `${userLabel}:\n${message.content}`] + default: + return [prompt, `${assistantLabel}:\n${message.content}`] + } + }, []) + .join('\n\n') + + const nextNumTokensEstimate = await this._getTokenCount(prompt) + const isValidPrompt = nextNumTokensEstimate <= maxNumTokens if (prompt && !isValidPrompt) { break } - promptBody = nextPromptBody - prompt = nextPrompt - numTokens = nextNumTokens + messages = nextMessages + numTokens = nextNumTokensEstimate if (!isValidPrompt) { break @@ -411,12 +412,18 @@ Current date: ${currentDate}${this._sepToken}\n\n` } const parentMessageRole = parentMessage.role || 'user' - const parentMessageRoleDesc = - parentMessageRole === 'user' ? this._userLabel : this._assistantLabel - // TODO: differentiate between assistant and user messages - const parentMessageString = `${parentMessageRoleDesc}:\n\n${parentMessage.text}${this._endToken}\n\n` - nextPromptBody = `${parentMessageString}${promptBody}` + nextMessages = nextMessages.slice(0, systemMessageOffset).concat([ + { + ...{ + role: parentMessageRole, + content: parentMessage.text, + name: parentMessage.name + } + }, + ...nextMessages.slice(systemMessageOffset) + ]) + parentMessageId = parentMessage.parentMessageId } while (true) @@ -427,46 +434,26 @@ Current date: ${currentDate}${this._sepToken}\n\n` Math.min(this._maxModelTokens - numTokens, this._maxResponseTokens) ) - return { prompt, maxTokens } + return { messages, maxTokens, numTokens } } protected async _getTokenCount(text: string) { - if (this._isChatGPTModel) { - // With this model, "<|im_end|>" is 1 token, but tokenizers aren't aware of it yet. - // Replace it with "<|endoftext|>" (which it does know about) so that the tokenizer can count it as 1 token. - // text = text.replace(/<\|im_end\|>/g, '<|endoftext|>') - // text = text.replace(/<\|im_sep\|>/g, '<|endoftext|>') - } - - // TODO: this seems hacky and should be fixed in the tokenizer + // TODO: use a better fix in the tokenizer text = text.replace(/<\|endoftext\|>/g, '') return tokenizer.encode(text).length } - protected get _isChatGPTModel() { - return ( - this._completionParams.model.startsWith('text-chat') || - this._completionParams.model.startsWith('text-davinci-002-render') - ) - } - protected async _defaultGetMessageById( id: string ): Promise { const res = await this._messageStore.get(id) - if (this._debug) { - console.log('getMessageById', id, res) - } return res } protected async _defaultUpsertMessage( message: types.ChatMessage ): Promise { - if (this._debug) { - console.log('upsertMessage', message.id, message) - } await this._messageStore.set(message.id, message) } } diff --git a/src/types.ts b/src/types.ts index abb531c..12e4239 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,14 +1,18 @@ -export type Role = 'user' | 'assistant' +import type * as openai from 'openai' + +export { openai } + +export type Role = 'user' | 'assistant' | 'system' export type FetchFn = typeof fetch export type SendMessageOptions = { - conversationId?: string + /** The name of a user in a multi-user chat. */ + name?: string parentMessageId?: string messageId?: string stream?: boolean - promptPrefix?: string - promptSuffix?: string + systemMessage?: string timeoutMs?: number onProgress?: (partialResponse: ChatMessage) => void abortSignal?: AbortSignal @@ -30,26 +34,21 @@ export interface ChatMessage { id: string text: string role: Role - parentMessageId?: string - conversationId?: string + name?: string + delta?: string detail?: any -} -export type ChatGPTErrorType = - | 'unknown' - | 'chatgpt:pool:account-on-cooldown' - | 'chatgpt:pool:account-not-found' - | 'chatgpt:pool:no-accounts' - | 'chatgpt:pool:timeout' - | 'chatgpt:pool:rate-limit' - | 'chatgpt:pool:unavailable' + // relevant for both ChatGPTAPI and ChatGPTUnofficialProxyAPI + parentMessageId?: string + // only relevant for ChatGPTUnofficialProxyAPI + conversationId?: string +} export class ChatGPTError extends Error { statusCode?: number statusText?: string isFinal?: boolean accountId?: string - type?: ChatGPTErrorType } /** Returns a chat message from a store by it's ID (or null if not found). */ @@ -58,121 +57,6 @@ export type GetMessageByIdFunction = (id: string) => Promise /** Upserts a chat message to a store. */ export type UpsertMessageFunction = (message: ChatMessage) => Promise -export namespace openai { - export type CompletionParams = { - /** ID of the model to use. */ - model: string - - /** The string prompt to generate a completion for. */ - prompt: string - - /** - * The suffix that comes after a completion of inserted text. - */ - suffix?: string - - /** - * The maximum number of tokens to generate in the completion. The token count of your prompt plus `max_tokens` cannot exceed the model\'s context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096). - */ - max_tokens?: number - - /** - * What [sampling temperature](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277) to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. We generally recommend altering this or `top_p` but not both. - */ - temperature?: number - - /** - * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both. - */ - top_p?: number - - /** - * Include the log probabilities on the `logprobs` most likely tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response. The maximum value for `logprobs` is 5. If you need more than this, please contact us through our [Help center](https://help.openai.com) and describe your use case. - */ - logprobs?: number - - /** - * Echo back the prompt in addition to the completion - */ - echo?: boolean - - /** - * Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence. - */ - stop?: string[] - - /** - * Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model\'s likelihood to talk about new topics. [See more information about frequency and presence penalties.](/docs/api-reference/parameter-details) - */ - presence_penalty?: number - - /** - * Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model\'s likelihood to repeat the same line verbatim. [See more information about frequency and presence penalties.](/docs/api-reference/parameter-details) - */ - frequency_penalty?: number - - /** - * Generates `best_of` completions server-side and returns the \"best\" (the one with the highest log probability per token). Results cannot be streamed. When used with `n`, `best_of` controls the number of candidate completions and `n` specifies how many to return – `best_of` must be greater than `n`. **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`. - */ - best_of?: number - - /** - * Modify the likelihood of specified tokens appearing in the completion. Accepts a json object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this [tokenizer tool](/tokenizer?view=bpe) (which works for both GPT-2 and GPT-3) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. As an example, you can pass `{\"50256\": -100}` to prevent the <|endoftext|> token from being generated. - */ - logit_bias?: Record - - /** - * A unique identifier representing your end-user, which will help OpenAI to monitor and detect abuse. [Learn more](/docs/usage-policies/end-user-ids). - */ - user?: string - - /* NOTE: this is handled by the `sendMessage` function. - * - * Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. - */ - // stream?: boolean | null - - /** - * NOT SUPPORTED - */ - /** - * How many completions to generate for each prompt. **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`. - */ - // 'n'?: number | null; - } - - export type ReverseProxyCompletionParams = CompletionParams & { - paid?: boolean - } - - export type CompletionResponse = { - id: string - object: string - created: number - model: string - choices: CompletionResponseChoices - usage?: CompletionResponseUsage - } - - export type CompletionResponseChoices = { - text?: string - index?: number - logprobs?: { - tokens?: Array - token_logprobs?: Array - top_logprobs?: Array - text_offset?: Array - } | null - finish_reason?: string - }[] - - export type CompletionResponseUsage = { - prompt_tokens: number - completion_tokens: number - total_tokens: number - } -} - /** * https://chat.openapi.com/backend-api/conversation */ @@ -260,12 +144,19 @@ export type MessageContent = { export type MessageMetadata = any -export type GetAccessTokenFn = ({ - email, - password, - sessionToken -}: { - email: string - password: string - sessionToken?: string -}) => string | Promise +export interface CreateChatCompletionDeltaResponse { + id: string + object: 'chat.completion.chunk' + created: number + model: string + choices: [ + { + delta: { + role: Role + content?: string + } + index: number + finish_reason: string | null + } + ] +}