diff --git a/eslint.config.mjs b/eslint.config.mjs index 22ffaa3..96582a8 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -30,6 +30,7 @@ export default antfu({ 'regexp/no-super-linear-backtracking': 'warn', 'node/prefer-global/process': 'off', 'curly': ['warn', 'multi-or-nest'], + 'antfu/curly': 'off', 'antfu/if-newline': 'off', 'brace-style': 'off', 'no-console': 'off', diff --git a/index.ts b/index.ts index a51cd7a..8eaf2d8 100644 --- a/index.ts +++ b/index.ts @@ -25,7 +25,7 @@ nodemon.once('start', () => { log.info('Restarting the Cat...') }).on('quit', () => { log.info('Stopping the Cat...') - deleteTempFiles('./src', f => f.startsWith('tmp_') && f.endsWith('.ts')) + deleteTempFiles('./src') process.exit() }).on('error', (err) => { log.error(err) @@ -35,11 +35,11 @@ process.on('SIGINT', () => { nodemon.emit('quit') }) -function deleteTempFiles(path: string, check: (str: string) => boolean) { +function deleteTempFiles(path: string) { readdirSync(path).forEach((file) => { const filePath = join(path, file) const isDirectory = statSync(filePath).isDirectory() - if (isDirectory) deleteTempFiles(filePath, check) - else if (check(file)) unlinkSync(filePath) + if (isDirectory) deleteTempFiles(filePath) + else if (file.startsWith('tmp_') && file.endsWith('.ts')) unlinkSync(filePath) }) } diff --git a/package.json b/package.json index ac60aae..0227ad2 100644 --- a/package.json +++ b/package.json @@ -61,11 +61,11 @@ "@langchain/anthropic": "^0.1.21", "@langchain/azure-openai": "^0.0.9", "@langchain/cohere": "^0.0.10", - "@langchain/community": "^0.2.2", - "@langchain/core": "^0.2.0", + "@langchain/community": "^0.2.4", + "@langchain/core": "^0.2.5", "@langchain/google-genai": "^0.0.16", - "@langchain/mistralai": "^0.0.22", - "@langchain/openai": "^0.0.33", + "@langchain/mistralai": "^0.0.23", + "@langchain/openai": "^0.1.0", "@mgcrea/fastify-request-logger": "^1.6.0", "@mgcrea/pino-pretty-compact": "^1.3.0", "@qdrant/js-client-rest": "^1.9.0", @@ -86,7 +86,7 @@ "html-to-text": "^9.0.5", "is-docker": "^3.0.0", "js-tiktoken": "^1.0.12", - "langchain": "^0.2.2", + "langchain": "^0.2.4", "lodash": "^4.17.21", "lowdb": "^7.0.1", "mammoth": "^1.7.2", @@ -99,14 +99,14 @@ "turbowatch": "^2.29.4", "uncrypto": "^0.1.3", "zod": "^3.23.8", - "zod-openapi": "^2.17.0", + "zod-openapi": "^2.18.0", "zod-to-json-schema": "^3.23.0" }, "devDependencies": { - "@antfu/eslint-config": "^2.18.1", + "@antfu/eslint-config": "^2.19.1", "@total-typescript/ts-reset": "^0.5.1", "@types/lodash": "^4.17.4", - "@types/node": "^20.12.12", + "@types/node": "^20.12.13", "@types/nodemon": "^1.19.6", "@types/qs": "^6.9.15", "@types/ws": "^8.5.10", @@ -120,7 +120,7 @@ "tsup": "^8.0.2", "tsx": "^4.11.0", "typescript": "^5.4.5", - "typescript-eslint": "^7.10.0", + "typescript-eslint": "^7.11.0", "vite-tsconfig-paths": "^4.3.2", "vitest": "^1.6.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9503640..672ad94 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -34,28 +34,28 @@ dependencies: version: 9.0.0 '@langchain/anthropic': specifier: ^0.1.21 - version: 0.1.21 + version: 0.1.21(langchain@0.2.4) '@langchain/azure-openai': specifier: ^0.0.9 - version: 0.0.9 + version: 0.0.9(langchain@0.2.4) '@langchain/cohere': specifier: ^0.0.10 - version: 0.0.10 + version: 0.0.10(langchain@0.2.4) '@langchain/community': - specifier: ^0.2.2 - version: 0.2.2(@qdrant/js-client-rest@1.9.0)(cheerio@1.0.0-rc.12)(d3-dsv@2.0.0)(html-to-text@9.0.5)(lodash@4.17.21)(mammoth@1.7.2)(officeparser@4.1.1)(pdf-parse@1.1.1) + specifier: ^0.2.4 + version: 0.2.4(@qdrant/js-client-rest@1.9.0)(cheerio@1.0.0-rc.12)(d3-dsv@2.0.0)(html-to-text@9.0.5)(lodash@4.17.21)(mammoth@1.7.2)(officeparser@4.1.1)(pdf-parse@1.1.1) '@langchain/core': - specifier: ^0.2.0 - version: 0.2.0 + specifier: ^0.2.5 + version: 0.2.5(langchain@0.2.4) '@langchain/google-genai': specifier: ^0.0.16 - version: 0.0.16(zod@3.23.8) + version: 0.0.16(langchain@0.2.4)(zod@3.23.8) '@langchain/mistralai': - specifier: ^0.0.22 - version: 0.0.22 + specifier: ^0.0.23 + version: 0.0.23(langchain@0.2.4) '@langchain/openai': - specifier: ^0.0.33 - version: 0.0.33 + specifier: ^0.1.0 + version: 0.1.0(langchain@0.2.4) '@mgcrea/fastify-request-logger': specifier: ^1.6.0 version: 1.6.0 @@ -103,7 +103,7 @@ dependencies: version: 4.27.0 fastify-zod-openapi: specifier: ^1.2.0 - version: 1.2.0(fastify@4.27.0)(zod-openapi@2.17.0)(zod@3.23.8) + version: 1.2.0(fastify@4.27.0)(zod-openapi@2.18.0)(zod@3.23.8) get-port-please: specifier: ^3.1.2 version: 3.1.2 @@ -117,8 +117,8 @@ dependencies: specifier: ^1.0.12 version: 1.0.12 langchain: - specifier: ^0.2.2 - version: 0.2.2(cheerio@1.0.0-rc.12)(d3-dsv@2.0.0)(html-to-text@9.0.5)(mammoth@1.7.2)(officeparser@4.1.1)(pdf-parse@1.1.1) + specifier: ^0.2.4 + version: 0.2.4(cheerio@1.0.0-rc.12)(d3-dsv@2.0.0)(html-to-text@9.0.5)(mammoth@1.7.2)(officeparser@4.1.1)(pdf-parse@1.1.1) lodash: specifier: ^4.17.21 version: 4.17.21 @@ -156,16 +156,16 @@ dependencies: specifier: ^3.23.8 version: 3.23.8 zod-openapi: - specifier: ^2.17.0 - version: 2.17.0(zod@3.23.8) + specifier: ^2.18.0 + version: 2.18.0(zod@3.23.8) zod-to-json-schema: specifier: ^3.23.0 version: 3.23.0(zod@3.23.8) devDependencies: '@antfu/eslint-config': - specifier: ^2.18.1 - version: 2.18.1(@vue/compiler-sfc@3.4.21)(eslint-plugin-format@0.1.1)(eslint@8.57.0)(typescript@5.4.5)(vitest@1.6.0) + specifier: ^2.19.1 + version: 2.19.1(@vue/compiler-sfc@3.4.21)(eslint-plugin-format@0.1.1)(eslint@8.57.0)(typescript@5.4.5)(vitest@1.6.0) '@total-typescript/ts-reset': specifier: ^0.5.1 version: 0.5.1 @@ -173,8 +173,8 @@ devDependencies: specifier: ^4.17.4 version: 4.17.4 '@types/node': - specifier: ^20.12.12 - version: 20.12.12 + specifier: ^20.12.13 + version: 20.12.13 '@types/nodemon': specifier: ^1.19.6 version: 1.19.6 @@ -215,14 +215,14 @@ devDependencies: specifier: ^5.4.5 version: 5.4.5 typescript-eslint: - specifier: ^7.10.0 - version: 7.10.0(eslint@8.57.0)(typescript@5.4.5) + specifier: ^7.11.0 + version: 7.11.0(eslint@8.57.0)(typescript@5.4.5) vite-tsconfig-paths: specifier: ^4.3.2 version: 4.3.2(typescript@5.4.5) vitest: specifier: ^1.6.0 - version: 1.6.0(@types/node@20.12.12)(@vitest/ui@1.6.0) + version: 1.6.0(@types/node@20.12.13)(@vitest/ui@1.6.0) packages: @@ -231,8 +231,8 @@ packages: engines: {node: '>=0.10.0'} dev: true - /@antfu/eslint-config@2.18.1(@vue/compiler-sfc@3.4.21)(eslint-plugin-format@0.1.1)(eslint@8.57.0)(typescript@5.4.5)(vitest@1.6.0): - resolution: {integrity: sha512-6LkzQa96SHt47ZCvAcLJbQLUXmcpl9wI+eo5OeyB2YhHbsUBX7ufT0r4x6fx6Ci2694HRNLl8wY42LUvwidduw==} + /@antfu/eslint-config@2.19.1(@vue/compiler-sfc@3.4.21)(eslint-plugin-format@0.1.1)(eslint@8.57.0)(typescript@5.4.5)(vitest@1.6.0): + resolution: {integrity: sha512-gtiyWxoBnk39Vgf23xJiSQrq3esEGYesv7Q4IZXEJJaYSpyiJWHMYxlC6dFr4V9tAczDa7bZjR9E6XWEiU7VEA==} hasBin: true peerDependencies: '@eslint-react/eslint-plugin': ^1.5.8 @@ -280,39 +280,39 @@ packages: '@antfu/install-pkg': 0.3.3 '@clack/prompts': 0.7.0 '@stylistic/eslint-plugin': 2.1.0(eslint@8.57.0)(typescript@5.4.5) - '@typescript-eslint/eslint-plugin': 7.9.0(@typescript-eslint/parser@7.9.0)(eslint@8.57.0)(typescript@5.4.5) - '@typescript-eslint/parser': 7.9.0(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/eslint-plugin': 7.11.0(@typescript-eslint/parser@7.11.0)(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/parser': 7.11.0(eslint@8.57.0)(typescript@5.4.5) eslint: 8.57.0 eslint-config-flat-gitignore: 0.1.5 eslint-flat-config-utils: 0.2.5 eslint-merge-processors: 0.1.0(eslint@8.57.0) - eslint-plugin-antfu: 2.2.0(eslint@8.57.0) + eslint-plugin-antfu: 2.3.3(eslint@8.57.0) eslint-plugin-command: 0.2.3(eslint@8.57.0) eslint-plugin-eslint-comments: 3.2.0(eslint@8.57.0) eslint-plugin-format: 0.1.1(eslint@8.57.0) - eslint-plugin-import-x: 0.5.0(eslint@8.57.0)(typescript@5.4.5) - eslint-plugin-jsdoc: 48.2.5(eslint@8.57.0) - eslint-plugin-jsonc: 2.15.1(eslint@8.57.0) + eslint-plugin-import-x: 0.5.1(eslint@8.57.0)(typescript@5.4.5) + eslint-plugin-jsdoc: 48.2.7(eslint@8.57.0) + eslint-plugin-jsonc: 2.16.0(eslint@8.57.0) eslint-plugin-markdown: 5.0.0(eslint@8.57.0) eslint-plugin-n: 17.7.0(eslint@8.57.0) eslint-plugin-no-only-tests: 3.1.0 eslint-plugin-perfectionist: 2.10.0(eslint@8.57.0)(typescript@5.4.5)(vue-eslint-parser@9.4.2) - eslint-plugin-regexp: 2.5.0(eslint@8.57.0) + eslint-plugin-regexp: 2.6.0(eslint@8.57.0) eslint-plugin-toml: 0.11.0(eslint@8.57.0) eslint-plugin-unicorn: 53.0.0(eslint@8.57.0) - eslint-plugin-unused-imports: 3.2.0(@typescript-eslint/eslint-plugin@7.9.0)(eslint@8.57.0) - eslint-plugin-vitest: 0.5.4(@typescript-eslint/eslint-plugin@7.9.0)(eslint@8.57.0)(typescript@5.4.5)(vitest@1.6.0) + eslint-plugin-unused-imports: 3.2.0(@typescript-eslint/eslint-plugin@7.11.0)(eslint@8.57.0) + eslint-plugin-vitest: 0.5.4(@typescript-eslint/eslint-plugin@7.11.0)(eslint@8.57.0)(typescript@5.4.5)(vitest@1.6.0) eslint-plugin-vue: 9.26.0(eslint@8.57.0) eslint-plugin-yml: 1.14.0(eslint@8.57.0) eslint-processor-vue-blocks: 0.1.2(@vue/compiler-sfc@3.4.21)(eslint@8.57.0) - globals: 15.2.0 + globals: 15.3.0 jsonc-eslint-parser: 2.4.0 local-pkg: 0.5.0 parse-gitignore: 2.0.0 picocolors: 1.0.1 toml-eslint-parser: 0.9.3 vue-eslint-parser: 9.4.2(eslint@8.57.0) - yaml-eslint-parser: 1.2.2 + yaml-eslint-parser: 1.2.3 yargs: 17.7.2 transitivePeerDependencies: - '@vue/compiler-sfc' @@ -556,7 +556,19 @@ packages: dependencies: '@types/eslint': 8.56.10 '@types/estree': 1.0.5 - '@typescript-eslint/types': 7.9.0 + '@typescript-eslint/types': 7.10.0 + comment-parser: 1.4.1 + esquery: 1.5.0 + jsdoc-type-pratt-parser: 4.0.0 + dev: true + + /@es-joy/jsdoccomment@0.43.1: + resolution: {integrity: sha512-I238eDtOolvCuvtxrnqtlBaw0BwdQuYqK7eA6XIonicMdOOOb75mqdIzkGDUbS04+1Di007rgm9snFRNeVrOog==} + engines: {node: '>=16'} + dependencies: + '@types/eslint': 8.56.10 + '@types/estree': 1.0.5 + '@typescript-eslint/types': 7.10.0 comment-parser: 1.4.1 esquery: 1.5.0 jsdoc-type-pratt-parser: 4.0.0 @@ -1244,49 +1256,55 @@ packages: type-detect: 4.0.8 dev: true - /@langchain/anthropic@0.1.21: + /@langchain/anthropic@0.1.21(langchain@0.2.4): resolution: {integrity: sha512-7L5UDhO93UYfBwdaGxIqc5ZGSQ4wgMyYdENflLYhA9Aeho+BSHd0Krqh6zEHNGy4p+OrCElyDy58G8yiDEpxvw==} engines: {node: '>=18'} dependencies: '@anthropic-ai/sdk': 0.21.0 - '@langchain/core': 0.2.0 + '@langchain/core': 0.2.5(langchain@0.2.4) fast-xml-parser: 4.3.5 zod: 3.23.8 zod-to-json-schema: 3.23.0(zod@3.23.8) transitivePeerDependencies: - encoding + - langchain + - openai dev: false - /@langchain/azure-openai@0.0.9: + /@langchain/azure-openai@0.0.9(langchain@0.2.4): resolution: {integrity: sha512-PQZduFxccWHqN2LYL40imHCunuKqR9eZr18hqaXkD2lexMCIpAXXOWCIzbYmLX4FJUGtWSZyp4fl5NDYApcvuw==} engines: {node: '>=18'} dependencies: '@azure/core-auth': 1.6.0 '@azure/openai': 1.0.0-beta.11 - '@langchain/core': 0.2.0 + '@langchain/core': 0.2.5(langchain@0.2.4) js-tiktoken: 1.0.12 zod: 3.23.8 zod-to-json-schema: 3.20.3(zod@3.23.8) transitivePeerDependencies: + - langchain + - openai - supports-color dev: false - /@langchain/cohere@0.0.10: + /@langchain/cohere@0.0.10(langchain@0.2.4): resolution: {integrity: sha512-qGeYeDKu6Itago3uSmVPjYD7BjHnA5miCYT3v4oRTXz2mDON4IrQit6Uk5dERLSrMKOrHCnRE9LYJEAyvo0s0Q==} engines: {node: '>=18'} dependencies: - '@langchain/core': 0.2.0 + '@langchain/core': 0.2.5(langchain@0.2.4) cohere-ai: 7.9.5 transitivePeerDependencies: - encoding + - langchain + - openai dev: false - /@langchain/community@0.2.2(@qdrant/js-client-rest@1.9.0)(cheerio@1.0.0-rc.12)(d3-dsv@2.0.0)(html-to-text@9.0.5)(lodash@4.17.21)(mammoth@1.7.2)(officeparser@4.1.1)(pdf-parse@1.1.1): - resolution: {integrity: sha512-TtlZnPBYt7Sujc1hAYvdZKUmV97wuF15O7b4nBX4lBfQeW38N0DwGbhqpitDbpaJqZ2s8DM4rjapECk0kIdAww==} + /@langchain/community@0.2.4(@qdrant/js-client-rest@1.9.0)(cheerio@1.0.0-rc.12)(d3-dsv@2.0.0)(html-to-text@9.0.5)(lodash@4.17.21)(mammoth@1.7.2)(officeparser@4.1.1)(pdf-parse@1.1.1): + resolution: {integrity: sha512-rwrPNQLyIe84TPqPYbYOfDA4G/ba1rdj7OtZg63dQmxIvNDOmUCh4xIQac2iuRUnM3o4Ben0Faa9qz+V5oPgIA==} engines: {node: '>=18'} peerDependencies: '@aws-crypto/sha256-js': ^5.0.0 - '@aws-sdk/client-bedrock-agent-runtime': ^3.485.0 + '@aws-sdk/client-bedrock-agent-runtime': ^3.583.0 '@aws-sdk/client-bedrock-runtime': ^3.422.0 '@aws-sdk/client-dynamodb': ^3.310.0 '@aws-sdk/client-kendra': ^3.352.0 @@ -1303,10 +1321,11 @@ packages: '@datastax/astra-db-ts': ^1.0.0 '@elastic/elasticsearch': ^8.4.0 '@getmetal/metal-sdk': '*' + '@getzep/zep-cloud': '*' '@getzep/zep-js': ^0.9.0 '@gomomento/sdk': ^1.51.1 '@gomomento/sdk-core': ^1.51.1 - '@google-ai/generativelanguage': ^0.2.1 + '@google-ai/generativelanguage': '*' '@google-cloud/storage': ^6.10.1 || ^7.7.0 '@gradientai/nodejs-sdk': ^1.2.0 '@huggingface/inference': ^2.6.4 @@ -1333,8 +1352,9 @@ packages: '@tensorflow-models/universal-sentence-encoder': '*' '@tensorflow/tfjs-converter': '*' '@tensorflow/tfjs-core': '*' + '@upstash/ratelimit': ^1.1.3 '@upstash/redis': ^1.20.6 - '@upstash/vector': ^1.0.7 + '@upstash/vector': ^1.1.1 '@vercel/kv': ^0.2.3 '@vercel/postgres': ^0.5.0 '@writerai/writer-sdk': ^0.40.2 @@ -1361,7 +1381,7 @@ packages: epub2: ^3.0.1 faiss-node: ^0.5.1 firebase-admin: ^11.9.0 || ^12.0.0 - google-auth-library: ^8.9.0 + google-auth-library: '*' googleapis: ^126.0.1 hnswlib-node: ^3.0.0 html-to-text: ^9.0.5 @@ -1389,7 +1409,7 @@ packages: portkey-ai: ^0.1.11 puppeteer: ^19.7.2 redis: '*' - replicate: ^0.18.0 + replicate: ^0.29.4 sonix-speech-recognition: ^2.1.1 srt-parser-2: ^1.2.3 typeorm: ^0.3.12 @@ -1439,6 +1459,8 @@ packages: optional: true '@getmetal/metal-sdk': optional: true + '@getzep/zep-cloud': + optional: true '@getzep/zep-js': optional: true '@gomomento/sdk': @@ -1499,6 +1521,8 @@ packages: optional: true '@tensorflow/tfjs-core': optional: true + '@upstash/ratelimit': + optional: true '@upstash/redis': optional: true '@upstash/vector': @@ -1638,8 +1662,8 @@ packages: youtubei.js: optional: true dependencies: - '@langchain/core': 0.2.0 - '@langchain/openai': 0.0.33 + '@langchain/core': 0.2.5(langchain@0.2.3) + '@langchain/openai': 0.0.33(langchain@0.2.3) '@qdrant/js-client-rest': 1.9.0(typescript@5.4.5) binary-extensions: 2.2.0 cheerio: 1.0.0-rc.12 @@ -1648,7 +1672,7 @@ packages: flat: 5.0.2 html-to-text: 9.0.5 js-yaml: 4.1.0 - langchain: 0.2.2(cheerio@1.0.0-rc.12)(d3-dsv@2.0.0)(html-to-text@9.0.5)(mammoth@1.7.2)(officeparser@4.1.1)(pdf-parse@1.1.1) + langchain: 0.2.3(cheerio@1.0.0-rc.12)(d3-dsv@2.0.0)(html-to-text@9.0.5)(mammoth@1.7.2)(officeparser@4.1.1)(pdf-parse@1.1.1) langsmith: 0.1.13 lodash: 4.17.21 mammoth: 1.7.2 @@ -1663,11 +1687,12 @@ packages: - encoding - fast-xml-parser - handlebars + - openai - peggy - pyodide dev: false - /@langchain/core@0.1.63: + /@langchain/core@0.1.63(langchain@0.2.3): resolution: {integrity: sha512-+fjyYi8wy6x1P+Ee1RWfIIEyxd9Ee9jksEwvrggPwwI/p45kIDTdYTblXsM13y4mNWTiACyLSdbwnPaxxdoz+w==} engines: {node: '>=18'} dependencies: @@ -1675,7 +1700,7 @@ packages: camelcase: 6.3.0 decamelize: 1.2.0 js-tiktoken: 1.0.12 - langsmith: 0.1.13 + langsmith: 0.1.30(@langchain/core@0.1.63)(langchain@0.2.3) ml-distance: 4.0.1 mustache: 4.2.0 p-queue: 6.6.2 @@ -1683,17 +1708,20 @@ packages: uuid: 9.0.1 zod: 3.23.8 zod-to-json-schema: 3.23.0(zod@3.23.8) + transitivePeerDependencies: + - langchain + - openai dev: false - /@langchain/core@0.2.0: - resolution: {integrity: sha512-UbCJUp9eh2JXd9AW/vhPbTgtZoMgTqJgSan5Wf/EP27X8JM65lWdCOpJW+gHyBXvabbyrZz3/EGaptTUL5gutw==} + /@langchain/core@0.1.63(langchain@0.2.4): + resolution: {integrity: sha512-+fjyYi8wy6x1P+Ee1RWfIIEyxd9Ee9jksEwvrggPwwI/p45kIDTdYTblXsM13y4mNWTiACyLSdbwnPaxxdoz+w==} engines: {node: '>=18'} dependencies: ansi-styles: 5.2.0 camelcase: 6.3.0 decamelize: 1.2.0 js-tiktoken: 1.0.12 - langsmith: 0.1.13 + langsmith: 0.1.30(@langchain/core@0.1.63)(langchain@0.2.4) ml-distance: 4.0.1 mustache: 4.2.0 p-queue: 6.6.2 @@ -1701,51 +1729,171 @@ packages: uuid: 9.0.1 zod: 3.23.8 zod-to-json-schema: 3.23.0(zod@3.23.8) + transitivePeerDependencies: + - langchain + - openai dev: false - /@langchain/google-genai@0.0.16(zod@3.23.8): + /@langchain/core@0.2.5(langchain@0.2.3): + resolution: {integrity: sha512-tMaKRFVewFn8crQwlbXGjT7hlMdX1yXHap1ebBx7Bb2C3C9AeZ+sXbX11m27yamypNlVVegwUcisw3YCaDkZJA==} + engines: {node: '>=18'} + dependencies: + ansi-styles: 5.2.0 + camelcase: 6.3.0 + decamelize: 1.2.0 + js-tiktoken: 1.0.12 + langsmith: 0.1.30(@langchain/core@0.2.5)(langchain@0.2.3) + ml-distance: 4.0.1 + mustache: 4.2.0 + p-queue: 6.6.2 + p-retry: 4.6.2 + uuid: 9.0.1 + zod: 3.23.8 + zod-to-json-schema: 3.23.0(zod@3.23.8) + transitivePeerDependencies: + - langchain + - openai + dev: false + + /@langchain/core@0.2.5(langchain@0.2.3)(openai@4.47.1): + resolution: {integrity: sha512-tMaKRFVewFn8crQwlbXGjT7hlMdX1yXHap1ebBx7Bb2C3C9AeZ+sXbX11m27yamypNlVVegwUcisw3YCaDkZJA==} + engines: {node: '>=18'} + dependencies: + ansi-styles: 5.2.0 + camelcase: 6.3.0 + decamelize: 1.2.0 + js-tiktoken: 1.0.12 + langsmith: 0.1.30(@langchain/core@0.2.5)(langchain@0.2.3)(openai@4.47.1) + ml-distance: 4.0.1 + mustache: 4.2.0 + p-queue: 6.6.2 + p-retry: 4.6.2 + uuid: 9.0.1 + zod: 3.23.8 + zod-to-json-schema: 3.23.0(zod@3.23.8) + transitivePeerDependencies: + - langchain + - openai + dev: false + + /@langchain/core@0.2.5(langchain@0.2.4): + resolution: {integrity: sha512-tMaKRFVewFn8crQwlbXGjT7hlMdX1yXHap1ebBx7Bb2C3C9AeZ+sXbX11m27yamypNlVVegwUcisw3YCaDkZJA==} + engines: {node: '>=18'} + dependencies: + ansi-styles: 5.2.0 + camelcase: 6.3.0 + decamelize: 1.2.0 + js-tiktoken: 1.0.12 + langsmith: 0.1.30(@langchain/core@0.2.5)(langchain@0.2.4) + ml-distance: 4.0.1 + mustache: 4.2.0 + p-queue: 6.6.2 + p-retry: 4.6.2 + uuid: 9.0.1 + zod: 3.23.8 + zod-to-json-schema: 3.23.0(zod@3.23.8) + transitivePeerDependencies: + - langchain + - openai + dev: false + + /@langchain/core@0.2.5(langchain@0.2.4)(openai@4.47.1): + resolution: {integrity: sha512-tMaKRFVewFn8crQwlbXGjT7hlMdX1yXHap1ebBx7Bb2C3C9AeZ+sXbX11m27yamypNlVVegwUcisw3YCaDkZJA==} + engines: {node: '>=18'} + dependencies: + ansi-styles: 5.2.0 + camelcase: 6.3.0 + decamelize: 1.2.0 + js-tiktoken: 1.0.12 + langsmith: 0.1.30(@langchain/core@0.2.5)(langchain@0.2.4)(openai@4.47.1) + ml-distance: 4.0.1 + mustache: 4.2.0 + p-queue: 6.6.2 + p-retry: 4.6.2 + uuid: 9.0.1 + zod: 3.23.8 + zod-to-json-schema: 3.23.0(zod@3.23.8) + transitivePeerDependencies: + - langchain + - openai + dev: false + + /@langchain/google-genai@0.0.16(langchain@0.2.4)(zod@3.23.8): resolution: {integrity: sha512-aUHEeY7sTwxNqj7L5scvnOhNLOKPVSvf7HR6p1Y3M7BPyU63fXP7faB+qyuHmibtKU8pj+ApoXPpjRflYKSv4w==} engines: {node: '>=18'} dependencies: '@google/generative-ai': 0.7.1 - '@langchain/core': 0.2.0 + '@langchain/core': 0.2.5(langchain@0.2.4) zod-to-json-schema: 3.23.0(zod@3.23.8) transitivePeerDependencies: + - langchain + - openai - zod dev: false - /@langchain/mistralai@0.0.22: - resolution: {integrity: sha512-cZ+HBz32Gq2zjkXcDs5hDnr8W0QxlRXhWAXu9zepwzLNe3aXxAD/lhz9l654o2fo89bqnuhtYgbGx8ZVYcDvCw==} + /@langchain/mistralai@0.0.23(langchain@0.2.4): + resolution: {integrity: sha512-0huhT3KXqrD1u20e2NWpBlprBoNidw4Q4hjBI9DySCb1Gx4wSIV6y8kswsWRfM1VDBZvJcCVLeVuOSAyShoFug==} engines: {node: '>=18'} dependencies: - '@langchain/core': 0.2.0 - '@mistralai/mistralai': 0.1.3 + '@langchain/core': 0.2.5(langchain@0.2.4) + '@mistralai/mistralai': 0.4.0 uuid: 9.0.1 zod: 3.23.8 zod-to-json-schema: 3.23.0(zod@3.23.8) transitivePeerDependencies: - encoding + - langchain + - openai dev: false - /@langchain/openai@0.0.33: + /@langchain/openai@0.0.33(langchain@0.2.3): resolution: {integrity: sha512-hTBo9y9bHtFvMT5ySBW7TrmKhLSA91iNahigeqAFBVrLmBDz+6rzzLFc1mpq6JEAR3fZKdaUXqso3nB23jIpTw==} engines: {node: '>=18'} dependencies: - '@langchain/core': 0.2.0 + '@langchain/core': 0.2.5(langchain@0.2.3)(openai@4.47.1) + js-tiktoken: 1.0.12 + openai: 4.47.1 + zod: 3.23.8 + zod-to-json-schema: 3.23.0(zod@3.23.8) + transitivePeerDependencies: + - encoding + - langchain + dev: false + + /@langchain/openai@0.1.0(langchain@0.2.4): + resolution: {integrity: sha512-jm7U9oxXQ2N03q3+S9CzEAmMJaL2FqdAi4bOYdEBS0aAWAU29so35ZOs5i2uu4W29mK9oV9XS/4A5ggR1gOLEA==} + engines: {node: '>=18'} + dependencies: + '@langchain/core': 0.2.5(langchain@0.2.4)(openai@4.47.1) js-tiktoken: 1.0.12 openai: 4.47.1 zod: 3.23.8 zod-to-json-schema: 3.23.0(zod@3.23.8) transitivePeerDependencies: - encoding + - langchain dev: false - /@langchain/textsplitters@0.0.0: + /@langchain/textsplitters@0.0.0(langchain@0.2.3): resolution: {integrity: sha512-3hPesWomnmVeYMppEGYbyv0v/sRUugUdlFBNn9m1ueJYHAIKbvCErkWxNUH3guyKKYgJVrkvZoQxcd9faucSaw==} engines: {node: '>=18'} dependencies: - '@langchain/core': 0.1.63 + '@langchain/core': 0.1.63(langchain@0.2.3) js-tiktoken: 1.0.12 + transitivePeerDependencies: + - langchain + - openai + dev: false + + /@langchain/textsplitters@0.0.0(langchain@0.2.4): + resolution: {integrity: sha512-3hPesWomnmVeYMppEGYbyv0v/sRUugUdlFBNn9m1ueJYHAIKbvCErkWxNUH3guyKKYgJVrkvZoQxcd9faucSaw==} + engines: {node: '>=18'} + dependencies: + '@langchain/core': 0.1.63(langchain@0.2.4) + js-tiktoken: 1.0.12 + transitivePeerDependencies: + - langchain + - openai dev: false /@lukeed/ms@2.0.1: @@ -1768,8 +1916,8 @@ packages: pino-pretty: 10.2.3 dev: false - /@mistralai/mistralai@0.1.3: - resolution: {integrity: sha512-WUHxC2xdeqX9PTXJEqdiNY54vT2ir72WSJrZTTBKRnkfhX6zIfCYA24faRlWjUB5WTpn+wfdGsTMl3ArijlXFA==} + /@mistralai/mistralai@0.4.0: + resolution: {integrity: sha512-KmFzNro1RKxIFh19J3osmUQhucefBBauMXN5fa9doG6dT9OHR/moBvvn+riVlR7c0AVfuxO8Dfa03AyLYYzbyg==} dependencies: node-fetch: 2.7.0 transitivePeerDependencies: @@ -2098,7 +2246,7 @@ packages: eslint: '*' dependencies: '@types/eslint': 8.56.10 - '@typescript-eslint/utils': 7.9.0(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/utils': 7.10.0(eslint@8.57.0)(typescript@5.4.5) eslint: 8.57.0 transitivePeerDependencies: - supports-color @@ -2113,7 +2261,7 @@ packages: dependencies: '@stylistic/eslint-plugin-js': 2.1.0(eslint@8.57.0) '@types/eslint': 8.56.10 - '@typescript-eslint/utils': 7.9.0(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/utils': 7.10.0(eslint@8.57.0)(typescript@5.4.5) eslint: 8.57.0 transitivePeerDependencies: - supports-color @@ -2165,7 +2313,7 @@ packages: resolution: {integrity: sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==} dependencies: '@types/jsonfile': 6.1.4 - '@types/node': 20.12.12 + '@types/node': 20.12.13 dev: false /@types/json-schema@7.0.15: @@ -2175,7 +2323,7 @@ packages: /@types/jsonfile@6.1.4: resolution: {integrity: sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==} dependencies: - '@types/node': 20.12.12 + '@types/node': 20.12.13 dev: false /@types/lodash@4.17.4: @@ -2195,7 +2343,7 @@ packages: /@types/node-fetch@2.6.7: resolution: {integrity: sha512-lX17GZVpJ/fuCjguZ5b3TjEbSENxmEk1B2z02yoXSK9WMEWRivhdSY73wWMn6bpcCDAOh6qAdktpKHIlkDk2lg==} dependencies: - '@types/node': 20.12.12 + '@types/node': 20.12.13 form-data: 4.0.0 dev: false @@ -2205,15 +2353,15 @@ packages: undici-types: 5.26.5 dev: false - /@types/node@20.12.12: - resolution: {integrity: sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==} + /@types/node@20.12.13: + resolution: {integrity: sha512-gBGeanV41c1L171rR7wjbMiEpEI/l5XFQdLLfhr/REwpgDy/4U8y89+i8kRiLzDyZdOkXh+cRaTetUnCYutoXA==} dependencies: undici-types: 5.26.5 /@types/nodemon@1.19.6: resolution: {integrity: sha512-vjKuaQOLUA5EY2zkUmWG1ipXbKt9Wd+H/0SiIuHVeH4cHtt6509iRUGH9ZR0iqgUrtj3BrP9KqoTuV3ZCbQcYA==} dependencies: - '@types/node': 20.12.12 + '@types/node': 20.12.13 dev: true /@types/normalize-package-data@2.4.3: @@ -2251,38 +2399,11 @@ packages: /@types/ws@8.5.10: resolution: {integrity: sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==} dependencies: - '@types/node': 20.12.12 - dev: true - - /@typescript-eslint/eslint-plugin@7.10.0(@typescript-eslint/parser@7.10.0)(eslint@8.57.0)(typescript@5.4.5): - resolution: {integrity: sha512-PzCr+a/KAef5ZawX7nbyNwBDtM1HdLIT53aSA2DDlxmxMngZ43O8SIePOeX8H5S+FHXeI6t97mTt/dDdzY4Fyw==} - engines: {node: ^18.18.0 || >=20.0.0} - peerDependencies: - '@typescript-eslint/parser': ^7.0.0 - eslint: ^8.56.0 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@eslint-community/regexpp': 4.10.0 - '@typescript-eslint/parser': 7.10.0(eslint@8.57.0)(typescript@5.4.5) - '@typescript-eslint/scope-manager': 7.10.0 - '@typescript-eslint/type-utils': 7.10.0(eslint@8.57.0)(typescript@5.4.5) - '@typescript-eslint/utils': 7.10.0(eslint@8.57.0)(typescript@5.4.5) - '@typescript-eslint/visitor-keys': 7.10.0 - eslint: 8.57.0 - graphemer: 1.4.0 - ignore: 5.3.1 - natural-compare: 1.4.0 - ts-api-utils: 1.3.0(typescript@5.4.5) - typescript: 5.4.5 - transitivePeerDependencies: - - supports-color + '@types/node': 20.12.13 dev: true - /@typescript-eslint/eslint-plugin@7.9.0(@typescript-eslint/parser@7.9.0)(eslint@8.57.0)(typescript@5.4.5): - resolution: {integrity: sha512-6e+X0X3sFe/G/54aC3jt0txuMTURqLyekmEHViqyA2VnxhLMpvA6nqmcjIy+Cr9tLDHPssA74BP5Mx9HQIxBEA==} + /@typescript-eslint/eslint-plugin@7.11.0(@typescript-eslint/parser@7.11.0)(eslint@8.57.0)(typescript@5.4.5): + resolution: {integrity: sha512-P+qEahbgeHW4JQ/87FuItjBj8O3MYv5gELDzr8QaQ7fsll1gSMTYb6j87MYyxwf3DtD7uGFB9ShwgmCJB5KmaQ==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: '@typescript-eslint/parser': ^7.0.0 @@ -2293,11 +2414,11 @@ packages: optional: true dependencies: '@eslint-community/regexpp': 4.10.0 - '@typescript-eslint/parser': 7.9.0(eslint@8.57.0)(typescript@5.4.5) - '@typescript-eslint/scope-manager': 7.9.0 - '@typescript-eslint/type-utils': 7.9.0(eslint@8.57.0)(typescript@5.4.5) - '@typescript-eslint/utils': 7.9.0(eslint@8.57.0)(typescript@5.4.5) - '@typescript-eslint/visitor-keys': 7.9.0 + '@typescript-eslint/parser': 7.11.0(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/scope-manager': 7.11.0 + '@typescript-eslint/type-utils': 7.11.0(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/utils': 7.11.0(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/visitor-keys': 7.11.0 eslint: 8.57.0 graphemer: 1.4.0 ignore: 5.3.1 @@ -2308,8 +2429,8 @@ packages: - supports-color dev: true - /@typescript-eslint/parser@7.10.0(eslint@8.57.0)(typescript@5.4.5): - resolution: {integrity: sha512-2EjZMA0LUW5V5tGQiaa2Gys+nKdfrn2xiTIBLR4fxmPmVSvgPcKNW+AE/ln9k0A4zDUti0J/GZXMDupQoI+e1w==} + /@typescript-eslint/parser@7.11.0(eslint@8.57.0)(typescript@5.4.5): + resolution: {integrity: sha512-yimw99teuaXVWsBcPO1Ais02kwJ1jmNA1KxE7ng0aT7ndr1pT1wqj0OJnsYVGKKlc4QJai86l/025L6z8CljOg==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: eslint: ^8.56.0 @@ -2318,31 +2439,10 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 7.10.0 - '@typescript-eslint/types': 7.10.0 - '@typescript-eslint/typescript-estree': 7.10.0(typescript@5.4.5) - '@typescript-eslint/visitor-keys': 7.10.0 - debug: 4.3.4(supports-color@5.5.0) - eslint: 8.57.0 - typescript: 5.4.5 - transitivePeerDependencies: - - supports-color - dev: true - - /@typescript-eslint/parser@7.9.0(eslint@8.57.0)(typescript@5.4.5): - resolution: {integrity: sha512-qHMJfkL5qvgQB2aLvhUSXxbK7OLnDkwPzFalg458pxQgfxKDfT1ZDbHQM/I6mDIf/svlMkj21kzKuQ2ixJlatQ==} - engines: {node: ^18.18.0 || >=20.0.0} - peerDependencies: - eslint: ^8.56.0 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@typescript-eslint/scope-manager': 7.9.0 - '@typescript-eslint/types': 7.9.0 - '@typescript-eslint/typescript-estree': 7.9.0(typescript@5.4.5) - '@typescript-eslint/visitor-keys': 7.9.0 + '@typescript-eslint/scope-manager': 7.11.0 + '@typescript-eslint/types': 7.11.0 + '@typescript-eslint/typescript-estree': 7.11.0(typescript@5.4.5) + '@typescript-eslint/visitor-keys': 7.11.0 debug: 4.3.4(supports-color@5.5.0) eslint: 8.57.0 typescript: 5.4.5 @@ -2366,16 +2466,16 @@ packages: '@typescript-eslint/visitor-keys': 7.10.0 dev: true - /@typescript-eslint/scope-manager@7.9.0: - resolution: {integrity: sha512-ZwPK4DeCDxr3GJltRz5iZejPFAAr4Wk3+2WIBaj1L5PYK5RgxExu/Y68FFVclN0y6GGwH8q+KgKRCvaTmFBbgQ==} + /@typescript-eslint/scope-manager@7.11.0: + resolution: {integrity: sha512-27tGdVEiutD4POirLZX4YzT180vevUURJl4wJGmm6TrQoiYwuxTIY98PBp6L2oN+JQxzE0URvYlzJaBHIekXAw==} engines: {node: ^18.18.0 || >=20.0.0} dependencies: - '@typescript-eslint/types': 7.9.0 - '@typescript-eslint/visitor-keys': 7.9.0 + '@typescript-eslint/types': 7.11.0 + '@typescript-eslint/visitor-keys': 7.11.0 dev: true - /@typescript-eslint/type-utils@7.10.0(eslint@8.57.0)(typescript@5.4.5): - resolution: {integrity: sha512-D7tS4WDkJWrVkuzgm90qYw9RdgBcrWmbbRkrLA4d7Pg3w0ttVGDsvYGV19SH8gPR5L7OtcN5J1hTtyenO9xE9g==} + /@typescript-eslint/type-utils@7.11.0(eslint@8.57.0)(typescript@5.4.5): + resolution: {integrity: sha512-WmppUEgYy+y1NTseNMJ6mCFxt03/7jTOy08bcg7bxJJdsM4nuhnchyBbE8vryveaJUf62noH7LodPSo5Z0WUCg==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: eslint: ^8.56.0 @@ -2384,28 +2484,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 7.10.0(typescript@5.4.5) - '@typescript-eslint/utils': 7.10.0(eslint@8.57.0)(typescript@5.4.5) - debug: 4.3.4(supports-color@5.5.0) - eslint: 8.57.0 - ts-api-utils: 1.3.0(typescript@5.4.5) - typescript: 5.4.5 - transitivePeerDependencies: - - supports-color - dev: true - - /@typescript-eslint/type-utils@7.9.0(eslint@8.57.0)(typescript@5.4.5): - resolution: {integrity: sha512-6Qy8dfut0PFrFRAZsGzuLoM4hre4gjzWJB6sUvdunCYZsYemTkzZNwF1rnGea326PHPT3zn5Lmg32M/xfJfByA==} - engines: {node: ^18.18.0 || >=20.0.0} - peerDependencies: - eslint: ^8.56.0 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@typescript-eslint/typescript-estree': 7.9.0(typescript@5.4.5) - '@typescript-eslint/utils': 7.9.0(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/typescript-estree': 7.11.0(typescript@5.4.5) + '@typescript-eslint/utils': 7.11.0(eslint@8.57.0)(typescript@5.4.5) debug: 4.3.4(supports-color@5.5.0) eslint: 8.57.0 ts-api-utils: 1.3.0(typescript@5.4.5) @@ -2424,8 +2504,8 @@ packages: engines: {node: ^18.18.0 || >=20.0.0} dev: true - /@typescript-eslint/types@7.9.0: - resolution: {integrity: sha512-oZQD9HEWQanl9UfsbGVcZ2cGaR0YT5476xfWE0oE5kQa2sNK2frxOlkeacLOTh9po4AlUT5rtkGyYM5kew0z5w==} + /@typescript-eslint/types@7.11.0: + resolution: {integrity: sha512-MPEsDRZTyCiXkD4vd3zywDCifi7tatc4K37KqTprCvaXptP7Xlpdw0NR2hRJTetG5TxbWDB79Ys4kLmHliEo/w==} engines: {node: ^18.18.0 || >=20.0.0} dev: true @@ -2472,8 +2552,8 @@ packages: - supports-color dev: true - /@typescript-eslint/typescript-estree@7.9.0(typescript@5.4.5): - resolution: {integrity: sha512-zBCMCkrb2YjpKV3LA0ZJubtKCDxLttxfdGmwZvTqqWevUPN0FZvSI26FalGFFUZU/9YQK/A4xcQF9o/VVaCKAg==} + /@typescript-eslint/typescript-estree@7.11.0(typescript@5.4.5): + resolution: {integrity: sha512-cxkhZ2C/iyi3/6U9EPc5y+a6csqHItndvN/CzbNXTNrsC3/ASoYQZEt9uMaEp+xFNjasqQyszp5TumAVKKvJeQ==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: typescript: '*' @@ -2481,8 +2561,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 7.9.0 - '@typescript-eslint/visitor-keys': 7.9.0 + '@typescript-eslint/types': 7.11.0 + '@typescript-eslint/visitor-keys': 7.11.0 debug: 4.3.4(supports-color@5.5.0) globby: 11.1.0 is-glob: 4.0.3 @@ -2530,16 +2610,16 @@ packages: - typescript dev: true - /@typescript-eslint/utils@7.9.0(eslint@8.57.0)(typescript@5.4.5): - resolution: {integrity: sha512-5KVRQCzZajmT4Ep+NEgjXCvjuypVvYHUW7RHlXzNPuak2oWpVoD1jf5xCP0dPAuNIchjC7uQyvbdaSTFaLqSdA==} + /@typescript-eslint/utils@7.11.0(eslint@8.57.0)(typescript@5.4.5): + resolution: {integrity: sha512-xlAWwPleNRHwF37AhrZurOxA1wyXowW4PqVXZVUNCLjB48CqdPJoJWkrpH2nij9Q3Lb7rtWindtoXwxjxlKKCA==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: eslint: ^8.56.0 dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) - '@typescript-eslint/scope-manager': 7.9.0 - '@typescript-eslint/types': 7.9.0 - '@typescript-eslint/typescript-estree': 7.9.0(typescript@5.4.5) + '@typescript-eslint/scope-manager': 7.11.0 + '@typescript-eslint/types': 7.11.0 + '@typescript-eslint/typescript-estree': 7.11.0(typescript@5.4.5) eslint: 8.57.0 transitivePeerDependencies: - supports-color @@ -2562,11 +2642,11 @@ packages: eslint-visitor-keys: 3.4.3 dev: true - /@typescript-eslint/visitor-keys@7.9.0: - resolution: {integrity: sha512-iESPx2TNLDNGQLyjKhUvIKprlP49XNEK+MvIf9nIO7ZZaZdbnfWKHnXAgufpxqfA0YryH8XToi4+CjBgVnFTSQ==} + /@typescript-eslint/visitor-keys@7.11.0: + resolution: {integrity: sha512-7syYk4MzjxTEk0g/w3iqtgxnFQspDJfn6QKD36xMuuhTzjcxY7F8EmBLnALjVyaOF1/bVocu3bS/2/F7rXrveQ==} engines: {node: ^18.18.0 || >=20.0.0} dependencies: - '@typescript-eslint/types': 7.9.0 + '@typescript-eslint/types': 7.11.0 eslint-visitor-keys: 3.4.3 dev: true @@ -2616,7 +2696,7 @@ packages: pathe: 1.1.2 picocolors: 1.0.0 sirv: 2.0.4 - vitest: 1.6.0(@types/node@20.12.12)(@vitest/ui@1.6.0) + vitest: 1.6.0(@types/node@20.12.13)(@vitest/ui@1.6.0) dev: true /@vitest/utils@1.6.0: @@ -3731,8 +3811,8 @@ packages: resolution: {integrity: sha512-oOeA6FWU0UJT/Rxc3XF5Cq0nbIZbylm7j8+plqq0CZoE6m4u32OXJrR+9iy4srGMmF6v6pmgvP1zPxSRIGh3sg==} dev: true - /eslint-plugin-antfu@2.2.0(eslint@8.57.0): - resolution: {integrity: sha512-QHzHYP+fyfhSkIdcuT9JZ4rCPuJOoHRE27gglPYHlJ6lxB7pO9i45yAy4aurx/rleBuEC27U4c//1Nwtbasj4Q==} + /eslint-plugin-antfu@2.3.3(eslint@8.57.0): + resolution: {integrity: sha512-TAgYNuc20QyKw8NXtpzR3LeMTTv1qAJVKkjCVzjRSGiSR1EetEY7LRgQVhcgP/C1FnI87isQERAIkKvkYyLq0Q==} peerDependencies: eslint: '*' dependencies: @@ -3787,13 +3867,13 @@ packages: synckit: 0.9.0 dev: true - /eslint-plugin-import-x@0.5.0(eslint@8.57.0)(typescript@5.4.5): - resolution: {integrity: sha512-C7R8Z4IzxmsoOPMtSzwuOBW5FH6iRlxHR6iTks+MzVlrk3r3TUxokkWTx3ypdj9nGOEP+CG/5e6ebZzHbxgbbQ==} + /eslint-plugin-import-x@0.5.1(eslint@8.57.0)(typescript@5.4.5): + resolution: {integrity: sha512-2JK8bbFOLes+gG6tgdnM8safCxMAj4u2wjX8X1BRFPfnY7Ct2hFYESoIcVwABX/DDcdpQFLGtKmzbNEWJZD9iQ==} engines: {node: '>=16'} peerDependencies: eslint: ^8.56.0 || ^9.0.0-0 dependencies: - '@typescript-eslint/utils': 7.9.0(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/utils': 7.10.0(eslint@8.57.0)(typescript@5.4.5) debug: 4.3.4(supports-color@5.5.0) doctrine: 3.0.0 eslint: 8.57.0 @@ -3802,33 +3882,33 @@ packages: is-glob: 4.0.3 minimatch: 9.0.4 semver: 7.6.2 + tslib: 2.6.2 transitivePeerDependencies: - supports-color - typescript dev: true - /eslint-plugin-jsdoc@48.2.5(eslint@8.57.0): - resolution: {integrity: sha512-ZeTfKV474W1N9niWfawpwsXGu+ZoMXu4417eBROX31d7ZuOk8zyG66SO77DpJ2+A9Wa2scw/jRqBPnnQo7VbcQ==} + /eslint-plugin-jsdoc@48.2.7(eslint@8.57.0): + resolution: {integrity: sha512-fYj3roTnkFL9OFFTB129rico8lerC5G8Vp2ZW9SjO9RNWG0exVvI+i/Y8Bpm1ufjR0uvT38xtoab/U0Hp8Ybog==} engines: {node: '>=18'} peerDependencies: eslint: ^7.0.0 || ^8.0.0 || ^9.0.0 dependencies: - '@es-joy/jsdoccomment': 0.43.0 + '@es-joy/jsdoccomment': 0.43.1 are-docs-informative: 0.0.2 comment-parser: 1.4.1 debug: 4.3.4(supports-color@5.5.0) escape-string-regexp: 4.0.0 eslint: 8.57.0 esquery: 1.5.0 - is-builtin-module: 3.2.1 semver: 7.6.2 spdx-expression-parse: 4.0.0 transitivePeerDependencies: - supports-color dev: true - /eslint-plugin-jsonc@2.15.1(eslint@8.57.0): - resolution: {integrity: sha512-PVFrqIJa8BbM/e828RSn0SwB/Z5ye+2LDuy2XqG6AymNgPsfApRRcznsbxP7VrjdLEU4Nb+g9n/d6opyp0jp9A==} + /eslint-plugin-jsonc@2.16.0(eslint@8.57.0): + resolution: {integrity: sha512-Af/ZL5mgfb8FFNleH6KlO4/VdmDuTqmM+SPnWcdoWywTetv7kq+vQe99UyQb9XO3b0OWLVuTH7H0d/PXYCMdSg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: '>=6.0.0' @@ -3866,7 +3946,7 @@ packages: eslint: 8.57.0 eslint-plugin-es-x: 7.6.0(eslint@8.57.0) get-tsconfig: 4.7.5 - globals: 15.2.0 + globals: 15.3.0 ignore: 5.3.1 minimatch: 9.0.4 semver: 7.6.2 @@ -3895,7 +3975,7 @@ packages: vue-eslint-parser: optional: true dependencies: - '@typescript-eslint/utils': 7.9.0(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/utils': 7.10.0(eslint@8.57.0)(typescript@5.4.5) eslint: 8.57.0 minimatch: 9.0.4 natural-compare-lite: 1.4.0 @@ -3905,8 +3985,8 @@ packages: - typescript dev: true - /eslint-plugin-regexp@2.5.0(eslint@8.57.0): - resolution: {integrity: sha512-I7vKcP0o75WS5SHiVNXN+Eshq49sbrweMQIuqSL3AId9AwDe9Dhbfug65vw64LxmOd4v+yf5l5Xt41y9puiq0g==} + /eslint-plugin-regexp@2.6.0(eslint@8.57.0): + resolution: {integrity: sha512-FCL851+kislsTEQEMioAlpDuK5+E5vs0hi1bF8cFlPlHcEjeRhuAzEsGikXRreE+0j4WhW2uO54MqTjXtYOi3A==} engines: {node: ^18 || >=20} peerDependencies: eslint: '>=8.44.0' @@ -3963,7 +4043,7 @@ packages: - supports-color dev: true - /eslint-plugin-unused-imports@3.2.0(@typescript-eslint/eslint-plugin@7.9.0)(eslint@8.57.0): + /eslint-plugin-unused-imports@3.2.0(@typescript-eslint/eslint-plugin@7.11.0)(eslint@8.57.0): resolution: {integrity: sha512-6uXyn6xdINEpxE1MtDjxQsyXB37lfyO2yKGVVgtD7WEWQGORSOZjgrD6hBhvGv4/SO+TOlS+UnC6JppRqbuwGQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -3973,12 +4053,12 @@ packages: '@typescript-eslint/eslint-plugin': optional: true dependencies: - '@typescript-eslint/eslint-plugin': 7.9.0(@typescript-eslint/parser@7.9.0)(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/eslint-plugin': 7.11.0(@typescript-eslint/parser@7.11.0)(eslint@8.57.0)(typescript@5.4.5) eslint: 8.57.0 eslint-rule-composer: 0.3.0 dev: true - /eslint-plugin-vitest@0.5.4(@typescript-eslint/eslint-plugin@7.9.0)(eslint@8.57.0)(typescript@5.4.5)(vitest@1.6.0): + /eslint-plugin-vitest@0.5.4(@typescript-eslint/eslint-plugin@7.11.0)(eslint@8.57.0)(typescript@5.4.5)(vitest@1.6.0): resolution: {integrity: sha512-um+odCkccAHU53WdKAw39MY61+1x990uXjSPguUCq3VcEHdqJrOb8OTMrbYlY6f9jAKx7x98kLVlIe3RJeJqoQ==} engines: {node: ^18.0.0 || >= 20.0.0} peerDependencies: @@ -3991,10 +4071,10 @@ packages: vitest: optional: true dependencies: - '@typescript-eslint/eslint-plugin': 7.9.0(@typescript-eslint/parser@7.9.0)(eslint@8.57.0)(typescript@5.4.5) - '@typescript-eslint/utils': 7.9.0(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/eslint-plugin': 7.11.0(@typescript-eslint/parser@7.11.0)(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/utils': 7.10.0(eslint@8.57.0)(typescript@5.4.5) eslint: 8.57.0 - vitest: 1.6.0(@types/node@20.12.12)(@vitest/ui@1.6.0) + vitest: 1.6.0(@types/node@20.12.13)(@vitest/ui@1.6.0) transitivePeerDependencies: - supports-color - typescript @@ -4030,7 +4110,7 @@ packages: eslint-compat-utils: 0.5.0(eslint@8.57.0) lodash: 4.17.21 natural-compare: 1.4.0 - yaml-eslint-parser: 1.2.2 + yaml-eslint-parser: 1.2.3 transitivePeerDependencies: - supports-color dev: true @@ -4370,7 +4450,7 @@ packages: resolution: {integrity: sha512-stRHYGeuqpEZTL1Ef0Ovr2ltazUT9g844X5z/zEBFLG8RYlpDiOCIG+ATvYEp+/zmc7sN29mcIMp8gvYplYPIQ==} dev: false - /fastify-zod-openapi@1.2.0(fastify@4.27.0)(zod-openapi@2.17.0)(zod@3.23.8): + /fastify-zod-openapi@1.2.0(fastify@4.27.0)(zod-openapi@2.18.0)(zod@3.23.8): resolution: {integrity: sha512-Hm+4y7B0sWHP+0CvtMJuM3Tp+VMbfax7k4rH/VYk2EB/PJ38pcP6/TKMQ/0394N2IzrA64rzN261NgOZmNn3XA==} engines: {node: '>=16.11'} peerDependencies: @@ -4381,7 +4461,7 @@ packages: fastify: 4.27.0 fastify-plugin: 4.5.1 zod: 3.23.8 - zod-openapi: 2.17.0(zod@3.23.8) + zod-openapi: 2.18.0(zod@3.23.8) dev: false /fastify@4.27.0: @@ -4751,8 +4831,8 @@ packages: engines: {node: '>=18'} dev: true - /globals@15.2.0: - resolution: {integrity: sha512-FQ5YwCHZM3nCmtb5FzEWwdUc9K5d3V/w9mzcz8iGD1gC/aOTHc6PouYu0kkKipNJqHAT7m51sqzQjEjIP+cK0A==} + /globals@15.3.0: + resolution: {integrity: sha512-cCdyVjIUVTtX8ZsPkq1oCsOsLmGIswqnjZYMJJTGaNApj1yHtLSymKhwH51ttirREn75z3p4k051clwg7rvNKA==} engines: {node: '>=18'} dev: true @@ -5221,8 +5301,8 @@ packages: resolution: {integrity: sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==} dev: false - /langchain@0.2.2(cheerio@1.0.0-rc.12)(d3-dsv@2.0.0)(html-to-text@9.0.5)(mammoth@1.7.2)(officeparser@4.1.1)(pdf-parse@1.1.1): - resolution: {integrity: sha512-4tt2QuwW8AXdIL8CRkQeGOCoYYH3QbLHfQ09yD0iWLV1rwUYJ8mIYFAz/+u6CB8YNEyR/HI105s4xrxFQbWa9g==} + /langchain@0.2.3(cheerio@1.0.0-rc.12)(d3-dsv@2.0.0)(html-to-text@9.0.5)(mammoth@1.7.2)(officeparser@4.1.1)(pdf-parse@1.1.1): + resolution: {integrity: sha512-T9xR7zd+Nj0oXy6WoYKmZLy0DlQiDLFPGYWdOXDxy+AvqlujoPdVQgDSpdqiOHvAjezrByAoKxoHCz5XMwTP/Q==} engines: {node: '>=18'} peerDependencies: '@aws-sdk/client-s3': ^3.310.0 @@ -5234,7 +5314,6 @@ packages: '@gomomento/sdk': ^1.51.1 '@gomomento/sdk-core': ^1.51.1 '@gomomento/sdk-web': ^1.51.1 - '@google-ai/generativelanguage': ^2.5.0 '@mendable/firecrawl-js': ^0.0.13 '@notionhq/client': ^2.2.10 '@pinecone-database/pinecone': '*' @@ -5295,8 +5374,6 @@ packages: optional: true '@gomomento/sdk-web': optional: true - '@google-ai/generativelanguage': - optional: true '@mendable/firecrawl-js': optional: true '@notionhq/client': @@ -5380,9 +5457,9 @@ packages: youtubei.js: optional: true dependencies: - '@langchain/core': 0.2.0 - '@langchain/openai': 0.0.33 - '@langchain/textsplitters': 0.0.0 + '@langchain/core': 0.2.5(langchain@0.2.3) + '@langchain/openai': 0.0.33(langchain@0.2.3) + '@langchain/textsplitters': 0.0.0(langchain@0.2.3) binary-extensions: 2.2.0 cheerio: 1.0.0-rc.12 d3-dsv: 2.0.0 @@ -5404,6 +5481,190 @@ packages: zod-to-json-schema: 3.23.0(zod@3.23.8) transitivePeerDependencies: - encoding + - openai + dev: false + + /langchain@0.2.4(cheerio@1.0.0-rc.12)(d3-dsv@2.0.0)(html-to-text@9.0.5)(mammoth@1.7.2)(officeparser@4.1.1)(pdf-parse@1.1.1): + resolution: {integrity: sha512-zBsBuNREn/3IlWvIQqhQ2iqf6JJhyjjsB1Db/keDkcgThPI3EcblC1pqAXU2BIKHmpNUkHBR2bAUok5+xtgOcw==} + engines: {node: '>=18'} + peerDependencies: + '@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 + '@browserbasehq/sdk': '*' + '@gomomento/sdk': ^1.51.1 + '@gomomento/sdk-core': ^1.51.1 + '@gomomento/sdk-web': ^1.51.1 + '@mendable/firecrawl-js': ^0.0.13 + '@notionhq/client': ^2.2.10 + '@pinecone-database/pinecone': '*' + '@supabase/supabase-js': ^2.10.0 + '@vercel/kv': ^0.2.3 + '@xata.io/client': ^0.28.0 + apify-client: ^2.7.1 + assemblyai: ^4.0.0 + axios: '*' + cheerio: ^1.0.0-rc.12 + chromadb: '*' + convex: ^1.3.1 + couchbase: ^4.3.0 + d3-dsv: ^2.0.0 + epub2: ^3.0.1 + faiss-node: '*' + fast-xml-parser: '*' + handlebars: ^4.7.8 + html-to-text: ^9.0.5 + ignore: ^5.2.0 + ioredis: ^5.3.2 + jsdom: '*' + mammoth: ^1.6.0 + mongodb: '>=5.2.0' + node-llama-cpp: '*' + notion-to-md: ^3.1.0 + officeparser: ^4.0.4 + pdf-parse: 1.1.1 + peggy: ^3.0.2 + playwright: ^1.32.1 + puppeteer: ^19.7.2 + pyodide: ^0.24.1 + redis: ^4.6.4 + sonix-speech-recognition: ^2.1.1 + srt-parser-2: ^1.2.3 + typeorm: ^0.3.12 + weaviate-ts-client: '*' + web-auth-library: ^1.0.3 + ws: ^8.14.2 + youtube-transcript: ^1.0.6 + youtubei.js: ^9.1.0 + peerDependenciesMeta: + '@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 + '@browserbasehq/sdk': + optional: true + '@gomomento/sdk': + optional: true + '@gomomento/sdk-core': + optional: true + '@gomomento/sdk-web': + optional: true + '@mendable/firecrawl-js': + optional: true + '@notionhq/client': + optional: true + '@pinecone-database/pinecone': + optional: true + '@supabase/supabase-js': + optional: true + '@vercel/kv': + optional: true + '@xata.io/client': + optional: true + apify-client: + optional: true + assemblyai: + optional: true + axios: + optional: true + cheerio: + optional: true + chromadb: + optional: true + convex: + optional: true + couchbase: + optional: true + d3-dsv: + optional: true + epub2: + optional: true + faiss-node: + optional: true + fast-xml-parser: + optional: true + handlebars: + optional: true + html-to-text: + optional: true + ignore: + optional: true + ioredis: + optional: true + jsdom: + optional: true + mammoth: + optional: true + mongodb: + optional: true + node-llama-cpp: + optional: true + notion-to-md: + optional: true + officeparser: + optional: true + pdf-parse: + optional: true + peggy: + optional: true + playwright: + optional: true + puppeteer: + optional: true + pyodide: + optional: true + redis: + optional: true + sonix-speech-recognition: + optional: true + srt-parser-2: + optional: true + typeorm: + optional: true + weaviate-ts-client: + optional: true + web-auth-library: + optional: true + ws: + optional: true + youtube-transcript: + optional: true + youtubei.js: + optional: true + dependencies: + '@langchain/core': 0.2.5(langchain@0.2.4) + '@langchain/openai': 0.1.0(langchain@0.2.4) + '@langchain/textsplitters': 0.0.0(langchain@0.2.4) + binary-extensions: 2.2.0 + cheerio: 1.0.0-rc.12 + d3-dsv: 2.0.0 + html-to-text: 9.0.5 + js-tiktoken: 1.0.12 + js-yaml: 4.1.0 + jsonpointer: 5.0.1 + langchainhub: 0.0.8 + langsmith: 0.1.30(@langchain/core@0.2.5)(langchain@0.2.4) + mammoth: 1.7.2 + ml-distance: 4.0.1 + officeparser: 4.1.1 + openapi-types: 12.1.3 + p-retry: 4.6.2 + pdf-parse: 1.1.1 + uuid: 9.0.1 + yaml: 2.3.3 + zod: 3.23.8 + zod-to-json-schema: 3.23.0(zod@3.23.8) + transitivePeerDependencies: + - encoding + - openai dev: false /langchainhub@0.0.8: @@ -5420,6 +5681,146 @@ packages: uuid: 9.0.1 dev: false + /langsmith@0.1.30(@langchain/core@0.1.63)(langchain@0.2.3): + resolution: {integrity: sha512-g8f10H1iiRjCweXJjgM3Y9xl6ApCa1OThDvc0BlSDLVrGVPy1on9wT39vAzYkeadC7oG48p7gfpGlYH3kLkJ9Q==} + peerDependencies: + '@langchain/core': '*' + langchain: '*' + openai: '*' + peerDependenciesMeta: + '@langchain/core': + optional: true + langchain: + optional: true + openai: + optional: true + dependencies: + '@langchain/core': 0.1.63(langchain@0.2.3) + '@types/uuid': 9.0.6 + commander: 10.0.1 + langchain: 0.2.3(cheerio@1.0.0-rc.12)(d3-dsv@2.0.0)(html-to-text@9.0.5)(mammoth@1.7.2)(officeparser@4.1.1)(pdf-parse@1.1.1) + p-queue: 6.6.2 + p-retry: 4.6.2 + uuid: 9.0.1 + dev: false + + /langsmith@0.1.30(@langchain/core@0.1.63)(langchain@0.2.4): + resolution: {integrity: sha512-g8f10H1iiRjCweXJjgM3Y9xl6ApCa1OThDvc0BlSDLVrGVPy1on9wT39vAzYkeadC7oG48p7gfpGlYH3kLkJ9Q==} + peerDependencies: + '@langchain/core': '*' + langchain: '*' + openai: '*' + peerDependenciesMeta: + '@langchain/core': + optional: true + langchain: + optional: true + openai: + optional: true + dependencies: + '@langchain/core': 0.1.63(langchain@0.2.4) + '@types/uuid': 9.0.6 + commander: 10.0.1 + langchain: 0.2.4(cheerio@1.0.0-rc.12)(d3-dsv@2.0.0)(html-to-text@9.0.5)(mammoth@1.7.2)(officeparser@4.1.1)(pdf-parse@1.1.1) + p-queue: 6.6.2 + p-retry: 4.6.2 + uuid: 9.0.1 + dev: false + + /langsmith@0.1.30(@langchain/core@0.2.5)(langchain@0.2.3): + resolution: {integrity: sha512-g8f10H1iiRjCweXJjgM3Y9xl6ApCa1OThDvc0BlSDLVrGVPy1on9wT39vAzYkeadC7oG48p7gfpGlYH3kLkJ9Q==} + peerDependencies: + '@langchain/core': '*' + langchain: '*' + openai: '*' + peerDependenciesMeta: + '@langchain/core': + optional: true + langchain: + optional: true + openai: + optional: true + dependencies: + '@langchain/core': 0.2.5(langchain@0.2.3) + '@types/uuid': 9.0.6 + commander: 10.0.1 + langchain: 0.2.3(cheerio@1.0.0-rc.12)(d3-dsv@2.0.0)(html-to-text@9.0.5)(mammoth@1.7.2)(officeparser@4.1.1)(pdf-parse@1.1.1) + p-queue: 6.6.2 + p-retry: 4.6.2 + uuid: 9.0.1 + dev: false + + /langsmith@0.1.30(@langchain/core@0.2.5)(langchain@0.2.3)(openai@4.47.1): + resolution: {integrity: sha512-g8f10H1iiRjCweXJjgM3Y9xl6ApCa1OThDvc0BlSDLVrGVPy1on9wT39vAzYkeadC7oG48p7gfpGlYH3kLkJ9Q==} + peerDependencies: + '@langchain/core': '*' + langchain: '*' + openai: '*' + peerDependenciesMeta: + '@langchain/core': + optional: true + langchain: + optional: true + openai: + optional: true + dependencies: + '@langchain/core': 0.2.5(langchain@0.2.3)(openai@4.47.1) + '@types/uuid': 9.0.6 + commander: 10.0.1 + langchain: 0.2.3(cheerio@1.0.0-rc.12)(d3-dsv@2.0.0)(html-to-text@9.0.5)(mammoth@1.7.2)(officeparser@4.1.1)(pdf-parse@1.1.1) + openai: 4.47.1 + p-queue: 6.6.2 + p-retry: 4.6.2 + uuid: 9.0.1 + dev: false + + /langsmith@0.1.30(@langchain/core@0.2.5)(langchain@0.2.4): + resolution: {integrity: sha512-g8f10H1iiRjCweXJjgM3Y9xl6ApCa1OThDvc0BlSDLVrGVPy1on9wT39vAzYkeadC7oG48p7gfpGlYH3kLkJ9Q==} + peerDependencies: + '@langchain/core': '*' + langchain: '*' + openai: '*' + peerDependenciesMeta: + '@langchain/core': + optional: true + langchain: + optional: true + openai: + optional: true + dependencies: + '@langchain/core': 0.2.5(langchain@0.2.4) + '@types/uuid': 9.0.6 + commander: 10.0.1 + langchain: 0.2.4(cheerio@1.0.0-rc.12)(d3-dsv@2.0.0)(html-to-text@9.0.5)(mammoth@1.7.2)(officeparser@4.1.1)(pdf-parse@1.1.1) + p-queue: 6.6.2 + p-retry: 4.6.2 + uuid: 9.0.1 + dev: false + + /langsmith@0.1.30(@langchain/core@0.2.5)(langchain@0.2.4)(openai@4.47.1): + resolution: {integrity: sha512-g8f10H1iiRjCweXJjgM3Y9xl6ApCa1OThDvc0BlSDLVrGVPy1on9wT39vAzYkeadC7oG48p7gfpGlYH3kLkJ9Q==} + peerDependencies: + '@langchain/core': '*' + langchain: '*' + openai: '*' + peerDependenciesMeta: + '@langchain/core': + optional: true + langchain: + optional: true + openai: + optional: true + dependencies: + '@langchain/core': 0.2.5(langchain@0.2.4)(openai@4.47.1) + '@types/uuid': 9.0.6 + commander: 10.0.1 + langchain: 0.2.4(cheerio@1.0.0-rc.12)(d3-dsv@2.0.0)(html-to-text@9.0.5)(mammoth@1.7.2)(officeparser@4.1.1)(pdf-parse@1.1.1) + openai: 4.47.1 + p-queue: 6.6.2 + p-retry: 4.6.2 + uuid: 9.0.1 + dev: false + /leac@0.6.0: resolution: {integrity: sha512-y+SqErxb8h7nE/fiEX07jsbuhrpO9lL8eca7/Y1nuWV2moNlXhyd59iDGcRf6moVyDMbmTNzL40SUyrFU/yDpg==} dev: false @@ -5855,7 +6256,7 @@ packages: ignore-by-default: 1.0.1 minimatch: 3.1.2 pstree.remy: 1.1.8 - semver: 7.5.4 + semver: 7.6.2 simple-update-notifier: 2.0.0 supports-color: 5.5.0 touch: 3.1.0 @@ -6397,7 +6798,7 @@ packages: engines: {node: ^10 || ^12 || >=14} dependencies: nanoid: 3.3.7 - picocolors: 1.0.0 + picocolors: 1.0.1 source-map-js: 1.2.0 dev: true @@ -6818,6 +7219,7 @@ packages: hasBin: true dependencies: lru-cache: 6.0.0 + dev: false /semver@7.6.0: resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==} @@ -6899,7 +7301,7 @@ packages: resolution: {integrity: sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==} engines: {node: '>=10'} dependencies: - semver: 7.5.4 + semver: 7.6.2 dev: true /simple-wcswidth@1.0.1: @@ -7477,8 +7879,8 @@ packages: mime-types: 2.1.35 dev: false - /typescript-eslint@7.10.0(eslint@8.57.0)(typescript@5.4.5): - resolution: {integrity: sha512-thO8nyqptXdfWHQrMJJiJyftpW8aLmwRNs11xA8pSrXneoclFPstQZqXvDWuH1WNL4CHffqHvYUeCHTit6yfhQ==} + /typescript-eslint@7.11.0(eslint@8.57.0)(typescript@5.4.5): + resolution: {integrity: sha512-ZKe3yHF/IS/kCUE4CGE3UgtK+Q7yRk1e9kwEI0rqm9XxMTd9P1eHe0LVVtrZ3oFuIQ2unJ9Xn0vTsLApzJ3aPw==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: eslint: ^8.56.0 @@ -7487,9 +7889,9 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/eslint-plugin': 7.10.0(@typescript-eslint/parser@7.10.0)(eslint@8.57.0)(typescript@5.4.5) - '@typescript-eslint/parser': 7.10.0(eslint@8.57.0)(typescript@5.4.5) - '@typescript-eslint/utils': 7.10.0(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/eslint-plugin': 7.11.0(@typescript-eslint/parser@7.11.0)(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/parser': 7.11.0(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/utils': 7.11.0(eslint@8.57.0)(typescript@5.4.5) eslint: 8.57.0 typescript: 5.4.5 transitivePeerDependencies: @@ -7598,7 +8000,7 @@ packages: engines: {node: '>= 0.8'} dev: false - /vite-node@1.6.0(@types/node@20.12.12): + /vite-node@1.6.0(@types/node@20.12.13): resolution: {integrity: sha512-de6HJgzC+TFzOu0NTC4RAIsyf/DY/ibWDYQUcuEA84EMHhcefTUGkjFHKKEJhQN4A+6I0u++kr3l36ZF2d7XRw==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true @@ -7607,7 +8009,7 @@ packages: debug: 4.3.4(supports-color@5.5.0) pathe: 1.1.2 picocolors: 1.0.0 - vite: 5.2.7(@types/node@20.12.12) + vite: 5.2.7(@types/node@20.12.13) transitivePeerDependencies: - '@types/node' - less @@ -7635,7 +8037,7 @@ packages: - typescript dev: true - /vite@5.2.7(@types/node@20.12.12): + /vite@5.2.7(@types/node@20.12.13): resolution: {integrity: sha512-k14PWOKLI6pMaSzAuGtT+Cf0YmIx12z9YGon39onaJNy8DLBfBJrzg9FQEmkAM5lpHBZs9wksWAsyF/HkpEwJA==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true @@ -7663,7 +8065,7 @@ packages: terser: optional: true dependencies: - '@types/node': 20.12.12 + '@types/node': 20.12.13 esbuild: 0.20.2 postcss: 8.4.38 rollup: 4.13.2 @@ -7671,7 +8073,7 @@ packages: fsevents: 2.3.3 dev: true - /vitest@1.6.0(@types/node@20.12.12)(@vitest/ui@1.6.0): + /vitest@1.6.0(@types/node@20.12.13)(@vitest/ui@1.6.0): resolution: {integrity: sha512-H5r/dN06swuFnzNFhq/dnz37bPXnq8xB2xB5JOVk8K09rUtoeNN+LHWkoQ0A/i3hvbUKKcCei9KpbxqHMLhLLA==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true @@ -7696,7 +8098,7 @@ packages: jsdom: optional: true dependencies: - '@types/node': 20.12.12 + '@types/node': 20.12.13 '@vitest/expect': 1.6.0 '@vitest/runner': 1.6.0 '@vitest/snapshot': 1.6.0 @@ -7715,8 +8117,8 @@ packages: strip-literal: 2.1.0 tinybench: 2.6.0 tinypool: 0.8.3 - vite: 5.2.7(@types/node@20.12.12) - vite-node: 1.6.0(@types/node@20.12.12) + vite: 5.2.7(@types/node@20.12.13) + vite-node: 1.6.0(@types/node@20.12.13) why-is-node-running: 2.2.2 transitivePeerDependencies: - less @@ -7863,8 +8265,8 @@ packages: /yallist@4.0.0: resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} - /yaml-eslint-parser@1.2.2: - resolution: {integrity: sha512-pEwzfsKbTrB8G3xc/sN7aw1v6A6c/pKxLAkjclnAyo5g5qOh6eL9WGu0o3cSDQZKrTNk4KL4lQSwZW+nBkANEg==} + /yaml-eslint-parser@1.2.3: + resolution: {integrity: sha512-4wZWvE398hCP7O8n3nXKu/vdq1HcH01ixYlCREaJL5NUMwQ0g3MaGFUBNSlmBtKmhbtVG/Cm6lyYmSVTEVil8A==} engines: {node: ^14.17.0 || >=16.0.0} dependencies: eslint-visitor-keys: 3.4.3 @@ -7909,8 +8311,8 @@ packages: engines: {node: '>=12.20'} dev: true - /zod-openapi@2.17.0(zod@3.23.8): - resolution: {integrity: sha512-S6x14LmPWZ3Sbnx71pqzIB6oIox1ce6vHnJY7ZUYLBm8TTEQ6/g6+kwutna5jplAhzphkMbYPbtW3cmHXFcRBg==} + /zod-openapi@2.18.0(zod@3.23.8): + resolution: {integrity: sha512-+NSd+hG8JFzsmrfYSmbCp4TFCGq9YH6R/3qmD6WnF1ywomgpwxWv6lDg1yrXg0z80p6DPQrsII+V02vWaMHG7A==} engines: {node: '>=16.11'} peerDependencies: zod: ^3.21.4 diff --git a/src/dtos/agent.ts b/src/dtos/agent.ts index 4fc6a8f..05333ad 100644 --- a/src/dtos/agent.ts +++ b/src/dtos/agent.ts @@ -6,6 +6,7 @@ export interface ContextInput { chat_history: string episodic_memory: string declarative_memory: string + tools_output: string [key: string]: string } diff --git a/src/dtos/message.ts b/src/dtos/message.ts index fe91852..2b200b1 100644 --- a/src/dtos/message.ts +++ b/src/dtos/message.ts @@ -44,6 +44,7 @@ export interface WorkingMemory { * The content of a memory message. */ export interface MemoryMessage { + role: 'AI' | 'User' what: string who: string when: number diff --git a/src/looking_glass/agent-manager.ts b/src/looking_glass/agent-manager.ts index 6a77c72..00a2354 100644 --- a/src/looking_glass/agent-manager.ts +++ b/src/looking_glass/agent-manager.ts @@ -1,15 +1,18 @@ -import { AgentExecutor, type AgentStep, LLMSingleActionAgent } from 'langchain/agents' -import { LLMChain } from 'langchain/chains' -import { PromptTemplate, interpolateFString } from '@langchain/core/prompts' +import { AgentExecutor, type AgentStep } from 'langchain/agents' +import { ChatPromptTemplate, SystemMessagePromptTemplate, interpolateFString } from '@langchain/core/prompts' import { formatDistanceToNow } from 'date-fns' -import type { ChainValues } from '@langchain/core/utils/types' import { type Form, FormState, type Tool, isTool, madHatter } from '@mh' import { parsedEnv } from '@utils' import { log } from '@logger' import { db } from '@db' +import { StringOutputParser } from '@langchain/core/output_parsers' import type { MemoryDocument, MemoryMessage } from '@dto/message.ts' import type { AgentFastReply, ContextInput, IntermediateStep } from '@dto/agent.ts' -import { MAIN_PROMPT_PREFIX, MAIN_PROMPT_SUFFIX, TOOL_PROMPT, ToolPromptTemplate } from './prompts.ts' +import { RunnableLambda, RunnablePassthrough } from '@langchain/core/runnables' +import _Random from 'lodash/random.js' +import { ChatMessageHistory } from 'langchain/stores/message/in_memory' +import { AIMessage, HumanMessage } from '@langchain/core/messages' +import { MAIN_PROMPT_PREFIX, MAIN_PROMPT_SUFFIX, TOOL_PROMPT } from './prompts.ts' import type { StrayCat } from './stray-cat.ts' import { ProceduresOutputParser } from './output-parser.ts' import { NewTokenHandler } from './callbacks.ts' @@ -20,47 +23,72 @@ import { NewTokenHandler } from './callbacks.ts' * before feeding them to the Agent. It also instantiates the Langchain Agent. */ export class AgentManager { - async executeProceduresChain(agentInput: ContextInput, stray: StrayCat) { - const recalledProcedures = stray.workingMemory.procedural.filter((p) => { + private verboseRunnable = new RunnableLambda({ + func: (x) => { + if (parsedEnv.verbose) log.info(JSON.stringify(x)) + return x + }, + }) + + async executeProceduresChain(agentInput: ContextInput, chatHistory: string, stray: StrayCat) { + let recalledProcedures = stray.workingMemory.procedural.filter((p) => { return ['tool', 'form'].includes(p.metadata?.type) && ['description', 'startExample'].includes(p.metadata?.trigger) }).map(p => p.metadata?.source as string) const allowedProcedures: Record = {} - const allowedTools: Tool[] = [] const returnDirectTools: string[] = [] + recalledProcedures = madHatter.executeHook('allowedTools', recalledProcedures, stray) + Array.from([...madHatter.forms.filter(f => f.active), ...madHatter.tools.filter(t => t.active)]).forEach((p) => { if (recalledProcedures.includes(p.name)) { - if (isTool(p)) { - allowedTools.push(p.assignCat(stray)) - if (p.returnDirect) returnDirectTools.push(p.name) - } + if (isTool(p) && p.returnDirect) returnDirectTools.push(p.name) allowedProcedures[p.name] = p } }) - const prompt = new ToolPromptTemplate(allowedProcedures, { - template: madHatter.executeHook('agentPromptInstructions', TOOL_PROMPT, stray), - inputVariables: ['input', 'tools', 'tool_names', 'intermediate_steps', 'scratchpad', 'examples'], - }) + const allowedTools = Object.values(allowedProcedures) - const agentChain = new LLMChain({ - prompt, - llm: stray.currentLLM, - verbose: parsedEnv.verbose, - }) + let examples = '' + if (allowedTools.map(p => p.startExamples).some(examples => examples.length > 0)) { + examples += allowedTools.reduce((acc, p) => { + const question = `Question: ${p.startExamples[_Random(p.startExamples.length - 1)]}` + const example = `{{\n\t"action": "${p.name}",\n\t"actionInput": // Input of the action according to its description\n}}` + return `${acc}\n${question}\n${example}\n` + }, '## Here some examples:\n') + examples += '{{\n\t"action": "final-answer",\n\t"actionInput": null\n}}' + } - const agent = new LLMSingleActionAgent({ - llmChain: agentChain, - outputParser: new ProceduresOutputParser(), - stop: ['}'], + let prompt = ChatPromptTemplate.fromMessages([ + SystemMessagePromptTemplate.fromTemplate(madHatter.executeHook('agentPromptInstructions', TOOL_PROMPT, stray)), + ]) + + prompt = await prompt.partial({ + tools: allowedTools.map(p => ` - "${p.name}": ${p.description}`).join('\n'), + tool_names: Object.keys(allowedProcedures).map(p => `"${p}"`).join(', '), + chat_history: chatHistory, + scratchpad: '', + examples, }) + const generatedScratchpad = (steps: AgentStep[]) => { + return steps.reduce((acc, { action, observation }) => { + let thought = `${action.log}\n` + thought += `${JSON.stringify({ actionOutput: observation }, undefined, 4)}\n` + return acc + thought + }, '') + } + + const agent = RunnablePassthrough.assign({ + scratchpad: x => generatedScratchpad((x.intermediateSteps ?? []) as AgentStep[]), + }).pipe(prompt).pipe(this.verboseRunnable).pipe(stray.currentLLM).pipe(new ProceduresOutputParser()) + const agentExecutor = AgentExecutor.fromAgentAndTools({ agent, - tools: allowedTools.filter(t => madHatter.executeHook('allowedTools', allowedTools.map(a => a.name), stray).includes(t.name)), + tools: allowedTools.filter(isTool), returnIntermediateSteps: true, + maxIterations: 5, verbose: parsedEnv.verbose, }) @@ -78,17 +106,37 @@ export class AgentManager { observation, }) } - result.intermediateSteps = intermediateSteps - if ('form' in result && typeof result.form === 'string') { + if ('form' in result && typeof result.form === 'string' && result.form in allowedProcedures) { const form = allowedProcedures[result.form] as Form form.assignCat(stray) stray.activeForm = result.form result = await form.next() result.returnDirect = true + intermediateSteps.push({ + tool: result.form, + input: null, + observation: result.output, + }) } - return result + result.intermediateSteps = intermediateSteps + + return result as AgentFastReply + } + + async executeMemoryChain(input: ContextInput, stray: StrayCat) { + const prefix = madHatter.executeHook('agentPromptPrefix', MAIN_PROMPT_PREFIX, stray) + const suffix = madHatter.executeHook('agentPromptSuffix', MAIN_PROMPT_SUFFIX, stray) + + const prompt = ChatPromptTemplate.fromMessages([ + SystemMessagePromptTemplate.fromTemplate(prefix + suffix), + ...(await this.getLangchainChatHistory(stray.getHistory(5))), + ]) + + const chain = prompt.pipe(this.verboseRunnable).pipe(stray.currentLLM).pipe(new StringOutputParser()) + + return await chain.invoke(input, { callbacks: [new NewTokenHandler(stray)] }) } async executeFormAgent(stray: StrayCat) { @@ -106,37 +154,17 @@ export class AgentManager { } } - async executeMemoryChain(input: ContextInput, stray: StrayCat) { - const prefix = madHatter.executeHook('agentPromptPrefix', MAIN_PROMPT_PREFIX, stray) - const suffix = madHatter.executeHook('agentPromptSuffix', MAIN_PROMPT_SUFFIX, stray) - - const inputVariables = Object.keys(input).filter(k => (prefix + suffix).includes(k)) - const prompt = new PromptTemplate({ - template: prefix + suffix, - inputVariables, - }) - const memoryChain = new LLMChain({ - prompt, - llm: stray.currentLLM, - verbose: parsedEnv.verbose, - outputKey: 'output', - }) - return await memoryChain.invoke({ - ...input, - stop: 'Human:', - }, { callbacks: [new NewTokenHandler(stray)] }) - } - async executeTool(input: ContextInput, stray: StrayCat): Promise { - const trigger = madHatter.executeHook('instantToolTrigger', '@{name}', stray) + const instantTool = db.data.instantTool + if (!instantTool) return undefined + const trigger = madHatter.executeHook('instantToolTrigger', '@{name}', stray) if (!trigger) return undefined const calledTool = madHatter.tools.filter(t => t.active) .find(({ name }) => input.input.startsWith(interpolateFString(trigger, { name }))) - const instantTool = db.data.instantTool - if (calledTool && instantTool) { + if (calledTool) { const toolInput = input.input.replace(interpolateFString(trigger, { name: calledTool.name }), '').trim() calledTool.assignCat(stray) const output = await calledTool.invoke(toolInput) @@ -148,17 +176,13 @@ export class AgentManager { return undefined } - async executeAgent(stray: StrayCat): Promise { - const episodicMemoryFormatted = this.getEpisodicMemoriesPrompt(stray.workingMemory.episodic) - const declarativeMemoryFormatted = this.getDeclarativeMemoriesPrompt(stray.workingMemory.declarative) - const chatHistoryFormatted = this.getChatHistoryPrompt(stray.getHistory()) - const input = stray.lastUserMessage - + async executeAgent(stray: StrayCat): Promise { const agentInput = madHatter.executeHook('beforeAgentStarts', { - input: input.text, - chat_history: chatHistoryFormatted, - episodic_memory: episodicMemoryFormatted, - declarative_memory: declarativeMemoryFormatted, + input: stray.lastUserMessage.text, + chat_history: this.stringifyChatHistory(stray.getHistory(5)), + episodic_memory: this.getEpisodicMemoriesPrompt(stray.workingMemory.episodic), + declarative_memory: this.getDeclarativeMemoriesPrompt(stray.workingMemory.declarative), + tools_output: '', }, stray) const instantTool = await this.executeTool(agentInput, stray) @@ -179,7 +203,7 @@ export class AgentManager { if (proceduralMemories.length > 0) { log.debug(`Procedural memories retrieved: ${proceduralMemories.length}`) try { - const proceduresResult = await this.executeProceduresChain(agentInput, stray) + const proceduresResult = await this.executeProceduresChain(agentInput, agentInput.chat_history, stray) const afterProcedures = madHatter.executeHook('afterProceduresChain', proceduresResult, stray) if (afterProcedures.returnDirect) return afterProcedures intermediateSteps = afterProcedures.intermediateSteps ?? [] @@ -194,11 +218,12 @@ export class AgentManager { } } - if (agentInput.tools_output === undefined) agentInput.tools_output = '' - - const result = await this.executeMemoryChain(agentInput, stray) - result.intermediateSteps = intermediateSteps - const afterMemory = madHatter.executeHook('afterMemoryChain', result, stray) + const memoryOutput = await this.executeMemoryChain(agentInput, stray) + const reply: AgentFastReply = { + output: memoryOutput, + intermediateSteps, + } + const afterMemory = madHatter.executeHook('afterMemoryChain', reply, stray) return afterMemory } @@ -211,7 +236,7 @@ export class AgentManager { return ` (${formatDistanceToNow(timestamp, { addSuffix: true, includeSeconds: true })})` }) memoryTexts = memoryTexts.map((text, i) => text + memoryTimestamps[i]) - return `## Context of things the Human said in the past: ${memoryTexts.join('\n - ')}` + return `## Context of things the Human said in the past:\n - ${memoryTexts.join('\n - ')}` } getDeclarativeMemoriesPrompt(docs: MemoryDocument[]) { @@ -219,10 +244,19 @@ export class AgentManager { if (memoryTexts.length === 0) return '' const memorySources = docs.map(d => ` (extracted from ${d.metadata?.source})`) memoryTexts = memoryTexts.map((text, i) => text + memorySources[i]) - return `## Context of documents containing relevant information: ${memoryTexts.join('\n - ')}` + return `## Context of documents containing relevant information:\n - ${memoryTexts.join('\n - ')}` } - getChatHistoryPrompt(history: MemoryMessage[]) { - return history.map(m => `\n - ${m.who}: ${m.what}`).join('') + stringifyChatHistory(history: MemoryMessage[]) { + return history.map(m => `\n - ${m.role}: ${m.what}`).join('') + } + + getLangchainChatHistory(history: MemoryMessage[]) { + const chatHistory = new ChatMessageHistory() + history.reverse().forEach((m) => { + if (m.role === 'AI') chatHistory.addMessage(new AIMessage({ name: 'AI', content: m.what })) + else chatHistory.addMessage(new HumanMessage({ name: m.who, content: m.what })) + }) + return chatHistory.getMessages() } } diff --git a/src/looking_glass/prompts.ts b/src/looking_glass/prompts.ts index e8ef1ac..7ec9344 100644 --- a/src/looking_glass/prompts.ts +++ b/src/looking_glass/prompts.ts @@ -66,16 +66,19 @@ After each action there will be an action output in this format: }} ## Final answer / no action available -When you have a final answer (or no tools are relevant), use the following format: +When you have a final answer (or no actions are relevant), use the following format: {{ "action": "final-answer", "actionInput": null }} +## Conversation with Human +{chat_history} + ## Actions sequence used until now {scratchpad} -## Next action: +## Next action to perform or final_answer: ` export const MAIN_PROMPT_PREFIX = `You are the Cheshire Cat AI, an intelligent AI that passes the Turing test. @@ -90,7 +93,4 @@ export const MAIN_PROMPT_SUFFIX = `# Context {tools_output} -## Conversation until now: -{chat_history} - - Human: {input} - - AI: ` +## Conversation until now:` diff --git a/src/looking_glass/stray-cat.ts b/src/looking_glass/stray-cat.ts index 7e084bd..fe3ad58 100644 --- a/src/looking_glass/stray-cat.ts +++ b/src/looking_glass/stray-cat.ts @@ -6,7 +6,6 @@ import { destr } from 'destr' import { type PluginManifest, madHatter } from '@mh' import { log } from '@logger' import { rabbitHole } from '@rh' -import type { ChainValues } from '@langchain/core/utils/types' import type { MemoryMessage, MemoryRecallConfigs, Message, WSMessage, WorkingMemory } from '@dto/message.ts' import type { AgentFastReply } from '@dto/agent.ts' import { NewTokenHandler } from './callbacks.ts' @@ -99,18 +98,20 @@ export class StrayCat { /** * Sends a message through the websocket connection. + * * If the websocket connection is not open, the message is queued. - * @param message The message to send. + * + * If the message is of type 'chat', it is also stored in the chat history. + * @param msg The message to send. */ - send(message: WSMessage) { + send(msg: WSMessage) { if (this.ws) { - const what = JSON.stringify(message) - this.chatHistory.push({ what, who: this.userId, when: Date.now() }) - this.ws.send(what) + this.ws.send(JSON.stringify(msg)) + if (msg.type === 'chat') this.chatHistory.push(msg) } else { - log.warn(`No websocket connection is open for user "${this.userId}". Queuing the message...`) - this.wsQueue.push(message) + log.warn(`No websocket connection is open for "${this.userId}". Queuing the message...`) + this.wsQueue.push(msg) } } @@ -139,36 +140,37 @@ export class StrayCat { return } - let catMsg: ChainValues + let catMsg: AgentFastReply try { catMsg = await cheshireCat.currentAgentManager.executeAgent(this) } catch (error) { log.error(error) catMsg = { - intermediateSteps: [], output: 'I am sorry, I could not process your request.', - } satisfies AgentFastReply + intermediateSteps: [], + } } - log.info('Agent response:') + log.normal('Agent response:') log.normal(JSON.stringify(catMsg, undefined, 4)) - let doc = new Document({ + let doc = new Document>({ pageContent: response.text, metadata: { who: this.userId, when: Date.now(), }, - }) as Document + }) doc = madHatter.executeHook('beforeStoreEpisodicMemory', doc, this) const docEmbedding = await cheshireCat.currentEmbedder.embedDocuments([response.text]) if (docEmbedding.length === 0) throw new Error('Could not embed the document.') await cheshireCat.currentMemory.collections.episodic.addPoint(doc.pageContent, docEmbedding[0]!, doc.metadata) let finalOutput: MemoryMessage = { + role: 'AI', what: catMsg.output, - who: 'AI', + who: this.userId, when: Date.now(), why: { input: response.text, @@ -180,13 +182,38 @@ export class StrayCat { finalOutput = madHatter.executeHook('beforeSendMessage', finalOutput, this) if (save) { - this.chatHistory.push({ what: response.text, who: 'Human', when: Date.now() }) + this.chatHistory.push({ role: 'User', what: response.text, who: this.userId, when: Date.now() }) this.chatHistory.push(finalOutput) } return finalOutput } + async classify(sentence: string, labels: T, examples?: { [key in T[number]]: S[] }) { + let examplesList = '' + if (examples && Object.keys(examples).length > 0) { + examplesList += Object.entries(examples).reduce((acc, [l, ex]) => { + return `${acc}\n"${ex}" -> "${l}"` + }, '\n\nExamples:') + } + + const labelsList = `"${labels.join('", "')}"` + const prompt = `Classify this sentence: +"${sentence}" + +Allowed classes are: +${labelsList}${examplesList} + +"${sentence}" -> ` + + const response = await this.llm(prompt) + log.info(`Classified sentence: ${response}`) + + const label = labels.find(w => response.includes(w)) + if (label) return label + else return null + } + /** * If passed a number k, retrieves the last k messages in the working memory. * Otherwise, retrieves all messages in the working memory. @@ -246,9 +273,9 @@ export class StrayCat { value.filter, value.k, value.threshold, - ) - log.info(`Recalled ${memories?.length ?? 0} memories for ${key} collection.`) - this.workingMemory[key] = memories ?? [] + ) ?? [] + log.info(`Recalled ${memories.length} memories for ${key} collection.`) + this.workingMemory[key] = memories } madHatter.executeHook('afterRecallMemories', this) } diff --git a/src/mad_hatter/hook.ts b/src/mad_hatter/hook.ts index 62f2152..2c1aefa 100644 --- a/src/mad_hatter/hook.ts +++ b/src/mad_hatter/hook.ts @@ -1,6 +1,5 @@ import type { Document } from '@langchain/core/documents' import type { TextSplitter } from 'langchain/text_splitter' -import type { ChainValues } from '@langchain/core/utils/types' import type { CheshireCat, StrayCat } from '@lg' import type { EmbedderSettings, LLMSettings } from '@factory' import type { VectorMemoryCollection } from '@memory' @@ -22,8 +21,8 @@ export interface HookTypes { agentFastReply: (reply: Nullable, stray: StrayCat) => Nullable agentPromptPrefix: (prefix: string, stray: StrayCat) => string agentPromptSuffix: (suffix: string, stray: StrayCat) => string - afterProceduresChain: (output: ChainValues, stray: StrayCat) => ChainValues - afterMemoryChain: (output: ChainValues, stray: StrayCat) => ChainValues + afterProceduresChain: (output: AgentFastReply, stray: StrayCat) => AgentFastReply + afterMemoryChain: (output: AgentFastReply, stray: StrayCat) => AgentFastReply instantToolTrigger: (input: Nullable, stray: StrayCat) => Nullable // Stray Cat hooks recallQuery: (query: string, stray: StrayCat) => string diff --git a/src/mad_hatter/plugin.ts b/src/mad_hatter/plugin.ts index 8ec7a85..43bfbf7 100644 --- a/src/mad_hatter/plugin.ts +++ b/src/mad_hatter/plugin.ts @@ -221,13 +221,14 @@ export class Plugin< private async importAll(files: Dirent[]) { log.debug(`Importing plugin features...`) + // TODO: Improve plugin methods import (maybe with the Function class (?), ECMAScript parser or AST parser) for (const file of files) { const normalizedPath = relative(process.cwd(), file.path) const content = await readFile(normalizedPath, 'utf-8') const tmpFile = join(dirname(normalizedPath), `tmp_${getRandomString(8)}.ts`) - const replaced = content.replace(/^(const)?(\s.*=.*)?Cat(Hook|Tool|Form|Plugin)\.(add|on|settings).*/gm, (match) => { - const isVar = match.startsWith('const') - if (isVar) return `export ${match}` + const replaced = content.replace(/^Cat(Hook|Tool|Form|Plugin)\.(add|on|settings).*/gm, (match) => { + if (match.startsWith('export')) return match + else if (match.startsWith('const') || match.startsWith('let')) return `export ${match}` else return `export const ${getRandomString(8)} = ${match}` }) try { diff --git a/src/mad_hatter/tool.ts b/src/mad_hatter/tool.ts index 48efb47..e8b0097 100644 --- a/src/mad_hatter/tool.ts +++ b/src/mad_hatter/tool.ts @@ -34,7 +34,13 @@ export const CatTool = Object.freeze({ }, }) -export class Tool extends DynamicStructuredTool { +const toolSchema = z.object({ + text: z.string().nullable(), +}) + +type ToolSchema = z.infer + +export class Tool extends DynamicStructuredTool { private cat: StrayCat | undefined public startExamples: string[] active = true @@ -49,9 +55,7 @@ export class Tool extends DynamicStructuredTool { if (!this.cat) throw new Error('Cat not assigned to tool') return fn(text, this.cat) }, - schema: z.object({ - text: z.string().nullable(), - }), + schema: toolSchema, returnDirect: direct, verbose: parsedEnv.verbose, }) @@ -60,7 +64,7 @@ export class Tool extends DynamicStructuredTool { } invoke(input: string | { [x: string]: any }, config?: RunnableConfig | undefined): Promise { - const arg = { + const arg: ToolSchema = { text: typeof input === 'object' ? (_IsEmpty(input) ? null : JSON.stringify(input)) : `${input}`, } return super.invoke(arg, config) diff --git a/src/memory/vector-memory-collection.ts b/src/memory/vector-memory-collection.ts index 6c0b207..018b6db 100644 --- a/src/memory/vector-memory-collection.ts +++ b/src/memory/vector-memory-collection.ts @@ -136,18 +136,21 @@ export class VectorMemoryCollection { * @param args Optional arguments to pass. * @returns The id of the added point. */ - addPoint(content: string, vector: number[], metadata?: Record, id = randomUUID(), ...args: Parameters['1'][]) { - return vectorDb.upsert(this.name, { - points: [{ - id: id ?? randomUUID(), - vector, - payload: { - pageContent: content, - metadata, - }, - }], + async addPoint(content: string, vector: number[], metadata?: Record, id = randomUUID(), ...args: Parameters['1'][]) { + const point: PointData = { + id: id ?? randomUUID(), + vector, + payload: { + pageContent: content, + metadata, + }, + } + const res = await vectorDb.upsert(this.name, { + points: [point], ...args, }) + if (res.status === 'completed') return point + else return undefined } /** @@ -155,8 +158,8 @@ export class VectorMemoryCollection { * @param points An array of {@link PointData} representing the points to be added. * @returns The result of the upsert operation. */ - addPoints(points: PointData[]) { - return vectorDb.upsert(this.name, { points }) + addPoints(points: PointData[], ...args: Parameters['1'][]) { + return vectorDb.upsert(this.name, { points, ...args }) } /** diff --git a/src/rabbit-hole.ts b/src/rabbit-hole.ts index 4a3c267..fd13045 100644 --- a/src/rabbit-hole.ts +++ b/src/rabbit-hole.ts @@ -219,7 +219,7 @@ export class RabbitHole { } else log.warn(`Skipped memory insertion of empty document (${index}/${docs.length})`) doc = madHatter.executeHook('afterInsertInMemory', doc, stray) - await sleep(1000) + await sleep(500) } docs = madHatter.executeHook('afterStoreDocuments', docs, stray) stray.send({ type: 'notification', content: `Finished reading ${source}. I made ${docs.length} thoughts about it.` }) diff --git a/src/utils.ts b/src/utils.ts index 6957186..0e2316b 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -165,9 +165,9 @@ export function getRandomString(length: number) { * @throws If the JSON string is invalid or does not match the schema. */ export async function parseJson(text: string, schema: T, addDefaults = false) { - text = text.trim().replace(/^['"]|['"]$/g, '').replace('\_', '_').replace('\-', '-') text = text.replace(/^```(json)?|```$/g, '').trim() text += text.endsWith('}') ? '' : '}' + text = text.replace(/^['"]|['"]$/g, '').replace('\_', '_').replace('\-', '-') const merged = addDefaults ? defu(safeDestr(text), getZodDefaults(schema)) : safeDestr(text) return await schema.parseAsync(merged) as z.infer }