From ddf5167885c34bbac43af993b90773b2c357e6a9 Mon Sep 17 00:00:00 2001 From: Shinya Nishihara Date: Mon, 25 Dec 2023 16:25:25 +0900 Subject: [PATCH 1/5] fix: azure --- .github/workflows/openai-review.yml | 8 +- package-lock.json | 1253 ++++++++++++++++++++++++--- package.json | 1 + src/bot.ts | 110 ++- src/main.ts | 1 - src/options.ts | 4 - src/review-comment.ts | 2 +- src/review.ts | 27 +- 8 files changed, 1185 insertions(+), 221 deletions(-) diff --git a/.github/workflows/openai-review.yml b/.github/workflows/openai-review.yml index c35e3659..d16fcbdc 100644 --- a/.github/workflows/openai-review.yml +++ b/.github/workflows/openai-review.yml @@ -5,7 +5,7 @@ permissions: pull-requests: write on: - pull_request_target: + pull_request: types: [opened, synchronize, reopened] pull_request_review_comment: types: [created] @@ -19,6 +19,7 @@ concurrency: jobs: review: + if: github.actor != 'dependabot[bot]' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -29,7 +30,10 @@ jobs: - uses: ./ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + AZURE_OPENAI_API_KEY: ${{ Secrets.AZURE_OPENAI_API_KEY }} + AZURE_OPENAI_API_INSTANCE_NAME: ${{ Secrets.AZURE_OPENAI_API_INSTANCE_NAME }} + AZURE_OPENAI_API_DEPLOYMENT_NAME: ${{ Secrets.AZURE_OPENAI_API_DEPLOYMENT_NAME }} + AZURE_OPENAI_API_VERSION: '2023-12-01-preview' with: debug: true review_comment_lgtm: false diff --git a/package-lock.json b/package-lock.json index 1bccefde..48cf53fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "@octokit/action": "^6.0.4", "@octokit/plugin-retry": "^4.1.3", "@octokit/plugin-throttling": "^6.1.0", + "langchain": "^0.0.195", "minimatch": "^9.0.1", "node-fetch": "^3.3.1", "p-limit": "^4.0.0", @@ -198,6 +199,68 @@ "node": ">=6.0.0" } }, + "node_modules/@anthropic-ai/sdk": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.9.1.tgz", + "integrity": "sha512-wa1meQ2WSfoY8Uor3EdrJq0jTiZJoKoSii2ZVWRY1oN4Tlr5s59pADg9T79FTbPe1/se5c3pBeZgJL63wmuoBA==", + "dependencies": { + "@types/node": "^18.11.18", + "@types/node-fetch": "^2.6.4", + "abort-controller": "^3.0.0", + "agentkeepalive": "^4.2.1", + "digest-fetch": "^1.3.0", + "form-data-encoder": "1.7.2", + "formdata-node": "^4.3.2", + "node-fetch": "^2.6.7", + "web-streams-polyfill": "^3.2.1" + } + }, + "node_modules/@anthropic-ai/sdk/node_modules/@types/node": { + "version": "18.19.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.3.tgz", + "integrity": "sha512-k5fggr14DwAytoA/t8rPrIz++lXK7/DqckthCmoZOKNsEbJkId4Z//BqgApXBUGrGddrigYa1oqheo/7YmW4rg==", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@anthropic-ai/sdk/node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/@anthropic-ai/sdk/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/@anthropic-ai/sdk/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/@anthropic-ai/sdk/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/@babel/code-frame": { "version": "7.18.6", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", @@ -2136,7 +2199,7 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", - "dev": true, + "devOptional": true, "engines": { "node": ">= 6" } @@ -2230,8 +2293,29 @@ "node_modules/@types/node": { "version": "20.4.2", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.2.tgz", - "integrity": "sha512-Dd0BYtWgnWJKwO1jkmTrzofjK2QXXcai0dmtzvIBhcA+RsG5h8R3xlyta0kGOZRNfL9GuRtb1knmPEhQrePCEw==", - "dev": true + "integrity": "sha512-Dd0BYtWgnWJKwO1jkmTrzofjK2QXXcai0dmtzvIBhcA+RsG5h8R3xlyta0kGOZRNfL9GuRtb1knmPEhQrePCEw==" + }, + "node_modules/@types/node-fetch": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.9.tgz", + "integrity": "sha512-bQVlnMLFJ2d35DkPNjEPmd9ueO/rh5EiaZt2bhqiSarPjZIuIV6bPQVqcrEyvNo+AfTrRGVazle1tl597w3gfA==", + "dependencies": { + "@types/node": "*", + "form-data": "^4.0.0" + } + }, + "node_modules/@types/node-fetch/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } }, "node_modules/@types/normalize-package-data": { "version": "2.4.1", @@ -2262,6 +2346,11 @@ "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", "dev": true }, + "node_modules/@types/uuid": { + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.7.tgz", + "integrity": "sha512-WUtIVRUZ9i5dYXefDEAI7sh9/O7jGvHg7Df/5O/gtH3Yabe5odI3UWopVR1qbPXQtvOxWu3mM4XxlYeZtMWF4g==" + }, "node_modules/@types/yargs": { "version": "17.0.23", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.23.tgz", @@ -2500,13 +2589,24 @@ "version": "2.0.6", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz", "integrity": "sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==", - "dev": true + "devOptional": true + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } }, "node_modules/acorn": { "version": "8.8.2", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", - "dev": true, + "devOptional": true, "bin": { "acorn": "bin/acorn" }, @@ -2518,7 +2618,7 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-6.0.0.tgz", "integrity": "sha512-ZQl7LOWaF5ePqqcX4hLuv/bLXYQNfNWw2c0/yX/TsPRKamzHcTGQnlCjHT3TsmkOUVEPS3crCxiPfdzE/Trlhg==", - "dev": true, + "devOptional": true, "dependencies": { "acorn": "^7.1.1", "acorn-walk": "^7.1.1" @@ -2528,7 +2628,7 @@ "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", - "dev": true, + "devOptional": true, "bin": { "acorn": "bin/acorn" }, @@ -2549,7 +2649,7 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==", - "dev": true, + "devOptional": true, "engines": { "node": ">=0.4.0" } @@ -2558,7 +2658,7 @@ "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "dev": true, + "devOptional": true, "dependencies": { "debug": "4" }, @@ -2566,6 +2666,17 @@ "node": ">= 6.0.0" } }, + "node_modules/agentkeepalive": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", + "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", + "dependencies": { + "humanize-ms": "^1.2.1" + }, + "engines": { + "node": ">= 8.0.0" + } + }, "node_modules/ajv": { "version": "8.12.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", @@ -2666,8 +2777,7 @@ "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" }, "node_modules/aria-query": { "version": "5.1.3", @@ -2764,8 +2874,7 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "dev": true + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/atomically": { "version": "2.0.1", @@ -2929,11 +3038,15 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, + "node_modules/base-64": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz", + "integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==" + }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "dev": true, "funding": [ { "type": "github", @@ -2954,6 +3067,19 @@ "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==" }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/binary-search": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/binary-search/-/binary-search-1.3.6.tgz", + "integrity": "sha512-nbE1WxOTTrUWIfsfZ4aHGYu5DOuNkbxGokjV6Z2kxfJK3uaAb8zNK1muzOeipoLHZjInT4Br88BHpzevc681xA==" + }, "node_modules/bottleneck": { "version": "2.19.5", "resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz", @@ -2983,7 +3109,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz", "integrity": "sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==", - "dev": true + "devOptional": true }, "node_modules/browserslist": { "version": "4.21.5", @@ -3130,6 +3256,14 @@ "node": ">=10" } }, + "node_modules/charenc": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", + "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==", + "engines": { + "node": "*" + } + }, "node_modules/chatgpt": { "version": "5.2.5", "resolved": "https://registry.npmjs.org/chatgpt/-/chatgpt-5.2.5.tgz", @@ -3232,7 +3366,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, "dependencies": { "delayed-stream": "~1.0.0" }, @@ -3240,6 +3373,14 @@ "node": ">= 0.8" } }, + "node_modules/commander": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", + "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", + "engines": { + "node": ">=14" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -3288,17 +3429,25 @@ "node": ">= 8" } }, + "node_modules/crypt": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", + "integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==", + "engines": { + "node": "*" + } + }, "node_modules/cssom": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz", "integrity": "sha512-p3pvU7r1MyyqbTk+WbNJIgJjG2VmTIaB10rI93LzVPrmDJKkzKYMtxxyAvQXR/NS6otuzveI7+7BBq3SjBS2mw==", - "dev": true + "devOptional": true }, "node_modules/cssstyle": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-2.3.0.tgz", "integrity": "sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A==", - "dev": true, + "devOptional": true, "dependencies": { "cssom": "~0.3.6" }, @@ -3310,7 +3459,7 @@ "version": "0.3.8", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.8.tgz", "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==", - "dev": true + "devOptional": true }, "node_modules/damerau-levenshtein": { "version": "1.0.8", @@ -3330,7 +3479,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-2.0.0.tgz", "integrity": "sha512-X5eWTSXO/BJmpdIKCRuKUgSCgAN0OwliVK3yPKbwIWU1Tdw5BRajxlzMidvh+gwko9AfQ9zIj52pzF91Q3YAvQ==", - "dev": true, + "devOptional": true, "dependencies": { "abab": "^2.0.3", "whatwg-mimetype": "^2.3.0", @@ -3371,11 +3520,19 @@ } } }, + "node_modules/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/decimal.js": { "version": "10.4.3", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==", - "dev": true + "devOptional": true }, "node_modules/dedent": { "version": "0.7.0", @@ -3415,7 +3572,7 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", - "dev": true + "devOptional": true }, "node_modules/deepmerge": { "version": "4.3.1", @@ -3446,7 +3603,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "dev": true, "engines": { "node": ">=0.4.0" } @@ -3474,6 +3630,15 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/digest-fetch": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/digest-fetch/-/digest-fetch-1.3.0.tgz", + "integrity": "sha512-CGJuv6iKNM7QyZlM2T3sPAdZWd/p9zQiRNS9G+9COUCwzWFTs0Xp8NF5iePx7wtvhDykReiRRrSeNb4oMmB8lA==", + "dependencies": { + "base-64": "^0.1.0", + "md5": "^2.3.0" + } + }, "node_modules/dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -3502,7 +3667,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/domexception/-/domexception-2.0.1.tgz", "integrity": "sha512-yxJ2mFy/sibVQlu5qHjOkf9J3K6zgmCxgJ94u2EdvDOV09H+32LtRswEcUsmUWN72pVLOEnTSRaIVVzVQgS0dg==", - "dev": true, + "devOptional": true, "dependencies": { "webidl-conversions": "^5.0.0" }, @@ -3514,7 +3679,7 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-5.0.0.tgz", "integrity": "sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==", - "dev": true, + "devOptional": true, "engines": { "node": ">=8" } @@ -3712,7 +3877,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.0.0.tgz", "integrity": "sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw==", - "dev": true, + "devOptional": true, "dependencies": { "esprima": "^4.0.1", "estraverse": "^5.2.0", @@ -3734,7 +3899,7 @@ "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", "integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==", - "dev": true, + "devOptional": true, "dependencies": { "prelude-ls": "~1.1.2", "type-check": "~0.3.2" @@ -3747,7 +3912,7 @@ "version": "0.8.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "dev": true, + "devOptional": true, "dependencies": { "deep-is": "~0.1.3", "fast-levenshtein": "~2.0.6", @@ -3764,7 +3929,7 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==", - "dev": true, + "devOptional": true, "engines": { "node": ">= 0.8.0" } @@ -3773,7 +3938,7 @@ "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", "integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==", - "dev": true, + "devOptional": true, "dependencies": { "prelude-ls": "~1.1.2" }, @@ -4461,7 +4626,7 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true, + "devOptional": true, "bin": { "esparse": "bin/esparse.js", "esvalidate": "bin/esvalidate.js" @@ -4498,7 +4663,7 @@ "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true, + "devOptional": true, "engines": { "node": ">=4.0" } @@ -4507,11 +4672,24 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true, + "devOptional": true, "engines": { "node": ">=0.10.0" } }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "engines": { + "node": ">=6" + } + }, + "node_modules/eventemitter3": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", + "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==" + }, "node_modules/eventsource-parser": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-1.0.0.tgz", @@ -4569,6 +4747,11 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/expr-eval": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/expr-eval/-/expr-eval-2.0.2.tgz", + "integrity": "sha512-4EMSHGOPSwAfBiibw3ndnP0AvjDWLsMvGOvWEZ2F96IGk0bIVdjQisOHxReSkE13mHcfbuCiXw+G4y0zv6N8Eg==" + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -4619,7 +4802,7 @@ "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", - "dev": true + "devOptional": true }, "node_modules/fastq": { "version": "1.15.0", @@ -4701,6 +4884,14 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "bin": { + "flat": "cli.js" + } + }, "node_modules/flat-cache": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", @@ -4733,7 +4924,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", - "dev": true, + "devOptional": true, "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -4743,6 +4934,31 @@ "node": ">= 6" } }, + "node_modules/form-data-encoder": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz", + "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==" + }, + "node_modules/formdata-node": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz", + "integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==", + "dependencies": { + "node-domexception": "1.0.0", + "web-streams-polyfill": "4.0.0-beta.3" + }, + "engines": { + "node": ">= 12.20" + } + }, + "node_modules/formdata-node/node_modules/web-streams-polyfill": { + "version": "4.0.0-beta.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz", + "integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==", + "engines": { + "node": ">= 14" + } + }, "node_modules/formdata-polyfill": { "version": "4.0.10", "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", @@ -5131,7 +5347,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz", "integrity": "sha512-D5JbOMBIR/TVZkubHT+OyT2705QvogUW4IBn6nHd756OwieSF9aDYFj4dv6HHEVGYbHaLETa3WggZYWWMyy3ZQ==", - "dev": true, + "devOptional": true, "dependencies": { "whatwg-encoding": "^1.0.5" }, @@ -5149,7 +5365,7 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", - "dev": true, + "devOptional": true, "dependencies": { "@tootallnate/once": "1", "agent-base": "6", @@ -5163,7 +5379,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", - "dev": true, + "devOptional": true, "dependencies": { "agent-base": "6", "debug": "4" @@ -5181,11 +5397,19 @@ "node": ">=10.17.0" } }, + "node_modules/humanize-ms": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", + "dependencies": { + "ms": "^2.0.0" + } + }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dev": true, + "devOptional": true, "dependencies": { "safer-buffer": ">= 2.1.2 < 3" }, @@ -5197,7 +5421,7 @@ "version": "5.2.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", - "dev": true, + "devOptional": true, "engines": { "node": ">= 4" } @@ -5276,6 +5500,11 @@ "node": ">= 0.4" } }, + "node_modules/is-any-array": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-any-array/-/is-any-array-2.0.1.tgz", + "integrity": "sha512-UtilS7hLRu++wb/WBAw9bNuP1Eg04Ivn1vERJck8zJthEvXCBEBpGR/33u/xLKWEQf95803oalHrVDptcAvFdQ==" + }, "node_modules/is-arguments": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", @@ -5340,6 +5569,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + }, "node_modules/is-callable": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", @@ -5484,7 +5718,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", - "dev": true + "devOptional": true }, "node_modules/is-regex": { "version": "1.1.4", @@ -8115,7 +8349,6 @@ "version": "1.0.7", "resolved": "https://registry.npmjs.org/js-tiktoken/-/js-tiktoken-1.0.7.tgz", "integrity": "sha512-biba8u/clw7iesNEWLOLwrNGoBP2lA+hTaBLs/D45pJdUPFXyxD6nhcDVtADChghv4GgyAiMKYMiRx7x6h7Biw==", - "dev": true, "dependencies": { "base64-js": "^1.5.1" } @@ -8130,7 +8363,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, "dependencies": { "argparse": "^2.0.1" }, @@ -8142,7 +8374,7 @@ "version": "16.7.0", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.7.0.tgz", "integrity": "sha512-u9Smc2G1USStM+s/x1ru5Sxrl6mPYCbByG1U/hUmqaVsm4tbNyS7CicOSRyuGQYZhTu0h84qkZZQ/I+dzizSVw==", - "dev": true, + "devOptional": true, "dependencies": { "abab": "^2.0.5", "acorn": "^8.2.4", @@ -8184,6 +8416,27 @@ } } }, + "node_modules/jsdom/node_modules/ws": { + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "devOptional": true, + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", @@ -8238,6 +8491,14 @@ "node": ">=6" } }, + "node_modules/jsonpointer": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-5.0.1.tgz", + "integrity": "sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/jsx-ast-utils": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.3.tgz", @@ -8269,71 +8530,598 @@ "node": ">=6" } }, - "node_modules/language-subtag-registry": { - "version": "0.3.22", - "resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.22.tgz", - "integrity": "sha512-tN0MCzyWnoz/4nHS6uxdlFWoUZT7ABptwKPQ52Ea7URk6vll88bWBVhodtnlfEuCcKWNGoc+uGbw1cwa9IKh/w==", - "dev": true - }, - "node_modules/language-tags": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/language-tags/-/language-tags-1.0.5.tgz", - "integrity": "sha512-qJhlO9cGXi6hBGKoxEG/sKZDAHD5Hnu9Hs4WbOY3pCWXDhw0N8x1NenNzm2EnNLkLkk7J2SdxAkDSbb6ftT+UQ==", - "dev": true, - "dependencies": { - "language-subtag-registry": "~0.3.2" - } - }, - "node_modules/leven": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", - "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/levn": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", - "dev": true, - "dependencies": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/lines-and-columns": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", - "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", - "dev": true - }, - "node_modules/locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, + "node_modules/langchain": { + "version": "0.0.195", + "resolved": "https://registry.npmjs.org/langchain/-/langchain-0.0.195.tgz", + "integrity": "sha512-b3TOfhSUwxe2ZCr4yYlR5dciyy0qyqrDeqAfVFJKM0H7/ueFHFllr4uJydsbzC5+ahlqDFRbzUEK005sbHgdSQ==", "dependencies": { - "p-locate": "^5.0.0" + "@anthropic-ai/sdk": "^0.9.1", + "ansi-styles": "^5.0.0", + "binary-extensions": "^2.2.0", + "camelcase": "6", + "decamelize": "^1.2.0", + "expr-eval": "^2.0.2", + "flat": "^5.0.2", + "js-tiktoken": "^1.0.7", + "js-yaml": "^4.1.0", + "jsonpointer": "^5.0.1", + "langchainhub": "~0.0.6", + "langsmith": "~0.0.48", + "ml-distance": "^4.0.0", + "openai": "^4.19.0", + "openapi-types": "^12.1.3", + "p-queue": "^6.6.2", + "p-retry": "4", + "uuid": "^9.0.0", + "yaml": "^2.2.1", + "zod": "^3.22.3", + "zod-to-json-schema": "3.20.3" + }, + "engines": { + "node": ">=18" }, - "engines": { - "node": ">=10" + "peerDependencies": { + "@aws-crypto/sha256-js": "^5.0.0", + "@aws-sdk/client-bedrock-runtime": "^3.422.0", + "@aws-sdk/client-dynamodb": "^3.310.0", + "@aws-sdk/client-kendra": "^3.352.0", + "@aws-sdk/client-lambda": "^3.310.0", + "@aws-sdk/client-s3": "^3.310.0", + "@aws-sdk/client-sagemaker-runtime": "^3.310.0", + "@aws-sdk/client-sfn": "^3.310.0", + "@aws-sdk/credential-provider-node": "^3.388.0", + "@azure/storage-blob": "^12.15.0", + "@clickhouse/client": "^0.0.14", + "@cloudflare/ai": "^1.0.12", + "@elastic/elasticsearch": "^8.4.0", + "@getmetal/metal-sdk": "*", + "@getzep/zep-js": "^0.9.0", + "@gomomento/sdk": "^1.47.1", + "@gomomento/sdk-core": "^1.47.1", + "@gomomento/sdk-web": "^1.47.1", + "@google-ai/generativelanguage": "^0.2.1", + "@google-cloud/storage": "^6.10.1", + "@huggingface/inference": "^2.6.4", + "@mozilla/readability": "*", + "@notionhq/client": "^2.2.10", + "@opensearch-project/opensearch": "*", + "@pinecone-database/pinecone": "^1.1.0", + "@planetscale/database": "^1.8.0", + "@qdrant/js-client-rest": "^1.2.0", + "@raycast/api": "^1.55.2", + "@rockset/client": "^0.9.1", + "@smithy/eventstream-codec": "^2.0.5", + "@smithy/protocol-http": "^3.0.6", + "@smithy/signature-v4": "^2.0.10", + "@smithy/util-utf8": "^2.0.0", + "@supabase/postgrest-js": "^1.1.1", + "@supabase/supabase-js": "^2.10.0", + "@tensorflow-models/universal-sentence-encoder": "*", + "@tensorflow/tfjs-converter": "*", + "@tensorflow/tfjs-core": "*", + "@upstash/redis": "^1.20.6", + "@vercel/kv": "^0.2.3", + "@vercel/postgres": "^0.5.0", + "@writerai/writer-sdk": "^0.40.2", + "@xata.io/client": "^0.25.1", + "@xenova/transformers": "^2.5.4", + "@zilliz/milvus2-sdk-node": ">=2.2.7", + "apify-client": "^2.7.1", + "assemblyai": "^2.0.2", + "axios": "*", + "cassandra-driver": "^4.7.2", + "cheerio": "^1.0.0-rc.12", + "chromadb": "*", + "closevector-common": "0.1.0-alpha.1", + "closevector-node": "0.1.0-alpha.10", + "closevector-web": "0.1.0-alpha.16", + "cohere-ai": ">=6.0.0", + "convex": "^1.3.1", + "d3-dsv": "^2.0.0", + "epub2": "^3.0.1", + "faiss-node": "^0.5.1", + "fast-xml-parser": "^4.2.7", + "firebase-admin": "^11.9.0", + "google-auth-library": "^8.9.0", + "googleapis": "^126.0.1", + "hnswlib-node": "^1.4.2", + "html-to-text": "^9.0.5", + "ignore": "^5.2.0", + "ioredis": "^5.3.2", + "jsdom": "*", + "llmonitor": "^0.5.9", + "lodash": "^4.17.21", + "mammoth": "*", + "mongodb": "^5.2.0", + "mysql2": "^3.3.3", + "neo4j-driver": "*", + "node-llama-cpp": "*", + "notion-to-md": "^3.1.0", + "pdf-parse": "1.1.1", + "peggy": "^3.0.2", + "pg": "^8.11.0", + "pg-copy-streams": "^6.0.5", + "pickleparser": "^0.2.1", + "playwright": "^1.32.1", + "portkey-ai": "^0.1.11", + "puppeteer": "^19.7.2", + "redis": "^4.6.4", + "replicate": "^0.18.0", + "sonix-speech-recognition": "^2.1.1", + "srt-parser-2": "^1.2.2", + "typeorm": "^0.3.12", + "typesense": "^1.5.3", + "usearch": "^1.1.1", + "vectordb": "^0.1.4", + "voy-search": "0.6.2", + "weaviate-ts-client": "^1.4.0", + "web-auth-library": "^1.0.3", + "ws": "^8.14.2", + "youtube-transcript": "^1.0.6", + "youtubei.js": "^5.8.0" }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, - "node_modules/lodash.camelcase": { + "peerDependenciesMeta": { + "@aws-crypto/sha256-js": { + "optional": true + }, + "@aws-sdk/client-bedrock-runtime": { + "optional": true + }, + "@aws-sdk/client-dynamodb": { + "optional": true + }, + "@aws-sdk/client-kendra": { + "optional": true + }, + "@aws-sdk/client-lambda": { + "optional": true + }, + "@aws-sdk/client-s3": { + "optional": true + }, + "@aws-sdk/client-sagemaker-runtime": { + "optional": true + }, + "@aws-sdk/client-sfn": { + "optional": true + }, + "@aws-sdk/credential-provider-node": { + "optional": true + }, + "@azure/storage-blob": { + "optional": true + }, + "@clickhouse/client": { + "optional": true + }, + "@cloudflare/ai": { + "optional": true + }, + "@elastic/elasticsearch": { + "optional": true + }, + "@getmetal/metal-sdk": { + "optional": true + }, + "@getzep/zep-js": { + "optional": true + }, + "@gomomento/sdk": { + "optional": true + }, + "@gomomento/sdk-core": { + "optional": true + }, + "@gomomento/sdk-web": { + "optional": true + }, + "@google-ai/generativelanguage": { + "optional": true + }, + "@google-cloud/storage": { + "optional": true + }, + "@huggingface/inference": { + "optional": true + }, + "@mozilla/readability": { + "optional": true + }, + "@notionhq/client": { + "optional": true + }, + "@opensearch-project/opensearch": { + "optional": true + }, + "@pinecone-database/pinecone": { + "optional": true + }, + "@planetscale/database": { + "optional": true + }, + "@qdrant/js-client-rest": { + "optional": true + }, + "@raycast/api": { + "optional": true + }, + "@rockset/client": { + "optional": true + }, + "@smithy/eventstream-codec": { + "optional": true + }, + "@smithy/protocol-http": { + "optional": true + }, + "@smithy/signature-v4": { + "optional": true + }, + "@smithy/util-utf8": { + "optional": true + }, + "@supabase/postgrest-js": { + "optional": true + }, + "@supabase/supabase-js": { + "optional": true + }, + "@tensorflow-models/universal-sentence-encoder": { + "optional": true + }, + "@tensorflow/tfjs-converter": { + "optional": true + }, + "@tensorflow/tfjs-core": { + "optional": true + }, + "@upstash/redis": { + "optional": true + }, + "@vercel/kv": { + "optional": true + }, + "@vercel/postgres": { + "optional": true + }, + "@writerai/writer-sdk": { + "optional": true + }, + "@xata.io/client": { + "optional": true + }, + "@xenova/transformers": { + "optional": true + }, + "@zilliz/milvus2-sdk-node": { + "optional": true + }, + "apify-client": { + "optional": true + }, + "assemblyai": { + "optional": true + }, + "axios": { + "optional": true + }, + "cassandra-driver": { + "optional": true + }, + "cheerio": { + "optional": true + }, + "chromadb": { + "optional": true + }, + "closevector-common": { + "optional": true + }, + "closevector-node": { + "optional": true + }, + "closevector-web": { + "optional": true + }, + "cohere-ai": { + "optional": true + }, + "convex": { + "optional": true + }, + "d3-dsv": { + "optional": true + }, + "epub2": { + "optional": true + }, + "faiss-node": { + "optional": true + }, + "fast-xml-parser": { + "optional": true + }, + "firebase-admin": { + "optional": true + }, + "google-auth-library": { + "optional": true + }, + "googleapis": { + "optional": true + }, + "hnswlib-node": { + "optional": true + }, + "html-to-text": { + "optional": true + }, + "ignore": { + "optional": true + }, + "ioredis": { + "optional": true + }, + "jsdom": { + "optional": true + }, + "llmonitor": { + "optional": true + }, + "lodash": { + "optional": true + }, + "mammoth": { + "optional": true + }, + "mongodb": { + "optional": true + }, + "mysql2": { + "optional": true + }, + "neo4j-driver": { + "optional": true + }, + "node-llama-cpp": { + "optional": true + }, + "notion-to-md": { + "optional": true + }, + "pdf-parse": { + "optional": true + }, + "peggy": { + "optional": true + }, + "pg": { + "optional": true + }, + "pg-copy-streams": { + "optional": true + }, + "pickleparser": { + "optional": true + }, + "playwright": { + "optional": true + }, + "portkey-ai": { + "optional": true + }, + "puppeteer": { + "optional": true + }, + "redis": { + "optional": true + }, + "replicate": { + "optional": true + }, + "sonix-speech-recognition": { + "optional": true + }, + "srt-parser-2": { + "optional": true + }, + "typeorm": { + "optional": true + }, + "typesense": { + "optional": true + }, + "usearch": { + "optional": true + }, + "vectordb": { + "optional": true + }, + "voy-search": { + "optional": true + }, + "weaviate-ts-client": { + "optional": true + }, + "web-auth-library": { + "optional": true + }, + "ws": { + "optional": true + }, + "youtube-transcript": { + "optional": true + }, + "youtubei.js": { + "optional": true + } + } + }, + "node_modules/langchain/node_modules/@types/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==" + }, + "node_modules/langchain/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/langchain/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/langchain/node_modules/p-retry": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-4.6.2.tgz", + "integrity": "sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ==", + "dependencies": { + "@types/retry": "0.12.0", + "retry": "^0.13.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/langchain/node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/langchainhub": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/langchainhub/-/langchainhub-0.0.6.tgz", + "integrity": "sha512-SW6105T+YP1cTe0yMf//7kyshCgvCTyFBMTgH2H3s9rTAR4e+78DA/BBrUL/Mt4Q5eMWui7iGuAYb3pgGsdQ9w==" + }, + "node_modules/langsmith": { + "version": "0.0.53", + "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.0.53.tgz", + "integrity": "sha512-w2Rgx4ixE+wuItFVKGnc+Wmzj91RevMd7sev9BHWC8VFztDPuyrNZQD55QpxphM6JLb9hF9osxvAiYDGtDZbuQ==", + "dependencies": { + "@types/uuid": "^9.0.1", + "commander": "^10.0.1", + "p-queue": "^6.6.2", + "p-retry": "4", + "uuid": "^9.0.0" + }, + "bin": { + "langsmith": "dist/cli/main.cjs" + } + }, + "node_modules/langsmith/node_modules/@types/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==" + }, + "node_modules/langsmith/node_modules/p-retry": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-4.6.2.tgz", + "integrity": "sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ==", + "dependencies": { + "@types/retry": "0.12.0", + "retry": "^0.13.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/langsmith/node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/language-subtag-registry": { + "version": "0.3.22", + "resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.22.tgz", + "integrity": "sha512-tN0MCzyWnoz/4nHS6uxdlFWoUZT7ABptwKPQ52Ea7URk6vll88bWBVhodtnlfEuCcKWNGoc+uGbw1cwa9IKh/w==", + "dev": true + }, + "node_modules/language-tags": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/language-tags/-/language-tags-1.0.5.tgz", + "integrity": "sha512-qJhlO9cGXi6hBGKoxEG/sKZDAHD5Hnu9Hs4WbOY3pCWXDhw0N8x1NenNzm2EnNLkLkk7J2SdxAkDSbb6ftT+UQ==", + "dev": true, + "dependencies": { + "language-subtag-registry": "~0.3.2" + } + }, + "node_modules/leven": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "devOptional": true + }, + "node_modules/lodash.camelcase": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", "integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==", @@ -8417,6 +9205,16 @@ "tmpl": "1.0.5" } }, + "node_modules/md5": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", + "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", + "dependencies": { + "charenc": "0.0.2", + "crypt": "0.0.2", + "is-buffer": "~1.1.6" + } + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -8449,7 +9247,6 @@ "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "dev": true, "engines": { "node": ">= 0.6" } @@ -8458,7 +9255,6 @@ "version": "2.1.35", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dev": true, "dependencies": { "mime-db": "1.52.0" }, @@ -8501,6 +9297,46 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/ml-array-mean": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/ml-array-mean/-/ml-array-mean-1.1.6.tgz", + "integrity": "sha512-MIdf7Zc8HznwIisyiJGRH9tRigg3Yf4FldW8DxKxpCCv/g5CafTw0RRu51nojVEOXuCQC7DRVVu5c7XXO/5joQ==", + "dependencies": { + "ml-array-sum": "^1.1.6" + } + }, + "node_modules/ml-array-sum": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/ml-array-sum/-/ml-array-sum-1.1.6.tgz", + "integrity": "sha512-29mAh2GwH7ZmiRnup4UyibQZB9+ZLyMShvt4cH4eTK+cL2oEMIZFnSyB3SS8MlsTh6q/w/yh48KmqLxmovN4Dw==", + "dependencies": { + "is-any-array": "^2.0.0" + } + }, + "node_modules/ml-distance": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/ml-distance/-/ml-distance-4.0.1.tgz", + "integrity": "sha512-feZ5ziXs01zhyFUUUeZV5hwc0f5JW0Sh0ckU1koZe/wdVkJdGxcP06KNQuF0WBTj8FttQUzcvQcpcrOp/XrlEw==", + "dependencies": { + "ml-array-mean": "^1.1.6", + "ml-distance-euclidean": "^2.0.0", + "ml-tree-similarity": "^1.0.0" + } + }, + "node_modules/ml-distance-euclidean": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ml-distance-euclidean/-/ml-distance-euclidean-2.0.0.tgz", + "integrity": "sha512-yC9/2o8QF0A3m/0IXqCTXCzz2pNEzvmcE/9HFKOZGnTjatvBbsn4lWYJkxENkA4Ug2fnYl7PXQxnPi21sgMy/Q==" + }, + "node_modules/ml-tree-similarity": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/ml-tree-similarity/-/ml-tree-similarity-1.0.0.tgz", + "integrity": "sha512-XJUyYqjSuUQkNQHMscr6tcjldsOoAekxADTplt40QKfwW6nd++1wHWV9AArl0Zvw/TIHgNaZZNvr8QGvE8wLRg==", + "dependencies": { + "binary-search": "^1.3.5", + "num-sort": "^2.0.0" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -8601,11 +9437,22 @@ "node": ">=8" } }, + "node_modules/num-sort": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/num-sort/-/num-sort-2.1.0.tgz", + "integrity": "sha512-1MQz1Ed8z2yckoBeSfkQHHO9K1yDRxxtotKSJ9yvcTUUxSvfvzEq5GwBrjjHEpMlq/k5gvXdmJ1SbYxWtpNoVg==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/nwsapi": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.2.tgz", "integrity": "sha512-90yv+6538zuvUMnN+zCr8LuV6bPFdq50304114vJYJ8RDyK8D5O9Phpbd6SZWgI7PwzmmfN1upeOJlvybDSgCw==", - "dev": true + "devOptional": true }, "node_modules/object-inspect": { "version": "1.12.3", @@ -8739,6 +9586,76 @@ "node": ">=6" } }, + "node_modules/openai": { + "version": "4.24.1", + "resolved": "https://registry.npmjs.org/openai/-/openai-4.24.1.tgz", + "integrity": "sha512-ezm/O3eiZMnyBqirUnWm9N6INJU1WhNtz+nK/Zj/2oyKvRz9pgpViDxa5wYOtyGYXPn1sIKBV0I/S4BDhtydqw==", + "dependencies": { + "@types/node": "^18.11.18", + "@types/node-fetch": "^2.6.4", + "abort-controller": "^3.0.0", + "agentkeepalive": "^4.2.1", + "digest-fetch": "^1.3.0", + "form-data-encoder": "1.7.2", + "formdata-node": "^4.3.2", + "node-fetch": "^2.6.7", + "web-streams-polyfill": "^3.2.1" + }, + "bin": { + "openai": "bin/cli" + } + }, + "node_modules/openai/node_modules/@types/node": { + "version": "18.19.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.3.tgz", + "integrity": "sha512-k5fggr14DwAytoA/t8rPrIz++lXK7/DqckthCmoZOKNsEbJkId4Z//BqgApXBUGrGddrigYa1oqheo/7YmW4rg==", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/openai/node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/openai/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/openai/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/openai/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/openapi-types": { + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/openapi-types/-/openapi-types-12.1.3.tgz", + "integrity": "sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw==" + }, "node_modules/optionator": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", @@ -8756,6 +9673,14 @@ "node": ">= 0.8.0" } }, + "node_modules/p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==", + "engines": { + "node": ">=4" + } + }, "node_modules/p-limit": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz", @@ -8812,6 +9737,32 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/p-queue": { + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/p-queue/-/p-queue-6.6.2.tgz", + "integrity": "sha512-RwFpb72c/BhQLEXIZ5K2e+AhgNVmIejGlTgiB9MzZ0e93GRvqZ7uSi0dvRF7/XIXDeNkra2fNHBxTyPDGySpjQ==", + "dependencies": { + "eventemitter3": "^4.0.4", + "p-timeout": "^3.2.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-queue/node_modules/p-timeout": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-3.2.0.tgz", + "integrity": "sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg==", + "dependencies": { + "p-finally": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/p-retry": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-5.1.2.tgz", @@ -8882,7 +9833,7 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==", - "dev": true + "devOptional": true }, "node_modules/path-exists": { "version": "4.0.0", @@ -9096,13 +10047,13 @@ "version": "1.9.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==", - "dev": true + "devOptional": true }, "node_modules/punycode": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", - "dev": true, + "devOptional": true, "engines": { "node": ">=6" } @@ -9111,7 +10062,7 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==", - "dev": true + "devOptional": true }, "node_modules/queue-microtask": { "version": "1.2.3", @@ -9298,7 +10249,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", - "dev": true + "devOptional": true }, "node_modules/resolve": { "version": "1.22.1", @@ -9430,13 +10381,13 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true + "devOptional": true }, "node_modules/saxes": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/saxes/-/saxes-5.0.1.tgz", "integrity": "sha512-5LBh1Tls8c9xgGjw3QrMwETmTMVk0oFgvrFSvWx62llR2hcEInrKNZ2GZCCuuy2lvWrdl5jhbpeqc5hRYKFOcw==", - "dev": true, + "devOptional": true, "dependencies": { "xmlchars": "^2.2.0" }, @@ -9800,7 +10751,7 @@ "version": "3.2.4", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", - "dev": true + "devOptional": true }, "node_modules/terminal-link": { "version": "2.1.1", @@ -9897,7 +10848,7 @@ "version": "4.1.2", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.2.tgz", "integrity": "sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==", - "dev": true, + "devOptional": true, "dependencies": { "psl": "^1.1.33", "punycode": "^2.1.1", @@ -9912,7 +10863,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/tr46/-/tr46-2.1.0.tgz", "integrity": "sha512-15Ih7phfcdP5YxqiB+iDtLoaTz4Nd35+IiAv0kQ5FNKHzXgdWqPoTIqEDDJmXceQt4JZk6lVPT8lnDlPpGDppw==", - "dev": true, + "devOptional": true, "dependencies": { "punycode": "^2.1.1" }, @@ -10151,6 +11102,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + }, "node_modules/universal-user-agent": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", @@ -10160,7 +11116,7 @@ "version": "0.2.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", - "dev": true, + "devOptional": true, "engines": { "node": ">= 4.0.0" } @@ -10204,7 +11160,7 @@ "version": "1.5.10", "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", - "dev": true, + "devOptional": true, "dependencies": { "querystringify": "^2.1.1", "requires-port": "^1.0.0" @@ -10256,7 +11212,7 @@ "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz", "integrity": "sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==", "deprecated": "Use your platform's native performance.now() and performance.timeOrigin.", - "dev": true, + "devOptional": true, "dependencies": { "browser-process-hrtime": "^1.0.0" } @@ -10265,7 +11221,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-2.0.0.tgz", "integrity": "sha512-4tzD0mF8iSiMiNs30BiLO3EpfGLZUT2MSX/G+o7ZywDzliWQ3OPtTZ0PTC3B3ca1UAf4cJMHB+2Bf56EriJuRA==", - "dev": true, + "devOptional": true, "dependencies": { "xml-name-validator": "^3.0.0" }, @@ -10294,7 +11250,7 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-6.1.0.tgz", "integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==", - "dev": true, + "devOptional": true, "engines": { "node": ">=10.4" } @@ -10303,7 +11259,7 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz", "integrity": "sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==", - "dev": true, + "devOptional": true, "dependencies": { "iconv-lite": "0.4.24" } @@ -10312,13 +11268,13 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz", "integrity": "sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==", - "dev": true + "devOptional": true }, "node_modules/whatwg-url": { "version": "8.7.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-8.7.0.tgz", "integrity": "sha512-gAojqb/m9Q8a5IV96E3fHJM70AzCkgt4uXYX2O7EmuyOnLrViCQlsEBmF9UQIu3/aeAIp2U17rtbpZWNntQqdg==", - "dev": true, + "devOptional": true, "dependencies": { "lodash": "^4.7.0", "tr46": "^2.1.0", @@ -10404,7 +11360,7 @@ "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "dev": true, + "devOptional": true, "engines": { "node": ">=0.10.0" } @@ -10444,16 +11400,17 @@ } }, "node_modules/ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", - "dev": true, + "version": "8.15.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.15.1.tgz", + "integrity": "sha512-W5OZiCjXEmk0yZ66ZN82beM5Sz7l7coYxpRkzS+p9PP+ToQry8szKh+61eNktr7EA9DOwvFGhfC605jDHbP6QQ==", + "optional": true, + "peer": true, "engines": { - "node": ">=8.3.0" + "node": ">=10.0.0" }, "peerDependencies": { "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" + "utf-8-validate": ">=5.0.2" }, "peerDependenciesMeta": { "bufferutil": { @@ -10468,13 +11425,13 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==", - "dev": true + "devOptional": true }, "node_modules/xmlchars": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", - "dev": true + "devOptional": true }, "node_modules/y18n": { "version": "5.0.8", @@ -10491,6 +11448,14 @@ "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "dev": true }, + "node_modules/yaml": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.4.tgz", + "integrity": "sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA==", + "engines": { + "node": ">= 14" + } + }, "node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", @@ -10528,6 +11493,22 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/zod": { + "version": "3.22.4", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.22.4.tgz", + "integrity": "sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, + "node_modules/zod-to-json-schema": { + "version": "3.20.3", + "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.20.3.tgz", + "integrity": "sha512-/Q3wnyxAfCt94ZcrGiXXoiAfRqasxl9CX64LZ9fj+4dKH68zulUtU0uk1WMxQPfAxQ0ZI70dKzcoW7hHj+DwSQ==", + "peerDependencies": { + "zod": "^3.20.0" + } } } } diff --git a/package.json b/package.json index abf29881..1a1f0251 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "@octokit/action": "^6.0.4", "@octokit/plugin-retry": "^4.1.3", "@octokit/plugin-throttling": "^6.1.0", + "langchain": "^0.0.195", "minimatch": "^9.0.1", "node-fetch": "^3.3.1", "p-limit": "^4.0.0", diff --git a/src/bot.ts b/src/bot.ts index 4a5a1e4b..3d0a15eb 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -1,14 +1,11 @@ import './fetch-polyfill' import {info, setFailed, warning} from '@actions/core' -import { - ChatGPTAPI, - ChatGPTError, - ChatMessage, - SendMessageOptions - // eslint-disable-next-line import/no-unresolved -} from 'chatgpt' -import pRetry from 'p-retry' +import {ConversationChain} from 'langchain/chains' +import {ChatOpenAI} from 'langchain/chat_models/openai' +import {BufferMemory} from 'langchain/memory' +import {ChatPromptTemplate, MessagesPlaceholder} from 'langchain/prompts' +import {ChainValues} from 'langchain/schema' import {OpenAIOptions, Options} from './options' // define type to save parentMessageId and conversationId @@ -18,83 +15,78 @@ export interface Ids { } export class Bot { - private readonly api: ChatGPTAPI | null = null // not free + private readonly model: ChatOpenAI | null = null + private readonly api: ConversationChain | null = null private readonly options: Options constructor(options: Options, openaiOptions: OpenAIOptions) { this.options = options - if (process.env.OPENAI_API_KEY) { + if ( + process.env.AZURE_OPENAI_API_KEY && + process.env.AZURE_OPENAI_API_VERSION && + process.env.AZURE_OPENAI_API_INSTANCE_NAME && + process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME + ) { const currentDate = new Date().toISOString().split('T')[0] - const systemMessage = `${options.systemMessage} -Knowledge cutoff: ${openaiOptions.tokenLimits.knowledgeCutOff} -Current date: ${currentDate} + const systemMessage = `${options.systemMessage} + Knowledge cutoff: ${openaiOptions.tokenLimits.knowledgeCutOff} + Current date: ${currentDate} + + IMPORTANT: Entire response must be in the language with ISO code: ${options.language} + ` + const chatPrompt = ChatPromptTemplate.fromMessages([ + ['system', systemMessage], + new MessagesPlaceholder('history'), + ['human', '{input}'] + ]) -IMPORTANT: Entire response must be in the language with ISO code: ${options.language} -` - - this.api = new ChatGPTAPI({ - apiBaseUrl: options.apiBaseUrl, - systemMessage, - apiKey: process.env.OPENAI_API_KEY, - apiOrg: process.env.OPENAI_API_ORG ?? undefined, - debug: options.debug, - maxModelTokens: openaiOptions.tokenLimits.maxTokens, - maxResponseTokens: openaiOptions.tokenLimits.responseTokens, - completionParams: { - temperature: options.openaiModelTemperature, - model: openaiOptions.model - } + this.model = new ChatOpenAI({ + temperature: options.openaiModelTemperature, + azureOpenAIApiKey: process.env.AZURE_OPENAI_API_KEY, + azureOpenAIApiVersion: process.env.AZURE_OPENAI_API_VERSION, + azureOpenAIApiInstanceName: process.env.AZURE_OPENAI_API_INSTANCE_NAME, + azureOpenAIApiDeploymentName: + process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME, + timeout: this.options.openaiTimeoutMS, + maxRetries: this.options.openaiRetries + }) + this.api = new ConversationChain({ + memory: new BufferMemory({returnMessages: true, memoryKey: 'history'}), + prompt: chatPrompt, + llm: this.model }) } else { const err = - "Unable to initialize the OpenAI API, both 'OPENAI_API_KEY' environment variable are not available" + "Unable to initialize the OpenAI API, both 'AZURE_OPENAI_API_KEY' environment variable are not available" throw new Error(err) } } - chat = async (message: string, ids: Ids): Promise<[string, Ids]> => { - let res: [string, Ids] = ['', {}] + chat = async (message: string): Promise => { + let res: string = '' try { - res = await this.chat_(message, ids) + res = await this.chat_(message) return res } catch (e: unknown) { - if (e instanceof ChatGPTError) { - warning(`Failed to chat: ${e}, backtrace: ${e.stack}`) - } return res } } - private readonly chat_ = async ( - message: string, - ids: Ids - ): Promise<[string, Ids]> => { + private readonly chat_ = async (message: string): Promise => { // record timing const start = Date.now() if (!message) { - return ['', {}] + return '' } - let response: ChatMessage | undefined + let response: ChainValues | undefined if (this.api != null) { - const opts: SendMessageOptions = { - timeoutMs: this.options.openaiTimeoutMS - } - if (ids.parentMessageId) { - opts.parentMessageId = ids.parentMessageId - } try { - response = await pRetry(() => this.api!.sendMessage(message, opts), { - retries: this.options.openaiRetries - }) + response = await this.api.call({input: message}) } catch (e: unknown) { - if (e instanceof ChatGPTError) { - info( - `response: ${response}, failed to send message to openai: ${e}, backtrace: ${e.stack}` - ) - } + info(`response: ${response}, failed to send message to openai: ${e}`) } const end = Date.now() info(`response: ${JSON.stringify(response)}`) @@ -108,7 +100,7 @@ IMPORTANT: Entire response must be in the language with ISO code: ${options.lang } let responseText = '' if (response != null) { - responseText = response.text + responseText = response.response } else { warning('openai response is null') } @@ -119,10 +111,6 @@ IMPORTANT: Entire response must be in the language with ISO code: ${options.lang if (this.options.debug) { info(`openai responses: ${responseText}`) } - const newIds: Ids = { - parentMessageId: response?.id, - conversationId: response?.conversationId - } - return [responseText, newIds] + return responseText } } diff --git a/src/main.ts b/src/main.ts index 0b716c48..2568cb49 100644 --- a/src/main.ts +++ b/src/main.ts @@ -28,7 +28,6 @@ async function run(): Promise { getInput('openai_timeout_ms'), getInput('openai_concurrency_limit'), getInput('github_concurrency_limit'), - getInput('openai_base_url'), getInput('language') ) diff --git a/src/options.ts b/src/options.ts index 02541975..c53e3bef 100644 --- a/src/options.ts +++ b/src/options.ts @@ -20,7 +20,6 @@ export class Options { githubConcurrencyLimit: number lightTokenLimits: TokenLimits heavyTokenLimits: TokenLimits - apiBaseUrl: string language: string constructor( @@ -39,7 +38,6 @@ export class Options { openaiTimeoutMS = '120000', openaiConcurrencyLimit = '6', githubConcurrencyLimit = '6', - apiBaseUrl = 'https://api.openai.com/v1', language = 'en-US' ) { this.debug = debug @@ -59,7 +57,6 @@ export class Options { this.githubConcurrencyLimit = parseInt(githubConcurrencyLimit) this.lightTokenLimits = new TokenLimits(openaiLightModel) this.heavyTokenLimits = new TokenLimits(openaiHeavyModel) - this.apiBaseUrl = apiBaseUrl this.language = language } @@ -82,7 +79,6 @@ export class Options { info(`github_concurrency_limit: ${this.githubConcurrencyLimit}`) info(`summary_token_limits: ${this.lightTokenLimits.string()}`) info(`review_token_limits: ${this.heavyTokenLimits.string()}`) - info(`api_base_url: ${this.apiBaseUrl}`) info(`language: ${this.language}`) } diff --git a/src/review-comment.ts b/src/review-comment.ts index f42c53db..ad8f9ce6 100644 --- a/src/review-comment.ts +++ b/src/review-comment.ts @@ -172,7 +172,7 @@ export const handleReviewComment = async ( } } - const [reply] = await heavyBot.chat(prompts.renderComment(inputs), {}) + const reply = await heavyBot.chat(prompts.renderComment(inputs)) await commenter.reviewCommentReply(pullNumber, topLevelComment, reply) } diff --git a/src/review.ts b/src/review.ts index 5e7dd9db..4ed6cb86 100644 --- a/src/review.ts +++ b/src/review.ts @@ -337,7 +337,7 @@ ${ // summarize content try { - const [summarizeResp] = await lightBot.chat(summarizePrompt, {}) + const summarizeResp = await lightBot.chat(summarizePrompt) if (summarizeResp === '') { info('summarize: nothing obtained from openai') @@ -400,9 +400,8 @@ ${filename}: ${summary} ` } // ask chatgpt to summarize the summaries - const [summarizeResp] = await heavyBot.chat( - prompts.renderSummarizeChangesets(inputs), - {} + const summarizeResp = await heavyBot.chat( + prompts.renderSummarizeChangesets(inputs) ) if (summarizeResp === '') { warning('summarize: nothing obtained from openai') @@ -413,9 +412,8 @@ ${filename}: ${summary} } // final summary - const [summarizeFinalResponse] = await heavyBot.chat( - prompts.renderSummarize(inputs), - {} + const summarizeFinalResponse = await heavyBot.chat( + prompts.renderSummarize(inputs) ) if (summarizeFinalResponse === '') { info('summarize: nothing obtained from openai') @@ -423,9 +421,8 @@ ${filename}: ${summary} if (options.disableReleaseNotes === false) { // final release notes - const [releaseNotesResponse] = await heavyBot.chat( - prompts.renderSummarizeReleaseNotes(inputs), - {} + const releaseNotesResponse = await heavyBot.chat( + prompts.renderSummarizeReleaseNotes(inputs) ) if (releaseNotesResponse === '') { info('release notes: nothing obtained from openai') @@ -444,9 +441,8 @@ ${filename}: ${summary} } // generate a short summary as well - const [summarizeShortResponse] = await heavyBot.chat( - prompts.renderSummarizeShort(inputs), - {} + const summarizeShortResponse = await heavyBot.chat( + prompts.renderSummarizeShort(inputs) ) inputs.shortSummary = summarizeShortResponse @@ -619,9 +615,8 @@ ${commentChain} if (patchesPacked > 0) { // perform review try { - const [response] = await heavyBot.chat( - prompts.renderReviewFileDiff(ins), - {} + const response = await heavyBot.chat( + prompts.renderReviewFileDiff(ins) ) if (response === '') { info('review: nothing obtained from openai') From 9fe81d8dbd0f0a8df7ee2863a5b52a5373342591 Mon Sep 17 00:00:00 2001 From: Shinya Nishihara Date: Mon, 25 Dec 2023 16:57:16 +0900 Subject: [PATCH 2/5] npm run all --- dist/37.index.js | 4 +- dist/73.index.js | 129 + dist/index.js | 84729 ++++++++++++++++++++++++++++++++------------ dist/licenses.txt | 25 + src/bot.ts | 12 +- src/review.ts | 10 +- 6 files changed, 62049 insertions(+), 22860 deletions(-) create mode 100644 dist/73.index.js diff --git a/dist/37.index.js b/dist/37.index.js index c349ca0a..4e0fd904 100644 --- a/dist/37.index.js +++ b/dist/37.index.js @@ -3,14 +3,14 @@ exports.id = 37; exports.ids = [37]; exports.modules = { -/***/ 4037: +/***/ 6152: /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "toFormData": () => (/* binding */ toFormData) /* harmony export */ }); -/* harmony import */ var fetch_blob_from_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2777); +/* harmony import */ var fetch_blob_from_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7972); /* harmony import */ var formdata_polyfill_esm_min_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8010); diff --git a/dist/73.index.js b/dist/73.index.js new file mode 100644 index 00000000..dd9de4c0 --- /dev/null +++ b/dist/73.index.js @@ -0,0 +1,129 @@ +"use strict"; +exports.id = 73; +exports.ids = [73]; +exports.modules = { + +/***/ 4073: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +// ESM COMPAT FLAG +__webpack_require__.r(__webpack_exports__); + +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "fileFromPath": () => (/* binding */ fileFromPath), + "fileFromPathSync": () => (/* binding */ fileFromPathSync), + "isFile": () => (/* reexport */ isFile/* isFile */.z) +}); + +// EXTERNAL MODULE: external "fs" +var external_fs_ = __webpack_require__(7147); +// EXTERNAL MODULE: external "path" +var external_path_ = __webpack_require__(1017); +// EXTERNAL MODULE: ./node_modules/node-domexception/index.js +var node_domexception = __webpack_require__(7760); +// EXTERNAL MODULE: ./node_modules/formdata-node/lib/esm/File.js +var File = __webpack_require__(2084); +;// CONCATENATED MODULE: ./node_modules/formdata-node/lib/esm/isPlainObject.js +const getType = (value) => (Object.prototype.toString.call(value).slice(8, -1).toLowerCase()); +function isPlainObject(value) { + if (getType(value) !== "object") { + return false; + } + const pp = Object.getPrototypeOf(value); + if (pp === null || pp === undefined) { + return true; + } + const Ctor = pp.constructor && pp.constructor.toString(); + return Ctor === Object.toString(); +} +/* harmony default export */ const esm_isPlainObject = (isPlainObject); + +// EXTERNAL MODULE: ./node_modules/formdata-node/lib/esm/isFile.js +var isFile = __webpack_require__(1574); +;// CONCATENATED MODULE: ./node_modules/formdata-node/lib/esm/fileFromPath.js +var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; +}; +var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +}; +var _FileFromPath_path, _FileFromPath_start; + + + + + + +const MESSAGE = "The requested file could not be read, " + + "typically due to permission problems that have occurred after a reference " + + "to a file was acquired."; +class FileFromPath { + constructor(input) { + _FileFromPath_path.set(this, void 0); + _FileFromPath_start.set(this, void 0); + __classPrivateFieldSet(this, _FileFromPath_path, input.path, "f"); + __classPrivateFieldSet(this, _FileFromPath_start, input.start || 0, "f"); + this.name = (0,external_path_.basename)(__classPrivateFieldGet(this, _FileFromPath_path, "f")); + this.size = input.size; + this.lastModified = input.lastModified; + } + slice(start, end) { + return new FileFromPath({ + path: __classPrivateFieldGet(this, _FileFromPath_path, "f"), + lastModified: this.lastModified, + size: end - start, + start + }); + } + async *stream() { + const { mtimeMs } = await external_fs_.promises.stat(__classPrivateFieldGet(this, _FileFromPath_path, "f")); + if (mtimeMs > this.lastModified) { + throw new node_domexception(MESSAGE, "NotReadableError"); + } + if (this.size) { + yield* (0,external_fs_.createReadStream)(__classPrivateFieldGet(this, _FileFromPath_path, "f"), { + start: __classPrivateFieldGet(this, _FileFromPath_start, "f"), + end: __classPrivateFieldGet(this, _FileFromPath_start, "f") + this.size - 1 + }); + } + } + get [(_FileFromPath_path = new WeakMap(), _FileFromPath_start = new WeakMap(), Symbol.toStringTag)]() { + return "File"; + } +} +function createFileFromPath(path, { mtimeMs, size }, filenameOrOptions, options = {}) { + let filename; + if (esm_isPlainObject(filenameOrOptions)) { + [options, filename] = [filenameOrOptions, undefined]; + } + else { + filename = filenameOrOptions; + } + const file = new FileFromPath({ path, size, lastModified: mtimeMs }); + if (!filename) { + filename = file.name; + } + return new File/* File */.$([file], filename, { + ...options, lastModified: file.lastModified + }); +} +function fileFromPathSync(path, filenameOrOptions, options = {}) { + const stats = (0,external_fs_.statSync)(path); + return createFileFromPath(path, stats, filenameOrOptions, options); +} +async function fileFromPath(path, filenameOrOptions, options) { + const stats = await external_fs_.promises.stat(path); + return createFileFromPath(path, stats, filenameOrOptions, options); +} + + +/***/ }) + +}; +; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index a6f49664..93213e9b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,7 +1,7 @@ /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ -/***/ 6959: +/***/ 562: /***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => { "use strict"; @@ -17,8 +17,8 @@ const external_node_http_namespaceObject = require("node:http"); const external_node_https_namespaceObject = require("node:https"); ;// CONCATENATED MODULE: external "node:zlib" const external_node_zlib_namespaceObject = require("node:zlib"); -;// CONCATENATED MODULE: external "node:stream" -const external_node_stream_namespaceObject = require("node:stream"); +// EXTERNAL MODULE: external "node:stream" +var external_node_stream_ = __nccwpck_require__(4492); ;// CONCATENATED MODULE: external "node:buffer" const external_node_buffer_namespaceObject = require("node:buffer"); ;// CONCATENATED MODULE: ./node_modules/data-uri-to-buffer/dist/index.js @@ -236,7 +236,7 @@ const isSameProtocol = (destination, original) => { -const pipeline = (0,external_node_util_namespaceObject.promisify)(external_node_stream_namespaceObject.pipeline); +const pipeline = (0,external_node_util_namespaceObject.promisify)(external_node_stream_.pipeline); const INTERNALS = Symbol('Body internals'); /** @@ -270,7 +270,7 @@ class Body { } else if (ArrayBuffer.isView(body)) { // Body is ArrayBufferView body = external_node_buffer_namespaceObject.Buffer.from(body.buffer, body.byteOffset, body.byteLength); - } else if (body instanceof external_node_stream_namespaceObject) { + } else if (body instanceof external_node_stream_) { // Body is stream } else if (body instanceof esm_min/* FormData */.Ct) { // Body is FormData @@ -285,9 +285,9 @@ class Body { let stream = body; if (external_node_buffer_namespaceObject.Buffer.isBuffer(body)) { - stream = external_node_stream_namespaceObject.Readable.from(body); + stream = external_node_stream_.Readable.from(body); } else if (isBlob(body)) { - stream = external_node_stream_namespaceObject.Readable.from(body.stream()); + stream = external_node_stream_.Readable.from(body.stream()); } this[INTERNALS] = { @@ -299,7 +299,7 @@ class Body { }; this.size = size; - if (body instanceof external_node_stream_namespaceObject) { + if (body instanceof external_node_stream_) { body.on('error', error_ => { const error = error_ instanceof FetchBaseError ? error_ : @@ -341,7 +341,7 @@ class Body { return formData; } - const {toFormData} = await __nccwpck_require__.e(/* import() */ 37).then(__nccwpck_require__.bind(__nccwpck_require__, 4037)); + const {toFormData} = await __nccwpck_require__.e(/* import() */ 37).then(__nccwpck_require__.bind(__nccwpck_require__, 6152)); return toFormData(this.body, ct); } @@ -430,7 +430,7 @@ async function consumeBody(data) { } /* c8 ignore next 3 */ - if (!(body instanceof external_node_stream_namespaceObject)) { + if (!(body instanceof external_node_stream_)) { return external_node_buffer_namespaceObject.Buffer.alloc(0); } @@ -489,10 +489,10 @@ const clone = (instance, highWaterMark) => { // Check that body is a stream and not form-data object // note: we can't clone the form-data object without having it as a dependency - if ((body instanceof external_node_stream_namespaceObject) && (typeof body.getBoundary !== 'function')) { + if ((body instanceof external_node_stream_) && (typeof body.getBoundary !== 'function')) { // Tee instance body - p1 = new external_node_stream_namespaceObject.PassThrough({highWaterMark}); - p2 = new external_node_stream_namespaceObject.PassThrough({highWaterMark}); + p1 = new external_node_stream_.PassThrough({highWaterMark}); + p2 = new external_node_stream_.PassThrough({highWaterMark}); body.pipe(p1); body.pipe(p2); // Set instance body to teed body and return the other teed body @@ -555,7 +555,7 @@ const extractContentType = (body, request) => { } // Body is stream - can't really do much about this - if (body instanceof external_node_stream_namespaceObject) { + if (body instanceof external_node_stream_) { return null; } @@ -1746,8 +1746,8 @@ class AbortError extends FetchBaseError { } } -// EXTERNAL MODULE: ./node_modules/fetch-blob/from.js + 2 modules -var from = __nccwpck_require__(2777); +// EXTERNAL MODULE: ./node_modules/fetch-blob/from.js + 1 modules +var from = __nccwpck_require__(7972); ;// CONCATENATED MODULE: ./node_modules/node-fetch/src/index.js /** * Index.js @@ -1789,7 +1789,7 @@ const supportedSchemas = new Set(['data:', 'http:', 'https:']); * @param {*} [options_] - Fetch options * @return {Promise} */ -async function fetch(url, options_) { +async function src_fetch(url, options_) { return new Promise((resolve, reject) => { // Build request object const request = new Request(url, options_); @@ -1813,7 +1813,7 @@ async function fetch(url, options_) { const abort = () => { const error = new AbortError('The operation was aborted.'); reject(error); - if (request.body && request.body instanceof external_node_stream_namespaceObject.Readable) { + if (request.body && request.body instanceof external_node_stream_.Readable) { request.body.destroy(error); } @@ -1957,7 +1957,7 @@ async function fetch(url, options_) { } // HTTP-redirect fetch step 9 - if (response_.statusCode !== 303 && request.body && options_.body instanceof external_node_stream_namespaceObject.Readable) { + if (response_.statusCode !== 303 && request.body && options_.body instanceof external_node_stream_.Readable) { reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect')); finalize(); return; @@ -1977,7 +1977,7 @@ async function fetch(url, options_) { } // HTTP-redirect fetch step 15 - resolve(fetch(new Request(locationURL, requestOptions))); + resolve(src_fetch(new Request(locationURL, requestOptions))); finalize(); return; } @@ -1994,7 +1994,7 @@ async function fetch(url, options_) { }); } - let body = (0,external_node_stream_namespaceObject.pipeline)(response_, new external_node_stream_namespaceObject.PassThrough(), error => { + let body = (0,external_node_stream_.pipeline)(response_, new external_node_stream_.PassThrough(), error => { if (error) { reject(error); } @@ -2044,7 +2044,7 @@ async function fetch(url, options_) { // For gzip if (codings === 'gzip' || codings === 'x-gzip') { - body = (0,external_node_stream_namespaceObject.pipeline)(body, external_node_zlib_namespaceObject.createGunzip(zlibOptions), error => { + body = (0,external_node_stream_.pipeline)(body, external_node_zlib_namespaceObject.createGunzip(zlibOptions), error => { if (error) { reject(error); } @@ -2058,7 +2058,7 @@ async function fetch(url, options_) { if (codings === 'deflate' || codings === 'x-deflate') { // Handle the infamous raw deflate response from old servers // a hack for old IIS and Apache servers - const raw = (0,external_node_stream_namespaceObject.pipeline)(response_, new external_node_stream_namespaceObject.PassThrough(), error => { + const raw = (0,external_node_stream_.pipeline)(response_, new external_node_stream_.PassThrough(), error => { if (error) { reject(error); } @@ -2066,13 +2066,13 @@ async function fetch(url, options_) { raw.once('data', chunk => { // See http://stackoverflow.com/questions/37519828 if ((chunk[0] & 0x0F) === 0x08) { - body = (0,external_node_stream_namespaceObject.pipeline)(body, external_node_zlib_namespaceObject.createInflate(), error => { + body = (0,external_node_stream_.pipeline)(body, external_node_zlib_namespaceObject.createInflate(), error => { if (error) { reject(error); } }); } else { - body = (0,external_node_stream_namespaceObject.pipeline)(body, external_node_zlib_namespaceObject.createInflateRaw(), error => { + body = (0,external_node_stream_.pipeline)(body, external_node_zlib_namespaceObject.createInflateRaw(), error => { if (error) { reject(error); } @@ -2095,7 +2095,7 @@ async function fetch(url, options_) { // For br if (codings === 'br') { - body = (0,external_node_stream_namespaceObject.pipeline)(body, external_node_zlib_namespaceObject.createBrotliDecompress(), error => { + body = (0,external_node_stream_.pipeline)(body, external_node_zlib_namespaceObject.createBrotliDecompress(), error => { if (error) { reject(error); } @@ -2164,7 +2164,7 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) { // fetch-polyfill.js if (!globalThis.fetch) { - globalThis.fetch = fetch; + globalThis.fetch = src_fetch; globalThis.Headers = Headers; globalThis.Request = Request; globalThis.Response = Response; @@ -2172,679 +2172,2871 @@ if (!globalThis.fetch) { // EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js var core = __nccwpck_require__(2186); -// EXTERNAL MODULE: ./node_modules/keyv/src/index.js -var src = __nccwpck_require__(1531); -;// CONCATENATED MODULE: ./node_modules/p-timeout/index.js -class TimeoutError extends Error { - constructor(message) { - super(message); - this.name = 'TimeoutError'; - } -} +// EXTERNAL MODULE: ./node_modules/langchain/dist/chains/base.js +var base = __nccwpck_require__(3197); +// EXTERNAL MODULE: ./node_modules/langchain/dist/chains/llm_chain.js + 1 modules +var llm_chain = __nccwpck_require__(7287); +// EXTERNAL MODULE: ./node_modules/langchain/dist/chains/api/api_chain.js + 1 modules +var api_chain = __nccwpck_require__(6159); +// EXTERNAL MODULE: ./node_modules/langchain/dist/prompts/prompt.js +var prompts_prompt = __nccwpck_require__(3379); +// EXTERNAL MODULE: ./node_modules/langchain/dist/memory/base.js +var memory_base = __nccwpck_require__(790); +// EXTERNAL MODULE: ./node_modules/langchain/dist/schema/index.js +var schema = __nccwpck_require__(8102); +;// CONCATENATED MODULE: ./node_modules/langchain/dist/stores/message/in_memory.js /** -An error to be thrown when the request is aborted by AbortController. -DOMException is thrown instead of this Error when DOMException is available. -*/ -class p_timeout_AbortError extends Error { - constructor(message) { - super(); - this.name = 'AbortError'; - this.message = message; - } + * Class for storing chat message history in-memory. It extends the + * BaseListChatMessageHistory class and provides methods to get, add, and + * clear messages. + */ +class ChatMessageHistory extends schema/* BaseListChatMessageHistory */.oV { + constructor(messages) { + super(...arguments); + Object.defineProperty(this, "lc_namespace", { + enumerable: true, + configurable: true, + writable: true, + value: ["langchain", "stores", "message", "in_memory"] + }); + Object.defineProperty(this, "messages", { + enumerable: true, + configurable: true, + writable: true, + value: [] + }); + this.messages = messages ?? []; + } + /** + * Method to get all the messages stored in the ChatMessageHistory + * instance. + * @returns Array of stored BaseMessage instances. + */ + async getMessages() { + return this.messages; + } + /** + * Method to add a new message to the ChatMessageHistory instance. + * @param message The BaseMessage instance to add. + * @returns A promise that resolves when the message has been added. + */ + async addMessage(message) { + this.messages.push(message); + } + /** + * Method to clear all the messages from the ChatMessageHistory instance. + * @returns A promise that resolves when all messages have been cleared. + */ + async clear() { + this.messages = []; + } } -/** -TODO: Remove AbortError and just throw DOMException when targeting Node 18. -*/ -const getDOMException = errorMessage => globalThis.DOMException === undefined - ? new p_timeout_AbortError(errorMessage) - : new DOMException(errorMessage); +;// CONCATENATED MODULE: ./node_modules/langchain/dist/memory/chat_memory.js + /** -TODO: Remove below function and just 'reject(signal.reason)' when targeting Node 18. -*/ -const getAbortedReason = signal => { - const reason = signal.reason === undefined - ? getDOMException('This operation was aborted.') - : signal.reason; + * Abstract class that provides a base for implementing different types of + * memory systems. It is designed to maintain the state of an application, + * specifically the history of a conversation. This class is typically + * extended by other classes to create specific types of memory systems. + */ +class chat_memory_BaseChatMemory extends memory_base/* BaseMemory */.fF { + constructor(fields) { + super(); + Object.defineProperty(this, "chatHistory", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "returnMessages", { + enumerable: true, + configurable: true, + writable: true, + value: false + }); + Object.defineProperty(this, "inputKey", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "outputKey", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + this.chatHistory = fields?.chatHistory ?? new ChatMessageHistory(); + this.returnMessages = fields?.returnMessages ?? this.returnMessages; + this.inputKey = fields?.inputKey ?? this.inputKey; + this.outputKey = fields?.outputKey ?? this.outputKey; + } + /** + * Method to add user and AI messages to the chat history in sequence. + * @param inputValues The input values from the user. + * @param outputValues The output values from the AI. + * @returns Promise that resolves when the context has been saved. + */ + async saveContext(inputValues, outputValues) { + // this is purposefully done in sequence so they're saved in order + await this.chatHistory.addUserMessage((0,memory_base/* getInputValue */.d9)(inputValues, this.inputKey)); + await this.chatHistory.addAIChatMessage((0,memory_base/* getOutputValue */.jG)(outputValues, this.outputKey)); + } + /** + * Method to clear the chat history. + * @returns Promise that resolves when the chat history has been cleared. + */ + async clear() { + await this.chatHistory.clear(); + } +} + +;// CONCATENATED MODULE: ./node_modules/langchain/dist/memory/buffer_memory.js - return reason instanceof Error ? reason : getDOMException(reason); -}; -function pTimeout(promise, options) { - const { - milliseconds, - fallback, - message, - customTimers = {setTimeout, clearTimeout}, - } = options; +/** + * The `BufferMemory` class is a type of memory component used for storing + * and managing previous chat messages. It is a wrapper around + * `ChatMessageHistory` that extracts the messages into an input variable. + * This class is particularly useful in applications like chatbots where + * it is essential to remember previous interactions. Note: The memory + * instance represents the history of a single conversation. Therefore, it + * is not recommended to share the same history or memory instance between + * two different chains. If you deploy your LangChain app on a serverless + * environment, do not store memory instances in a variable, as your + * hosting provider may reset it by the next time the function is called. + * @example + * ```typescript + * // Initialize the memory to store chat history and set up the language model with a specific temperature. + * const memory = new BufferMemory({ memoryKey: "chat_history" }); + * const model = new ChatOpenAI({ temperature: 0.9 }); + * + * // Create a prompt template for a friendly conversation between a human and an AI. + * const prompt = + * PromptTemplate.fromTemplate(`The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. + * + * Current conversation: + * {chat_history} + * Human: {input} + * AI:`); + * + * // Set up the chain with the language model, prompt, and memory. + * const chain = new LLMChain({ llm: model, prompt, memory }); + * + * // Example usage of the chain to continue the conversation. + * // The `call` method sends the input to the model and returns the AI's response. + * const res = await chain.call({ input: "Hi! I'm Jim." }); + * console.log({ res }); + * + * ``` + */ +class BufferMemory extends chat_memory_BaseChatMemory { + constructor(fields) { + super({ + chatHistory: fields?.chatHistory, + returnMessages: fields?.returnMessages ?? false, + inputKey: fields?.inputKey, + outputKey: fields?.outputKey, + }); + Object.defineProperty(this, "humanPrefix", { + enumerable: true, + configurable: true, + writable: true, + value: "Human" + }); + Object.defineProperty(this, "aiPrefix", { + enumerable: true, + configurable: true, + writable: true, + value: "AI" + }); + Object.defineProperty(this, "memoryKey", { + enumerable: true, + configurable: true, + writable: true, + value: "history" + }); + this.humanPrefix = fields?.humanPrefix ?? this.humanPrefix; + this.aiPrefix = fields?.aiPrefix ?? this.aiPrefix; + this.memoryKey = fields?.memoryKey ?? this.memoryKey; + } + get memoryKeys() { + return [this.memoryKey]; + } + /** + * Loads the memory variables. It takes an `InputValues` object as a + * parameter and returns a `Promise` that resolves with a + * `MemoryVariables` object. + * @param _values `InputValues` object. + * @returns A `Promise` that resolves with a `MemoryVariables` object. + */ + async loadMemoryVariables(_values) { + const messages = await this.chatHistory.getMessages(); + if (this.returnMessages) { + const result = { + [this.memoryKey]: messages, + }; + return result; + } + const result = { + [this.memoryKey]: (0,memory_base/* getBufferString */.zs)(messages, this.humanPrefix, this.aiPrefix), + }; + return result; + } +} - let timer; +;// CONCATENATED MODULE: ./node_modules/langchain/dist/chains/conversation.js - const cancelablePromise = new Promise((resolve, reject) => { - if (typeof milliseconds !== 'number' || Math.sign(milliseconds) !== 1) { - throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${milliseconds}\``); - } - if (milliseconds === Number.POSITIVE_INFINITY) { - resolve(promise); - return; - } - if (options.signal) { - const {signal} = options; - if (signal.aborted) { - reject(getAbortedReason(signal)); - } +const conversation_DEFAULT_TEMPLATE = `The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. - signal.addEventListener('abort', () => { - reject(getAbortedReason(signal)); - }); - } +Current conversation: +{history} +Human: {input} +AI:`; +/** + * A class for conducting conversations between a human and an AI. It + * extends the {@link LLMChain} class. + * @example + * ```typescript + * const model = new ChatOpenAI({}); + * const chain = new ConversationChain({ llm: model }); + * + * // Sending a greeting to the conversation chain + * const res1 = await chain.call({ input: "Hi! I'm Jim." }); + * console.log({ res1 }); + * + * // Following up with a question in the conversation + * const res2 = await chain.call({ input: "What's my name?" }); + * console.log({ res2 }); + * ``` + */ +class conversation_ConversationChain extends llm_chain.LLMChain { + static lc_name() { + return "ConversationChain"; + } + constructor({ prompt, outputKey, memory, ...rest }) { + super({ + prompt: prompt ?? + new prompts_prompt.PromptTemplate({ + template: conversation_DEFAULT_TEMPLATE, + inputVariables: ["history", "input"], + }), + outputKey: outputKey ?? "response", + memory: memory ?? new BufferMemory(), + ...rest, + }); + } +} - // We create the error outside of `setTimeout` to preserve the stack trace. - const timeoutError = new TimeoutError(); +// EXTERNAL MODULE: ./node_modules/langchain/dist/chains/sequential_chain.js + 1 modules +var sequential_chain = __nccwpck_require__(7210); +// EXTERNAL MODULE: ./node_modules/langchain/dist/chains/combine_docs_chain.js +var combine_docs_chain = __nccwpck_require__(3608); +// EXTERNAL MODULE: ./node_modules/langchain/dist/chains/question_answering/load.js + 4 modules +var load = __nccwpck_require__(3504); +;// CONCATENATED MODULE: ./node_modules/langchain/dist/chains/chat_vector_db_chain.js - timer = customTimers.setTimeout.call(undefined, () => { - if (fallback) { - try { - resolve(fallback()); - } catch (error) { - reject(error); - } - return; - } - if (typeof promise.cancel === 'function') { - promise.cancel(); - } - if (message === false) { - resolve(); - } else if (message instanceof Error) { - reject(message); - } else { - timeoutError.message = message ?? `Promise timed out after ${milliseconds} milliseconds`; - reject(timeoutError); - } - }, milliseconds); +const question_generator_template = (/* unused pure expression or super */ null && (`Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question. - (async () => { - try { - resolve(await promise); - } catch (error) { - reject(error); - } finally { - customTimers.clearTimeout.call(undefined, timer); - } - })(); - }); +Chat History: +{chat_history} +Follow Up Input: {question} +Standalone question:`)); +const qa_template = (/* unused pure expression or super */ null && (`Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer. - cancelablePromise.clear = () => { - customTimers.clearTimeout.call(undefined, timer); - timer = undefined; - }; +{context} - return cancelablePromise; +Question: {question} +Helpful Answer:`)); +/** @deprecated use `ConversationalRetrievalQAChain` instead. */ +class ChatVectorDBQAChain extends (/* unused pure expression or super */ null && (BaseChain)) { + get inputKeys() { + return [this.inputKey, this.chatHistoryKey]; + } + get outputKeys() { + return [this.outputKey]; + } + constructor(fields) { + super(fields); + Object.defineProperty(this, "k", { + enumerable: true, + configurable: true, + writable: true, + value: 4 + }); + Object.defineProperty(this, "inputKey", { + enumerable: true, + configurable: true, + writable: true, + value: "question" + }); + Object.defineProperty(this, "chatHistoryKey", { + enumerable: true, + configurable: true, + writable: true, + value: "chat_history" + }); + Object.defineProperty(this, "outputKey", { + enumerable: true, + configurable: true, + writable: true, + value: "result" + }); + Object.defineProperty(this, "vectorstore", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "combineDocumentsChain", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "questionGeneratorChain", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + Object.defineProperty(this, "returnSourceDocuments", { + enumerable: true, + configurable: true, + writable: true, + value: false + }); + this.vectorstore = fields.vectorstore; + this.combineDocumentsChain = fields.combineDocumentsChain; + this.questionGeneratorChain = fields.questionGeneratorChain; + this.inputKey = fields.inputKey ?? this.inputKey; + this.outputKey = fields.outputKey ?? this.outputKey; + this.k = fields.k ?? this.k; + this.returnSourceDocuments = + fields.returnSourceDocuments ?? this.returnSourceDocuments; + } + /** @ignore */ + async _call(values, runManager) { + if (!(this.inputKey in values)) { + throw new Error(`Question key ${this.inputKey} not found.`); + } + if (!(this.chatHistoryKey in values)) { + throw new Error(`chat history key ${this.inputKey} not found.`); + } + const question = values[this.inputKey]; + const chatHistory = values[this.chatHistoryKey]; + let newQuestion = question; + if (chatHistory.length > 0) { + const result = await this.questionGeneratorChain.call({ + question, + chat_history: chatHistory, + }, runManager?.getChild("question_generator")); + const keys = Object.keys(result); + console.log("_call", values, keys); + if (keys.length === 1) { + newQuestion = result[keys[0]]; + } + else { + throw new Error("Return from llm chain has multiple values, only single values supported."); + } + } + const docs = await this.vectorstore.similaritySearch(newQuestion, this.k, undefined, runManager?.getChild("vectorstore")); + const inputs = { + question: newQuestion, + input_documents: docs, + chat_history: chatHistory, + }; + const result = await this.combineDocumentsChain.call(inputs, runManager?.getChild("combine_documents")); + if (this.returnSourceDocuments) { + return { + ...result, + sourceDocuments: docs, + }; + } + return result; + } + _chainType() { + return "chat-vector-db"; + } + static async deserialize(data, values) { + if (!("vectorstore" in values)) { + throw new Error(`Need to pass in a vectorstore to deserialize VectorDBQAChain`); + } + const { vectorstore } = values; + return new ChatVectorDBQAChain({ + combineDocumentsChain: await BaseChain.deserialize(data.combine_documents_chain), + questionGeneratorChain: await LLMChain.deserialize(data.question_generator), + k: data.k, + vectorstore, + }); + } + serialize() { + return { + _type: this._chainType(), + combine_documents_chain: this.combineDocumentsChain.serialize(), + question_generator: this.questionGeneratorChain.serialize(), + k: this.k, + }; + } + /** + * Creates an instance of ChatVectorDBQAChain using a BaseLanguageModel + * and other options. + * @param llm Instance of BaseLanguageModel used to generate a new question. + * @param vectorstore Instance of VectorStore used for vector operations. + * @param options (Optional) Additional options for creating the ChatVectorDBQAChain instance. + * @returns New instance of ChatVectorDBQAChain. + */ + static fromLLM(llm, vectorstore, options = {}) { + const { questionGeneratorTemplate, qaTemplate, verbose, ...rest } = options; + const question_generator_prompt = PromptTemplate.fromTemplate(questionGeneratorTemplate || question_generator_template); + const qa_prompt = PromptTemplate.fromTemplate(qaTemplate || qa_template); + const qaChain = loadQAStuffChain(llm, { prompt: qa_prompt, verbose }); + const questionGeneratorChain = new LLMChain({ + prompt: question_generator_prompt, + llm, + verbose, + }); + const instance = new this({ + vectorstore, + combineDocumentsChain: qaChain, + questionGeneratorChain, + ...rest, + }); + return instance; + } } -;// CONCATENATED MODULE: ./node_modules/quick-lru/index.js -class QuickLRU extends Map { - constructor(options = {}) { - super(); +// EXTERNAL MODULE: ./node_modules/langchain/dist/util/tiktoken.js + 3 modules +var tiktoken = __nccwpck_require__(7573); +// EXTERNAL MODULE: ./node_modules/langchain/dist/schema/runnable/index.js + 3 modules +var runnable = __nccwpck_require__(4379); +;// CONCATENATED MODULE: ./node_modules/langchain/dist/schema/document.js - if (!(options.maxSize && options.maxSize > 0)) { - throw new TypeError('`maxSize` must be a number greater than 0'); - } +/** + * Abstract base class for document transformation systems. + * + * A document transformation system takes an array of Documents and returns an + * array of transformed Documents. These arrays do not necessarily have to have + * the same length. + * + * One example of this is a text splitter that splits a large document into + * many smaller documents. + */ +class document_BaseDocumentTransformer extends (/* unused pure expression or super */ null && (Runnable)) { + constructor() { + super(...arguments); + Object.defineProperty(this, "lc_namespace", { + enumerable: true, + configurable: true, + writable: true, + value: ["langchain", "document_transformers"] + }); + } + /** + * Method to invoke the document transformation. This method calls the + * transformDocuments method with the provided input. + * @param input The input documents to be transformed. + * @param _options Optional configuration object to customize the behavior of callbacks. + * @returns A Promise that resolves to the transformed documents. + */ + invoke(input, _options) { + return this.transformDocuments(input); + } +} +/** + * Class for document transformers that return exactly one transformed document + * for each input document. + */ +class MappingDocumentTransformer extends (/* unused pure expression or super */ null && (document_BaseDocumentTransformer)) { + async transformDocuments(documents) { + const newDocuments = []; + for (const document of documents) { + const transformedDocument = await this._transformDocument(document); + newDocuments.push(transformedDocument); + } + return newDocuments; + } +} - if (typeof options.maxAge === 'number' && options.maxAge === 0) { - throw new TypeError('`maxAge` must be a number greater than 0'); - } +;// CONCATENATED MODULE: ./node_modules/langchain/dist/text_splitter.js - // TODO: Use private class fields when ESLint supports them. - this.maxSize = options.maxSize; - this.maxAge = options.maxAge || Number.POSITIVE_INFINITY; - this.onEviction = options.onEviction; - this.cache = new Map(); - this.oldCache = new Map(); - this._size = 0; - } - // TODO: Use private class methods when targeting Node.js 16. - _emitEvictions(cache) { - if (typeof this.onEviction !== 'function') { - return; - } - for (const [key, item] of cache) { - this.onEviction(key, item.value); - } - } +class TextSplitter extends (/* unused pure expression or super */ null && (BaseDocumentTransformer)) { + constructor(fields) { + super(fields); + Object.defineProperty(this, "lc_namespace", { + enumerable: true, + configurable: true, + writable: true, + value: ["langchain", "document_transformers", "text_splitters"] + }); + Object.defineProperty(this, "chunkSize", { + enumerable: true, + configurable: true, + writable: true, + value: 1000 + }); + Object.defineProperty(this, "chunkOverlap", { + enumerable: true, + configurable: true, + writable: true, + value: 200 + }); + Object.defineProperty(this, "keepSeparator", { + enumerable: true, + configurable: true, + writable: true, + value: false + }); + Object.defineProperty(this, "lengthFunction", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + this.chunkSize = fields?.chunkSize ?? this.chunkSize; + this.chunkOverlap = fields?.chunkOverlap ?? this.chunkOverlap; + this.keepSeparator = fields?.keepSeparator ?? this.keepSeparator; + this.lengthFunction = + fields?.lengthFunction ?? ((text) => text.length); + if (this.chunkOverlap >= this.chunkSize) { + throw new Error("Cannot have chunkOverlap >= chunkSize"); + } + } + async transformDocuments(documents, chunkHeaderOptions = {}) { + return this.splitDocuments(documents, chunkHeaderOptions); + } + splitOnSeparator(text, separator) { + let splits; + if (separator) { + if (this.keepSeparator) { + const regexEscapedSeparator = separator.replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&"); + splits = text.split(new RegExp(`(?=${regexEscapedSeparator})`)); + } + else { + splits = text.split(separator); + } + } + else { + splits = text.split(""); + } + return splits.filter((s) => s !== ""); + } + async createDocuments(texts, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + metadatas = [], chunkHeaderOptions = {}) { + // if no metadata is provided, we create an empty one for each text + const _metadatas = metadatas.length > 0 ? metadatas : new Array(texts.length).fill({}); + const { chunkHeader = "", chunkOverlapHeader = "(cont'd) ", appendChunkOverlapHeader = false, } = chunkHeaderOptions; + const documents = new Array(); + for (let i = 0; i < texts.length; i += 1) { + const text = texts[i]; + let lineCounterIndex = 1; + let prevChunk = null; + let indexPrevChunk = -1; + for (const chunk of await this.splitText(text)) { + let pageContent = chunkHeader; + // we need to count the \n that are in the text before getting removed by the splitting + const indexChunk = text.indexOf(chunk, indexPrevChunk + 1); + if (prevChunk === null) { + const newLinesBeforeFirstChunk = this.numberOfNewLines(text, 0, indexChunk); + lineCounterIndex += newLinesBeforeFirstChunk; + } + else { + const indexEndPrevChunk = indexPrevChunk + (await this.lengthFunction(prevChunk)); + if (indexEndPrevChunk < indexChunk) { + const numberOfIntermediateNewLines = this.numberOfNewLines(text, indexEndPrevChunk, indexChunk); + lineCounterIndex += numberOfIntermediateNewLines; + } + else if (indexEndPrevChunk > indexChunk) { + const numberOfIntermediateNewLines = this.numberOfNewLines(text, indexChunk, indexEndPrevChunk); + lineCounterIndex -= numberOfIntermediateNewLines; + } + if (appendChunkOverlapHeader) { + pageContent += chunkOverlapHeader; + } + } + const newLinesCount = this.numberOfNewLines(chunk); + const loc = _metadatas[i].loc && typeof _metadatas[i].loc === "object" + ? { ..._metadatas[i].loc } + : {}; + loc.lines = { + from: lineCounterIndex, + to: lineCounterIndex + newLinesCount, + }; + const metadataWithLinesNumber = { + ..._metadatas[i], + loc, + }; + pageContent += chunk; + documents.push(new Document({ + pageContent, + metadata: metadataWithLinesNumber, + })); + lineCounterIndex += newLinesCount; + prevChunk = chunk; + indexPrevChunk = indexChunk; + } + } + return documents; + } + numberOfNewLines(text, start, end) { + const textSection = text.slice(start, end); + return (textSection.match(/\n/g) || []).length; + } + async splitDocuments(documents, chunkHeaderOptions = {}) { + const selectedDocuments = documents.filter((doc) => doc.pageContent !== undefined); + const texts = selectedDocuments.map((doc) => doc.pageContent); + const metadatas = selectedDocuments.map((doc) => doc.metadata); + return this.createDocuments(texts, metadatas, chunkHeaderOptions); + } + joinDocs(docs, separator) { + const text = docs.join(separator).trim(); + return text === "" ? null : text; + } + async mergeSplits(splits, separator) { + const docs = []; + const currentDoc = []; + let total = 0; + for (const d of splits) { + const _len = await this.lengthFunction(d); + if (total + _len + (currentDoc.length > 0 ? separator.length : 0) > + this.chunkSize) { + if (total > this.chunkSize) { + console.warn(`Created a chunk of size ${total}, + +which is longer than the specified ${this.chunkSize}`); + } + if (currentDoc.length > 0) { + const doc = this.joinDocs(currentDoc, separator); + if (doc !== null) { + docs.push(doc); + } + // Keep on popping if: + // - we have a larger chunk than in the chunk overlap + // - or if we still have any chunks and the length is long + while (total > this.chunkOverlap || + (total + _len > this.chunkSize && total > 0)) { + total -= await this.lengthFunction(currentDoc[0]); + currentDoc.shift(); + } + } + } + currentDoc.push(d); + total += _len; + } + const doc = this.joinDocs(currentDoc, separator); + if (doc !== null) { + docs.push(doc); + } + return docs; + } +} +class CharacterTextSplitter extends (/* unused pure expression or super */ null && (TextSplitter)) { + static lc_name() { + return "CharacterTextSplitter"; + } + constructor(fields) { + super(fields); + Object.defineProperty(this, "separator", { + enumerable: true, + configurable: true, + writable: true, + value: "\n\n" + }); + this.separator = fields?.separator ?? this.separator; + } + async splitText(text) { + // First we naively split the large input into a bunch of smaller ones. + const splits = this.splitOnSeparator(text, this.separator); + return this.mergeSplits(splits, this.keepSeparator ? "" : this.separator); + } +} +const SupportedTextSplitterLanguages = (/* unused pure expression or super */ null && ([ + "cpp", + "go", + "java", + "js", + "php", + "proto", + "python", + "rst", + "ruby", + "rust", + "scala", + "swift", + "markdown", + "latex", + "html", + "sol", +])); +class text_splitter_RecursiveCharacterTextSplitter extends (/* unused pure expression or super */ null && (TextSplitter)) { + static lc_name() { + return "RecursiveCharacterTextSplitter"; + } + constructor(fields) { + super(fields); + Object.defineProperty(this, "separators", { + enumerable: true, + configurable: true, + writable: true, + value: ["\n\n", "\n", " ", ""] + }); + this.separators = fields?.separators ?? this.separators; + this.keepSeparator = fields?.keepSeparator ?? true; + } + async _splitText(text, separators) { + const finalChunks = []; + // Get appropriate separator to use + let separator = separators[separators.length - 1]; + let newSeparators; + for (let i = 0; i < separators.length; i += 1) { + const s = separators[i]; + if (s === "") { + separator = s; + break; + } + if (text.includes(s)) { + separator = s; + newSeparators = separators.slice(i + 1); + break; + } + } + // Now that we have the separator, split the text + const splits = this.splitOnSeparator(text, separator); + // Now go merging things, recursively splitting longer texts. + let goodSplits = []; + const _separator = this.keepSeparator ? "" : separator; + for (const s of splits) { + if ((await this.lengthFunction(s)) < this.chunkSize) { + goodSplits.push(s); + } + else { + if (goodSplits.length) { + const mergedText = await this.mergeSplits(goodSplits, _separator); + finalChunks.push(...mergedText); + goodSplits = []; + } + if (!newSeparators) { + finalChunks.push(s); + } + else { + const otherInfo = await this._splitText(s, newSeparators); + finalChunks.push(...otherInfo); + } + } + } + if (goodSplits.length) { + const mergedText = await this.mergeSplits(goodSplits, _separator); + finalChunks.push(...mergedText); + } + return finalChunks; + } + async splitText(text) { + return this._splitText(text, this.separators); + } + static fromLanguage(language, options) { + return new text_splitter_RecursiveCharacterTextSplitter({ + ...options, + separators: text_splitter_RecursiveCharacterTextSplitter.getSeparatorsForLanguage(language), + }); + } + static getSeparatorsForLanguage(language) { + if (language === "cpp") { + return [ + // Split along class definitions + "\nclass ", + // Split along function definitions + "\nvoid ", + "\nint ", + "\nfloat ", + "\ndouble ", + // Split along control flow statements + "\nif ", + "\nfor ", + "\nwhile ", + "\nswitch ", + "\ncase ", + // Split by the normal type of lines + "\n\n", + "\n", + " ", + "", + ]; + } + else if (language === "go") { + return [ + // Split along function definitions + "\nfunc ", + "\nvar ", + "\nconst ", + "\ntype ", + // Split along control flow statements + "\nif ", + "\nfor ", + "\nswitch ", + "\ncase ", + // Split by the normal type of lines + "\n\n", + "\n", + " ", + "", + ]; + } + else if (language === "java") { + return [ + // Split along class definitions + "\nclass ", + // Split along method definitions + "\npublic ", + "\nprotected ", + "\nprivate ", + "\nstatic ", + // Split along control flow statements + "\nif ", + "\nfor ", + "\nwhile ", + "\nswitch ", + "\ncase ", + // Split by the normal type of lines + "\n\n", + "\n", + " ", + "", + ]; + } + else if (language === "js") { + return [ + // Split along function definitions + "\nfunction ", + "\nconst ", + "\nlet ", + "\nvar ", + "\nclass ", + // Split along control flow statements + "\nif ", + "\nfor ", + "\nwhile ", + "\nswitch ", + "\ncase ", + "\ndefault ", + // Split by the normal type of lines + "\n\n", + "\n", + " ", + "", + ]; + } + else if (language === "php") { + return [ + // Split along function definitions + "\nfunction ", + // Split along class definitions + "\nclass ", + // Split along control flow statements + "\nif ", + "\nforeach ", + "\nwhile ", + "\ndo ", + "\nswitch ", + "\ncase ", + // Split by the normal type of lines + "\n\n", + "\n", + " ", + "", + ]; + } + else if (language === "proto") { + return [ + // Split along message definitions + "\nmessage ", + // Split along service definitions + "\nservice ", + // Split along enum definitions + "\nenum ", + // Split along option definitions + "\noption ", + // Split along import statements + "\nimport ", + // Split along syntax declarations + "\nsyntax ", + // Split by the normal type of lines + "\n\n", + "\n", + " ", + "", + ]; + } + else if (language === "python") { + return [ + // First, try to split along class definitions + "\nclass ", + "\ndef ", + "\n\tdef ", + // Now split by the normal type of lines + "\n\n", + "\n", + " ", + "", + ]; + } + else if (language === "rst") { + return [ + // Split along section titles + "\n===\n", + "\n---\n", + "\n***\n", + // Split along directive markers + "\n.. ", + // Split by the normal type of lines + "\n\n", + "\n", + " ", + "", + ]; + } + else if (language === "ruby") { + return [ + // Split along method definitions + "\ndef ", + "\nclass ", + // Split along control flow statements + "\nif ", + "\nunless ", + "\nwhile ", + "\nfor ", + "\ndo ", + "\nbegin ", + "\nrescue ", + // Split by the normal type of lines + "\n\n", + "\n", + " ", + "", + ]; + } + else if (language === "rust") { + return [ + // Split along function definitions + "\nfn ", + "\nconst ", + "\nlet ", + // Split along control flow statements + "\nif ", + "\nwhile ", + "\nfor ", + "\nloop ", + "\nmatch ", + "\nconst ", + // Split by the normal type of lines + "\n\n", + "\n", + " ", + "", + ]; + } + else if (language === "scala") { + return [ + // Split along class definitions + "\nclass ", + "\nobject ", + // Split along method definitions + "\ndef ", + "\nval ", + "\nvar ", + // Split along control flow statements + "\nif ", + "\nfor ", + "\nwhile ", + "\nmatch ", + "\ncase ", + // Split by the normal type of lines + "\n\n", + "\n", + " ", + "", + ]; + } + else if (language === "swift") { + return [ + // Split along function definitions + "\nfunc ", + // Split along class definitions + "\nclass ", + "\nstruct ", + "\nenum ", + // Split along control flow statements + "\nif ", + "\nfor ", + "\nwhile ", + "\ndo ", + "\nswitch ", + "\ncase ", + // Split by the normal type of lines + "\n\n", + "\n", + " ", + "", + ]; + } + else if (language === "markdown") { + return [ + // First, try to split along Markdown headings (starting with level 2) + "\n## ", + "\n### ", + "\n#### ", + "\n##### ", + "\n###### ", + // Note the alternative syntax for headings (below) is not handled here + // Heading level 2 + // --------------- + // End of code block + "```\n\n", + // Horizontal lines + "\n\n***\n\n", + "\n\n---\n\n", + "\n\n___\n\n", + // Note that this splitter doesn't handle horizontal lines defined + // by *three or more* of ***, ---, or ___, but this is not handled + "\n\n", + "\n", + " ", + "", + ]; + } + else if (language === "latex") { + return [ + // First, try to split along Latex sections + "\n\\chapter{", + "\n\\section{", + "\n\\subsection{", + "\n\\subsubsection{", + // Now split by environments + "\n\\begin{enumerate}", + "\n\\begin{itemize}", + "\n\\begin{description}", + "\n\\begin{list}", + "\n\\begin{quote}", + "\n\\begin{quotation}", + "\n\\begin{verse}", + "\n\\begin{verbatim}", + // Now split by math environments + "\n\\begin{align}", + "$$", + "$", + // Now split by the normal type of lines + "\n\n", + "\n", + " ", + "", + ]; + } + else if (language === "html") { + return [ + // First, try to split along HTML tags + "", + "
", + "

", + "
", + "

  • ", + "

    ", + "

    ", + "

    ", + "

    ", + "

    ", + "
    ", + "", + "", + "", + "
    ", + "", + "
      ", + "
        ", + "
        ", + "