diff --git a/package-lock.json b/package-lock.json index 56c6b27..bf94bc1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@aleph-sdk/client": "^1.0.6", "@aleph-sdk/ethereum": "^1.0.3", "@aleph-sdk/message": "^1.0.7", - "@libertai/libertai-js": "0.0.9", + "@libertai/libertai-js": "file:../libertai-js/libertai-libertai-js-0.0.10.tgz", "@quasar/extras": "^1.16.12", "@tanstack/vue-query": "^5.51.21", "@wagmi/vue": "^0.0.34", @@ -166,32 +166,6 @@ "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==", - "license": "MIT", - "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.42", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.42.tgz", - "integrity": "sha512-d2ZFc/3lnK2YCYhos8iaNIYu9Vfhr92nHiyJHRltXWjXUBjEE+A4I58Tdbnw4VhggSW+2j5y5gTrLs4biNnubg==", - "license": "MIT", - "dependencies": { - "undici-types": "~5.26.4" - } - }, "node_modules/@babel/code-frame": { "version": "7.24.7", "license": "MIT", @@ -3701,6 +3675,8 @@ "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.1.63.tgz", "integrity": "sha512-+fjyYi8wy6x1P+Ee1RWfIIEyxd9Ee9jksEwvrggPwwI/p45kIDTdYTblXsM13y4mNWTiACyLSdbwnPaxxdoz+w==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "ansi-styles": "^5.0.0", "camelcase": "6", @@ -3724,6 +3700,8 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", "license": "MIT", + "optional": true, + "peer": true, "engines": { "node": ">=10" }, @@ -3740,26 +3718,12 @@ "https://github.com/sponsors/ctavan" ], "license": "MIT", + "optional": true, + "peer": true, "bin": { "uuid": "dist/bin/uuid" } }, - "node_modules/@langchain/openai": { - "version": "0.0.34", - "resolved": "https://registry.npmjs.org/@langchain/openai/-/openai-0.0.34.tgz", - "integrity": "sha512-M+CW4oXle5fdoz2T2SwdOef8pl3/1XmUx1vjn2mXUVM/128aO0l23FMF0SNBsAbRV6P+p/TuzjodchJbi0Ht/A==", - "license": "MIT", - "dependencies": { - "@langchain/core": ">0.1.56 <0.3.0", - "js-tiktoken": "^1.0.12", - "openai": "^4.41.1", - "zod": "^3.22.4", - "zod-to-json-schema": "^3.22.3" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/@langchain/textsplitters": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/@langchain/textsplitters/-/textsplitters-0.0.3.tgz", @@ -3774,719 +3738,50 @@ } }, "node_modules/@langchain/textsplitters/node_modules/@langchain/core": { - "version": "0.2.18", - "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.2.18.tgz", - "integrity": "sha512-ru542BwNcsnDfjTeDbIkFIchwa54ctHZR+kVrC8U9NPS9/36iM8p8ruprOV7Zccj/oxtLE5UpEhV+9MZhVcFlA==", - "license": "MIT", - "dependencies": { - "ansi-styles": "^5.0.0", - "camelcase": "6", - "decamelize": "1.2.0", - "js-tiktoken": "^1.0.12", - "langsmith": "~0.1.39", - "ml-distance": "^4.0.0", - "mustache": "^4.2.0", - "p-queue": "^6.6.2", - "p-retry": "4", - "uuid": "^10.0.0", - "zod": "^3.22.4", - "zod-to-json-schema": "^3.22.3" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@langchain/textsplitters/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==", - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@libertai/libertai-js": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/@libertai/libertai-js/-/libertai-js-0.0.9.tgz", - "integrity": "sha512-k1DMnzH72XdPyPKCagcMY6e/pDtUWfDYmg9tB9WjTDFSYKHuXA7DorI0hK63HoKcaLvt2meXcpQlU2aeIVp6dg==", - "license": "MIT", - "dependencies": { - "axios": "^1.7.2", - "langchain": "^0.1.37", - "localforage": "^1.10.0", - "ml-distance": "^4.0.1", - "uuid": "^10.0.0" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@libertai/libertai-js/node_modules/@langchain/community": { - "version": "0.0.57", - "resolved": "https://registry.npmjs.org/@langchain/community/-/community-0.0.57.tgz", - "integrity": "sha512-tib4UJNkyA4TPNsTNChiBtZmThVJBr7X/iooSmKeCr+yUEha2Yxly3A4OAO95Vlpj4Q+od8HAfCbZih/1XqAMw==", - "license": "MIT", - "dependencies": { - "@langchain/core": "~0.1.60", - "@langchain/openai": "~0.0.28", - "expr-eval": "^2.0.2", - "flat": "^5.0.2", - "langsmith": "~0.1.1", - "uuid": "^9.0.0", - "zod": "^3.22.3", - "zod-to-json-schema": "^3.22.5" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "@aws-crypto/sha256-js": "^5.0.0", - "@aws-sdk/client-bedrock-agent-runtime": "^3.485.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-sagemaker-runtime": "^3.310.0", - "@aws-sdk/client-sfn": "^3.310.0", - "@aws-sdk/credential-provider-node": "^3.388.0", - "@azure/search-documents": "^12.0.0", - "@clickhouse/client": "^0.2.5", - "@cloudflare/ai": "*", - "@datastax/astra-db-ts": "^1.0.0", - "@elastic/elasticsearch": "^8.4.0", - "@getmetal/metal-sdk": "*", - "@getzep/zep-js": "^0.9.0", - "@gomomento/sdk": "^1.51.1", - "@gomomento/sdk-core": "^1.51.1", - "@google-ai/generativelanguage": "^0.2.1", - "@gradientai/nodejs-sdk": "^1.2.0", - "@huggingface/inference": "^2.6.4", - "@mlc-ai/web-llm": "^0.2.35", - "@mozilla/readability": "*", - "@neondatabase/serverless": "*", - "@opensearch-project/opensearch": "*", - "@pinecone-database/pinecone": "*", - "@planetscale/database": "^1.8.0", - "@premai/prem-sdk": "^0.3.25", - "@qdrant/js-client-rest": "^1.8.2", - "@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", - "@upstash/vector": "^1.0.7", - "@vercel/kv": "^0.2.3", - "@vercel/postgres": "^0.5.0", - "@writerai/writer-sdk": "^0.40.2", - "@xata.io/client": "^0.28.0", - "@xenova/transformers": "^2.5.4", - "@zilliz/milvus2-sdk-node": ">=2.2.7", - "better-sqlite3": "^9.4.0", - "cassandra-driver": "^4.7.2", - "cborg": "^4.1.1", - "chromadb": "*", - "closevector-common": "0.1.3", - "closevector-node": "0.1.6", - "closevector-web": "0.1.6", - "cohere-ai": "*", - "convex": "^1.3.1", - "couchbase": "^4.3.0", - "discord.js": "^14.14.1", - "dria": "^0.0.3", - "duck-duck-scrape": "^2.2.5", - "faiss-node": "^0.5.1", - "firebase-admin": "^11.9.0 || ^12.0.0", - "google-auth-library": "^8.9.0", - "googleapis": "^126.0.1", - "hnswlib-node": "^3.0.0", - "html-to-text": "^9.0.5", - "interface-datastore": "^8.2.11", - "ioredis": "^5.3.2", - "it-all": "^3.0.4", - "jsdom": "*", - "jsonwebtoken": "^9.0.2", - "llmonitor": "^0.5.9", - "lodash": "^4.17.21", - "lunary": "^0.6.11", - "mongodb": ">=5.2.0", - "mysql2": "^3.3.3", - "neo4j-driver": "*", - "node-llama-cpp": "*", - "pg": "^8.11.0", - "pg-copy-streams": "^6.0.5", - "pickleparser": "^0.2.1", - "portkey-ai": "^0.1.11", - "redis": "*", - "replicate": "^0.18.0", - "typeorm": "^0.3.12", - "typesense": "^1.5.3", - "usearch": "^1.1.1", - "vectordb": "^0.1.4", - "voy-search": "0.6.2", - "weaviate-ts-client": "*", - "web-auth-library": "^1.0.3", - "ws": "^8.14.2" - }, - "peerDependenciesMeta": { - "@aws-crypto/sha256-js": { - "optional": true - }, - "@aws-sdk/client-bedrock-agent-runtime": { - "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-sagemaker-runtime": { - "optional": true - }, - "@aws-sdk/client-sfn": { - "optional": true - }, - "@aws-sdk/credential-provider-node": { - "optional": true - }, - "@azure/search-documents": { - "optional": true - }, - "@clickhouse/client": { - "optional": true - }, - "@cloudflare/ai": { - "optional": true - }, - "@datastax/astra-db-ts": { - "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 - }, - "@google-ai/generativelanguage": { - "optional": true - }, - "@gradientai/nodejs-sdk": { - "optional": true - }, - "@huggingface/inference": { - "optional": true - }, - "@mlc-ai/web-llm": { - "optional": true - }, - "@mozilla/readability": { - "optional": true - }, - "@neondatabase/serverless": { - "optional": true - }, - "@opensearch-project/opensearch": { - "optional": true - }, - "@pinecone-database/pinecone": { - "optional": true - }, - "@planetscale/database": { - "optional": true - }, - "@premai/prem-sdk": { - "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 - }, - "@upstash/vector": { - "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 - }, - "better-sqlite3": { - "optional": true - }, - "cassandra-driver": { - "optional": true - }, - "cborg": { - "optional": true - }, - "chromadb": { - "optional": true - }, - "closevector-common": { - "optional": true - }, - "closevector-node": { - "optional": true - }, - "closevector-web": { - "optional": true - }, - "cohere-ai": { - "optional": true - }, - "convex": { - "optional": true - }, - "couchbase": { - "optional": true - }, - "discord.js": { - "optional": true - }, - "dria": { - "optional": true - }, - "duck-duck-scrape": { - "optional": true - }, - "faiss-node": { - "optional": true - }, - "firebase-admin": { - "optional": true - }, - "google-auth-library": { - "optional": true - }, - "googleapis": { - "optional": true - }, - "hnswlib-node": { - "optional": true - }, - "html-to-text": { - "optional": true - }, - "interface-datastore": { - "optional": true - }, - "ioredis": { - "optional": true - }, - "it-all": { - "optional": true - }, - "jsdom": { - "optional": true - }, - "jsonwebtoken": { - "optional": true - }, - "llmonitor": { - "optional": true - }, - "lodash": { - "optional": true - }, - "lunary": { - "optional": true - }, - "mongodb": { - "optional": true - }, - "mysql2": { - "optional": true - }, - "neo4j-driver": { - "optional": true - }, - "node-llama-cpp": { - "optional": true - }, - "pg": { - "optional": true - }, - "pg-copy-streams": { - "optional": true - }, - "pickleparser": { - "optional": true - }, - "portkey-ai": { - "optional": true - }, - "redis": { - "optional": true - }, - "replicate": { - "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 - } - } - }, - "node_modules/@libertai/libertai-js/node_modules/@langchain/community/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" - ], - "license": "MIT", - "bin": { - "uuid": "dist/bin/uuid" - } - }, - "node_modules/@libertai/libertai-js/node_modules/langchain": { - "version": "0.1.37", - "resolved": "https://registry.npmjs.org/langchain/-/langchain-0.1.37.tgz", - "integrity": "sha512-rpaLEJtRrLYhAViEp7/aHfSkxbgSqHJ5n10tXv3o4kHP/wOin85RpTgewwvGjEaKc3797jOg+sLSk6a7e0UlMg==", + "version": "0.2.18", + "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.2.18.tgz", + "integrity": "sha512-ru542BwNcsnDfjTeDbIkFIchwa54ctHZR+kVrC8U9NPS9/36iM8p8ruprOV7Zccj/oxtLE5UpEhV+9MZhVcFlA==", "license": "MIT", "dependencies": { - "@anthropic-ai/sdk": "^0.9.1", - "@langchain/community": "~0.0.47", - "@langchain/core": "~0.1.60", - "@langchain/openai": "~0.0.28", - "@langchain/textsplitters": "~0.0.0", - "binary-extensions": "^2.2.0", - "js-tiktoken": "^1.0.7", - "js-yaml": "^4.1.0", - "jsonpointer": "^5.0.1", - "langchainhub": "~0.0.8", - "langsmith": "~0.1.7", + "ansi-styles": "^5.0.0", + "camelcase": "6", + "decamelize": "1.2.0", + "js-tiktoken": "^1.0.12", + "langsmith": "~0.1.39", "ml-distance": "^4.0.0", - "openapi-types": "^12.1.3", + "mustache": "^4.2.0", + "p-queue": "^6.6.2", "p-retry": "4", - "uuid": "^9.0.0", - "yaml": "^2.2.1", + "uuid": "^10.0.0", "zod": "^3.22.4", "zod-to-json-schema": "^3.22.3" }, "engines": { "node": ">=18" + } + }, + "node_modules/@langchain/textsplitters/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==", + "license": "MIT", + "engines": { + "node": ">=10" }, - "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", - "@google-ai/generativelanguage": "^0.2.1", - "@google-cloud/storage": "^6.10.1 || ^7.7.0", - "@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", - "fast-xml-parser": "*", - "google-auth-library": "^8.9.0", - "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 - }, - "@google-ai/generativelanguage": { - "optional": true - }, - "@google-cloud/storage": { - "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 - }, - "google-auth-library": { - "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 - } + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/@libertai/libertai-js/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" - ], + "node_modules/@libertai/libertai-js": { + "version": "0.0.10", + "resolved": "file:../libertai-js/libertai-libertai-js-0.0.10.tgz", + "integrity": "sha512-bjR2fqo60fy3GXQwVjJ9b6IpS1XOpazba/hcNX5hvmdt4QQrQVblrhjizSh2QkAckW9l4ohC2+OMZhiorAXqzg==", "license": "MIT", - "bin": { - "uuid": "dist/bin/uuid" + "dependencies": { + "axios": "^1.7.3" + }, + "engines": { + "node": ">=18.0.0" } }, "node_modules/@lit-labs/ssr-dom-shim": { @@ -8414,11 +7709,6 @@ "version": "1.0.2", "license": "MIT" }, - "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/base-x": { "version": "3.0.10", "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.10.tgz", @@ -8987,15 +8277,6 @@ "dev": true, "license": "MIT" }, - "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==", - "license": "BSD-3-Clause", - "engines": { - "node": "*" - } - }, "node_modules/chokidar": { "version": "3.6.0", "license": "MIT", @@ -9800,15 +9081,6 @@ } } }, - "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==", - "license": "BSD-3-Clause", - "engines": { - "node": "*" - } - }, "node_modules/crypto-browserify": { "version": "3.12.0", "dev": true, @@ -10045,16 +9317,6 @@ "randombytes": "^2.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==", - "license": "ISC", - "dependencies": { - "base-64": "^0.1.0", - "md5": "^2.3.0" - } - }, "node_modules/dijkstrajs": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz", @@ -10867,12 +10129,6 @@ "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, - "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==", - "license": "MIT" - }, "node_modules/express": { "version": "4.19.2", "dev": true, @@ -11234,6 +10490,7 @@ }, "node_modules/flat": { "version": "5.0.2", + "dev": true, "license": "BSD-3-Clause", "bin": { "flat": "cli.js" @@ -12036,12 +11293,6 @@ "node": ">=8" } }, - "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==", - "license": "MIT" - }, "node_modules/is-callable": { "version": "1.2.7", "license": "MIT", @@ -13356,7 +12607,7 @@ }, "node_modules/lodash": { "version": "4.17.21", - "devOptional": true, + "dev": true, "license": "MIT" }, "node_modules/lodash.debounce": { @@ -13666,17 +12917,6 @@ "license": "Apache-2.0", "peer": true }, - "node_modules/md5": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", - "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", - "license": "BSD-3-Clause", - "dependencies": { - "charenc": "0.0.2", - "crypt": "0.0.2", - "is-buffer": "~1.1.6" - } - }, "node_modules/md5.js": { "version": "1.3.5", "license": "MIT", @@ -18424,15 +17664,6 @@ "defaults": "^1.0.3" } }, - "node_modules/web-streams-polyfill": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", - "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", - "license": "MIT", - "engines": { - "node": ">= 8" - } - }, "node_modules/web3": { "version": "4.11.1", "license": "LGPL-3.0", diff --git a/package.json b/package.json index 4a2425b..d851e31 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "@aleph-sdk/client": "^1.0.6", "@aleph-sdk/ethereum": "^1.0.3", "@aleph-sdk/message": "^1.0.7", - "@libertai/libertai-js": "0.0.9", + "@libertai/libertai-js": "file:../libertai-js/libertai-libertai-js-0.0.10.tgz", "@quasar/extras": "^1.16.12", "@tanstack/vue-query": "^5.51.21", "@wagmi/vue": "^0.0.34", diff --git a/src/components/dialog/KnowledgeBaseRenameDialog.vue b/src/components/dialog/KnowledgeBaseRenameDialog.vue new file mode 100644 index 0000000..43bc22e --- /dev/null +++ b/src/components/dialog/KnowledgeBaseRenameDialog.vue @@ -0,0 +1,27 @@ + + diff --git a/src/pages/Chat.vue b/src/pages/Chat.vue index a37e9dc..6148016 100644 --- a/src/pages/Chat.vue +++ b/src/pages/Chat.vue @@ -121,6 +121,7 @@ import dayjs from 'dayjs'; import LtaiIcon from 'components/libertai/LtaiIcon.vue'; import { searchDocuments } from 'src/utils/knowledge/embedding'; import { useKnowledgeStore } from 'stores/knowledge'; +import { KnowledgeSearchResult } from 'src/types/knowledge'; const $q = useQuasar(); const route = useRoute(); @@ -215,24 +216,17 @@ async function generatePersonaMessage() { // Set loading state isLoadingRef.value = true; - let searchResultMessages: Message[] = []; + let knowledgeSearchResults: KnowledgeSearchResult[] = []; // Finding related knowledge document chunks if (knowledgeBaseIds.length > 0) { const documents = knowledgeStore.getDocumentsFrom(knowledgeBaseIds); const lastUserMessage = messages.findLast((message) => message.author === 'user')!; - const searchResults = await searchDocuments(lastUserMessage.content, documents); - console.log(searchResults); - searchResultMessages = searchResults.map( - (result): Message => ({ - role: 'search-result', - content: result.content, - }), - ); + knowledgeSearchResults = await searchDocuments(lastUserMessage.content, documents); } // Expand all the messages to inline any compatible attachments - const expandedMessages = messages + const allMessages = messages .map((message: UIMessage): Message[] => { const ret = []; // Push any attachments as messages ahead of the message itself @@ -249,11 +243,15 @@ async function generatePersonaMessage() { }) .flat(); - // Append the search results to the messages - const allMessages: Message[] = [...expandedMessages, ...searchResultMessages]; - // Generate a stream of responses from the AI - for await (const output of inferenceEngine.generateAnswer(allMessages, model, persona, username, false)) { + for await (const output of inferenceEngine.generateAnswer( + allMessages, + model, + persona, + knowledgeSearchResults.map((result) => result.content), + username, + false, + )) { const stopped = output.stopped; let content = output.content; if (!stopped) { diff --git a/src/pages/KnowledgeBase.vue b/src/pages/KnowledgeBase.vue index 8c1070a..fc8665d 100644 --- a/src/pages/KnowledgeBase.vue +++ b/src/pages/KnowledgeBase.vue @@ -4,7 +4,31 @@
-

{{ knowledgeBaseRef.name }}

+
+

{{ knowledgeBaseRef.name }}

+ + + + + + + + + Rename + + + + + + + + Delete + + + + +
+
- + + - Are you sure you want to delete the the document {{ selectedDocument!.name }}? + Are you sure you want to delete the document {{ selectedDocument!.name }}? + + + + + + + + Are you sure you want to delete the knowledge base "{{ knowledgeBaseRef.name }}" ? @@ -113,6 +154,7 @@ import LtaiDialog from 'components/libertai/LtaiDialog.vue'; import KnowledgeBaseRenameDocumentDialog from 'components/dialog/KnowledgeBaseRenameDocumentDialog.vue'; import { processDocument } from 'src/utils/knowledge/document'; import { decryptFile, encryptFile } from 'src/utils/encryption'; +import KnowledgeBaseRenameDialog from 'components/dialog/KnowledgeBaseRenameDialog.vue'; const $q = useQuasar(); const route = useRoute(); @@ -125,6 +167,8 @@ const knowledgeStore = useKnowledgeStore(); const knowledgeBaseRef = ref(undefined); const knowledgeBaseIdentifierRef = ref(undefined); const selectedDocument = ref(undefined); +const showRenameKnowledgeBase = ref(false); +const showDeleteKnowledgeBaseConfirmation = ref(false); const showRenameDocument = ref(false); const showDeleteDocumentConfirmation = ref(false); @@ -228,11 +272,7 @@ const downloadDocument = async (document: KnowledgeDocument) => { }; const renameDocument = async (document: KnowledgeDocument, newName: string) => { - if ( - knowledgeBaseRef.value === undefined || - knowledgeBaseIdentifierRef.value === undefined || - accountStore.alephStorage === null - ) { + if (knowledgeBaseRef.value === undefined || knowledgeBaseIdentifierRef.value === undefined) { return; } @@ -256,6 +296,23 @@ const renameDocument = async (document: KnowledgeDocument, newName: string) => { }; const deleteDocument = async (document: KnowledgeDocument) => { + if (knowledgeBaseRef.value === undefined || knowledgeBaseIdentifierRef.value === undefined) { + return; + } + + try { + await knowledgeStore.deleteKnowledgeDocument(document, knowledgeBaseRef.value, knowledgeBaseIdentifierRef.value); + + knowledgeBaseRef.value.documents = knowledgeBaseRef.value.documents.filter((d) => d.id !== document.id); + } catch (error) { + $q.notify({ + message: (error as Error)?.message ?? 'Document deletion failed, please try again', + color: 'negative', + }); + } +}; + +const renameKnowledgeBase = async (newName: string) => { if ( knowledgeBaseRef.value === undefined || knowledgeBaseIdentifierRef.value === undefined || @@ -265,18 +322,38 @@ const deleteDocument = async (document: KnowledgeDocument) => { } try { - await accountStore.alephStorage.deleteFile(document.store.item_hash); - - knowledgeBaseRef.value.documents = knowledgeBaseRef.value.documents.filter((d) => d.id !== document.id); await knowledgeStore.updateKnowledgeBase( - JSON.parse(JSON.stringify(knowledgeBaseRef.value)), + JSON.parse(JSON.stringify({ ...knowledgeBaseRef.value, name: newName })), knowledgeBaseIdentifierRef.value, ); + + knowledgeBaseRef.value.name = newName; } catch (error) { $q.notify({ - message: (error as Error)?.message ?? 'Document deletion failed, please try again', + message: (error as Error)?.message ?? 'Knowledge base renaming failed, please try again', + color: 'negative', + }); + } +}; + +const deleteKnowledgeBase = async () => { + if ( + knowledgeBaseRef.value === undefined || + knowledgeBaseIdentifierRef.value === undefined || + accountStore.alephStorage === null + ) { + return; + } + + const success = await knowledgeStore.deleteKnowledgeBase(knowledgeBaseRef.value, knowledgeBaseIdentifierRef.value); + if (!success) { + $q.notify({ + message: 'Knowledge base deletion failed, please try again', color: 'negative', }); + return; } + + await router.push({ path: '/knowledge-base' }); }; diff --git a/src/stores/knowledge.ts b/src/stores/knowledge.ts index d3c8391..3d0340c 100644 --- a/src/stores/knowledge.ts +++ b/src/stores/knowledge.ts @@ -79,5 +79,41 @@ export const useKnowledgeStore = defineStore('knowledge', { return knowledgeBase; }); }, + + async deleteKnowledgeDocument( + document: KnowledgeDocument, + knowledgeBase: KnowledgeBase, + kbIdentifier: KnowledgeBaseIdentifier, + updateKnowledgeBase: boolean = true, + ) { + const { alephStorage } = useAccountStore(); + if (alephStorage === null) { + return; + } + + await alephStorage.deleteFile(document.store.item_hash); + if (updateKnowledgeBase) { + await this.updateKnowledgeBase(knowledgeBase, kbIdentifier); + } + }, + + async deleteKnowledgeBase(knowledgeBase: KnowledgeBase, kbIdentifier: KnowledgeBaseIdentifier): Promise { + const { alephStorage } = useAccountStore(); + if (alephStorage === null) { + return false; + } + knowledgeBase.documents.forEach((document) => { + this.deleteKnowledgeDocument(document, knowledgeBase, kbIdentifier, false); + }); + + const success = await alephStorage.deleteKnowledgeBase(kbIdentifier, this.knowledgeBaseIdentifiers); + + if (!success) { + return success; + } + this.knowledgeBases = this.knowledgeBases.filter((kb) => kb.id !== knowledgeBase.id); + this.knowledgeBaseIdentifiers = this.knowledgeBaseIdentifiers.filter((kbi) => kbi.id !== kbIdentifier.id); + return success; + }, }, }); diff --git a/src/utils/aleph-persistent-storage.ts b/src/utils/aleph-persistent-storage.ts index 33cdb5a..027b133 100644 --- a/src/utils/aleph-persistent-storage.ts +++ b/src/utils/aleph-persistent-storage.ts @@ -279,4 +279,42 @@ export class AlephPersistentStorage { return undefined; } } + + async deleteKnowledgeBase( + kbIdentifier: KnowledgeBaseIdentifier, + currentKbIdentifiers: KnowledgeBaseIdentifier[], + ): Promise { + try { + await this.subAccountClient.forget({ + hashes: [kbIdentifier.post_hash], + }); + + const newKbIdentifiers: KnowledgeBaseIdentifier[] = [ + ...currentKbIdentifiers.filter((kbi) => kbi.id !== kbIdentifier.id), + ].map((kbi) => ({ + ...kbi, + encryption: { + key: eciesEncrypt(this.encryptionPrivateKey.publicKey.toHex(), Buffer.from(kbi.encryption.key)).toString( + BUFFER_ENCODING, + ), + iv: eciesEncrypt(this.encryptionPrivateKey.publicKey.toHex(), Buffer.from(kbi.encryption.iv)).toString( + BUFFER_ENCODING, + ), + }, + })); + + await this.subAccountClient.createAggregate({ + key: LIBERTAI_KNOWLEDGE_BASE_IDENTIFIERS_KEY, + content: { + data: newKbIdentifiers, + }, + address: this.account.address, + channel: LIBERTAI_CHANNEL, + }); + return true; + } catch (error) { + console.error(`Deleting knowledge base failed: ${error}`); + return false; + } + } } diff --git a/src/utils/knowledge/document.ts b/src/utils/knowledge/document.ts index 83a2f6b..b73d5f8 100644 --- a/src/utils/knowledge/document.ts +++ b/src/utils/knowledge/document.ts @@ -7,7 +7,7 @@ import { generateChunks } from 'src/utils/knowledge/embedding'; export const processDocument = async (file: File): Promise> => { const fileInfo = await extractFileContent(file); - const chunks = await generateChunks(fileInfo.content); + const chunks = await generateChunks(fileInfo.type, fileInfo.content); return { ...fileInfo, id: uuidv4(), name: file.name, size: file.size, chunks }; }; diff --git a/src/utils/knowledge/embedding.ts b/src/utils/knowledge/embedding.ts index dcfb213..b0cc0da 100644 --- a/src/utils/knowledge/embedding.ts +++ b/src/utils/knowledge/embedding.ts @@ -1,5 +1,5 @@ import axios from 'axios'; -import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter'; +import { MarkdownTextSplitter, RecursiveCharacterTextSplitter } from 'langchain/text_splitter'; import { KnowledgeDocument, KnowledgeDocumentChunk, KnowledgeSearchResult } from 'src/types/knowledge'; import { distance } from 'ml-distance'; @@ -7,15 +7,12 @@ const DEFAULT_EMBEDDING_API_URL = 'https://curated.aleph.cloud/vm/ee1b2a8e5bd645447739d8b234ef495c9a2b4d0b98317d510a3ccf822808ebe5/embedding'; export const generateChunks = async ( + fileType: string, content: string, - chunkSize = 500, - overlapSize = 100, + chunkSize: number = 500, + chunkOverlap: number = 100, ): Promise => { - const splitter = new RecursiveCharacterTextSplitter({ - chunkSize: chunkSize, - chunkOverlap: overlapSize, - separators: ['\n\n---\n\n', '\n\n', '\n', ' '], - }); + const splitter = getTextSplitter(fileType, chunkSize, chunkOverlap); // Split into a list of LangChain documents const documentChunks = await splitter.createDocuments( @@ -40,6 +37,23 @@ export const generateChunks = async ( return result; }; +const getTextSplitter = ( + fileType: string, + chunkSize: number, + chunkOverlap: number, +): MarkdownTextSplitter | RecursiveCharacterTextSplitter => { + switch (fileType) { + case 'text/markdown': + return new MarkdownTextSplitter(); + default: + return new RecursiveCharacterTextSplitter({ + chunkSize, + chunkOverlap, + separators: ['\n\n---\n\n', '\n\n', '\n', ' '], + }); + } +}; + export const searchDocuments = async ( query: string, documents: KnowledgeDocument[], @@ -67,7 +81,7 @@ export const searchDocuments = async ( async function embed(content: string): Promise { const tries = 3; - let timeout = 1000; + const timeout = 1000; const errors = []; for (let i = 0; i < tries; i++) { @@ -81,7 +95,6 @@ async function embed(content: string): Promise { errors.push(error); console.error(`Error embedding text: ${error}`); await new Promise((resolve) => setTimeout(resolve, timeout)); - timeout *= 2; } } return [];