diff --git a/main.ts b/main.ts index 59dd731..3311617 100644 --- a/main.ts +++ b/main.ts @@ -24,6 +24,13 @@ interface CannoliSettings { ollamaBaseUrl: string; ollamaModel: string; ollamaTemperature: number; + azureAPIKey: string; + azureModel: string; + azureTemperature: number; + azureOpenAIApiDeploymentName: string; + azureOpenAIApiInstanceName: string; + azureOpenAIApiVersion: string; + azureBaseURL: string; geminiModel: string; geminiAPIKey: string; geminiTemperature: number; @@ -56,6 +63,13 @@ const DEFAULT_SETTINGS: CannoliSettings = { ollamaBaseUrl: "http://127.0.0.1:11434", ollamaModel: "llama2", ollamaTemperature: 1, + azureModel: "", + azureAPIKey: "", + azureTemperature: 1, + azureOpenAIApiDeploymentName: "", + azureOpenAIApiInstanceName: "", + azureOpenAIApiVersion: "", + azureBaseURL: "", geminiModel: "gemini-1.0-pro-latest", geminiAPIKey: "", geminiTemperature: 1, @@ -456,6 +470,16 @@ export default class Cannoli extends Plugin { temperature: this.settings.defaultTemperature, baseURL: this.settings.openaiBaseURL, }; + case "azure_openai": + return { + apiKey: this.settings.azureAPIKey, + model: this.settings.azureModel, + temperature: this.settings.azureTemperature, + azureOpenAIApiDeploymentName: this.settings.azureOpenAIApiDeploymentName, + azureOpenAIApiInstanceName: this.settings.azureOpenAIApiInstanceName, + azureOpenAIApiVersion: this.settings.azureOpenAIApiVersion, + baseURL: this.settings.azureBaseURL, + }; case "ollama": return { baseURL: this.settings.ollamaBaseUrl, @@ -495,6 +519,15 @@ export default class Cannoli extends Plugin { }); break; } + case "azure_openai": { + const config = getConfigByProvider("azure_openai"); + llm = new LLMProvider({ + provider: "azure_openai", + baseConfig: config, + getDefaultConfigByProvider: getConfigByProvider, + }); + break; + } case "ollama": { const config = getConfigByProvider("ollama"); llm = new LLMProvider({ @@ -1018,6 +1051,7 @@ class CannoliSettingTab extends PluginSettingTab { ) .addDropdown((dropdown) => { dropdown.addOption("openai", "OpenAI"); + dropdown.addOption("azure_openai", "Azure OpenAI"); dropdown.addOption("ollama", "Ollama"); dropdown.addOption("gemini", "Gemini"); dropdown.addOption("anthropic", "Anthropic"); @@ -1137,6 +1171,127 @@ class CannoliSettingTab extends PluginSettingTab { await this.plugin.saveSettings(); }) ); + } else if (this.plugin.settings.llmProvider === "azure_openai") { + // azure openai api key setting + new Setting(containerEl) + .setName("Azure OpenAI API key") + .setDesc( + "This key will be used to make all Azure OpenAI LLM calls. Be aware that complex cannolis, can be expensive to run." + ) + .addText((text) => + text + .setValue(this.plugin.settings.azureAPIKey) + .setPlaceholder("sk-...") + .onChange(async (value) => { + this.plugin.settings.azureAPIKey = value; + await this.plugin.saveSettings(); + }).inputEl.setAttribute("type", "password") + ); + // azure openai model setting + new Setting(containerEl) + .setName("Azure OpenAI model") + .setDesc( + "This model will be used for all LLM nodes unless overridden with a config arrow." + ) + .addText((text) => + text + .setValue(this.plugin.settings.azureModel) + .onChange(async (value) => { + this.plugin.settings.azureModel = value; + await this.plugin.saveSettings(); + }) + ); + // Default LLM temperature setting + new Setting(containerEl) + .setName("LLM temperature") + .setDesc( + "This temperature will be used for all LLM nodes unless overridden with a config arrow." + ) + .addText((text) => + text + .setValue( + !isNaN(this.plugin.settings.azureTemperature) && + this.plugin.settings.azureTemperature + ? this.plugin.settings.azureTemperature.toString() + : DEFAULT_SETTINGS.azureTemperature.toString() + ) + .onChange(async (value) => { + // If it's not empty and it's a number, save it + if (!isNaN(parseFloat(value))) { + this.plugin.settings.azureTemperature = + parseFloat(value); + await this.plugin.saveSettings(); + } else { + // Otherwise, reset it to the default + this.plugin.settings.azureTemperature = + DEFAULT_SETTINGS.azureTemperature; + await this.plugin.saveSettings(); + } + }) + ); + // azure openai api deployment name setting + new Setting(containerEl) + .setName("Azure OpenAI API deployment name") + .setDesc( + "This deployment will be used to make all Azure OpenAI LLM calls." + ) + .addText((text) => + text + .setValue(this.plugin.settings.azureOpenAIApiDeploymentName) + .setPlaceholder("deployment-name") + .onChange(async (value) => { + this.plugin.settings.azureOpenAIApiDeploymentName = value; + await this.plugin.saveSettings(); + }) + ); + + // azure openai api instance name setting + new Setting(containerEl) + .setName("Azure OpenAI API instance name") + .setDesc( + "This instance will be used to make all Azure OpenAI LLM calls." + ) + .addText((text) => + text + .setValue(this.plugin.settings.azureOpenAIApiInstanceName) + .setPlaceholder("instance-name") + .onChange(async (value) => { + this.plugin.settings.azureOpenAIApiInstanceName = value; + await this.plugin.saveSettings(); + }) + ); + + // azure openai api version setting + new Setting(containerEl) + .setName("Azure OpenAI API version") + .setDesc( + "This version will be used to make all Azure OpenAI LLM calls. Be aware that complex cannolis, can be expensive to run." + ) + .addText((text) => + text + .setValue(this.plugin.settings.azureOpenAIApiVersion) + .setPlaceholder("xxxx-xx-xx") + .onChange(async (value) => { + this.plugin.settings.azureOpenAIApiVersion = value; + await this.plugin.saveSettings(); + }) + ); + + // azure base url setting + new Setting(containerEl) + .setName("Azure base url") + .setDesc( + "This url will be used to make azure openai llm calls against a different endpoint. This is useful for switching to an azure enterprise endpoint, or, some other openai compatible service." + ) + .addText((text) => + text + .setValue(this.plugin.settings.azureBaseURL) + .setPlaceholder("https://api.openai.com/v1/") + .onChange(async (value) => { + this.plugin.settings.azureBaseURL = value; + await this.plugin.saveSettings(); + }) + ); } else if (this.plugin.settings.llmProvider === "ollama") { // ollama base url setting new Setting(containerEl) diff --git a/package-lock.json b/package-lock.json index e4699a3..b45fe4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,15 +9,15 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@langchain/anthropic": "^0.1.16", - "@langchain/community": "^0.0.52", - "@langchain/core": "^0.1.60", - "@langchain/google-genai": "^0.0.12", - "@langchain/groq": "^0.0.8", - "@langchain/openai": "^0.0.28", + "@langchain/anthropic": "0.2.1", + "@langchain/community": "0.2.12", + "@langchain/core": "0.2.7", + "@langchain/google-genai": "0.0.19", + "@langchain/groq": "0.0.12", + "@langchain/openai": "0.1.3", "esbuild-plugin-wat": "^0.2.7", "js-yaml": "^4.1.0", - "langchain": "^0.1.36", + "langchain": "0.2.5", "obsidian-dataview": "^0.5.66", "openai": "^4.24.1", "p-limit": "^4.0.0", @@ -48,38 +48,6 @@ "node": ">=0.10.0" } }, - "node_modules/@anthropic-ai/sdk": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.9.1.tgz", - "integrity": "sha512-wa1meQ2WSfoY8Uor3EdrJq0jTiZJoKoSii2ZVWRY1oN4Tlr5s59pADg9T79FTbPe1/se5c3pBeZgJL63wmuoBA==", - "dependencies": { - "@types/node": "^18.11.18", - "@types/node-fetch": "^2.6.4", - "abort-controller": "^3.0.0", - "agentkeepalive": "^4.2.1", - "digest-fetch": "^1.3.0", - "form-data-encoder": "1.7.2", - "formdata-node": "^4.3.2", - "node-fetch": "^2.6.7", - "web-streams-polyfill": "^3.2.1" - } - }, - "node_modules/@anthropic-ai/sdk/node_modules/@types/node": { - "version": "18.19.31", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.31.tgz", - "integrity": "sha512-ArgCD39YpyyrtFKIqMDvjz79jto5fcI/SVUs2HwB+f0dAzq68yqOdyaSivLiLugSziTpNXLQrVb7RZFmdZzbhA==", - "dependencies": { - "undici-types": "~5.26.4" - } - }, - "node_modules/@anthropic-ai/sdk/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==", - "engines": { - "node": ">= 8" - } - }, "node_modules/@codemirror/language": { "version": "6.10.1", "resolved": "git+ssh://git@github.com/lishid/cm-language.git#2644bfc27afda707a7e1f3aedaf3ca7120f63cd9", @@ -558,12 +526,13 @@ "dev": true }, "node_modules/@langchain/anthropic": { - "version": "0.1.16", - "resolved": "https://registry.npmjs.org/@langchain/anthropic/-/anthropic-0.1.16.tgz", - "integrity": "sha512-vCbwkZ3pkMSKf67fBgNlslvuW9f3EZGBbO8Ic2etgX3xFl6L0WuMtfS26P1FCDpRwaKuC1BrCj2aLAeMzMq/Fg==", + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@langchain/anthropic/-/anthropic-0.2.1.tgz", + "integrity": "sha512-HoN8uHks0dnA8yK6sWO6Oz3N4c5YxLAGhNzxxAD4bIBnmD2ZvQq54Skjxh+m0ANkbjH7yJwRqU3HJyIhOUeLtA==", + "license": "MIT", "dependencies": { - "@anthropic-ai/sdk": "^0.20.1", - "@langchain/core": "~0.1.56", + "@anthropic-ai/sdk": "^0.21.0", + "@langchain/core": ">=0.2.5 <0.3.0", "fast-xml-parser": "^4.3.5", "zod": "^3.22.4", "zod-to-json-schema": "^3.22.4" @@ -573,9 +542,10 @@ } }, "node_modules/@langchain/anthropic/node_modules/@anthropic-ai/sdk": { - "version": "0.20.7", - "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.20.7.tgz", - "integrity": "sha512-uyc+3WGLpe8ur6mSIKSab7P9JdBerTdmqb7popc/yROYLLCW/Ykyw4ZfjmN/cLmxjnAKnv5YUngzbPM0BJuGjg==", + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.21.1.tgz", + "integrity": "sha512-fqdt74RTdplnaFOYhwNjjK/Ec09Dqv9ekYr7PuC6GdhV1RWkziqbpJBewn42CYYqCr92JeX6g+IXVgXmq9l7XQ==", + "license": "MIT", "dependencies": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", @@ -588,9 +558,10 @@ } }, "node_modules/@langchain/anthropic/node_modules/@types/node": { - "version": "18.19.31", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.31.tgz", - "integrity": "sha512-ArgCD39YpyyrtFKIqMDvjz79jto5fcI/SVUs2HwB+f0dAzq68yqOdyaSivLiLugSziTpNXLQrVb7RZFmdZzbhA==", + "version": "18.19.37", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.37.tgz", + "integrity": "sha512-Pi53fdVMk7Ig5IfAMltQQMgtY7xLzHaEous8IQasYsdQbYK3v90FkxI3XYQCe/Qme58pqp14lXJIsFmGP8VoZQ==", + "license": "MIT", "dependencies": { "undici-types": "~5.26.4" } @@ -599,20 +570,25 @@ "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/@langchain/community": { - "version": "0.0.52", - "resolved": "https://registry.npmjs.org/@langchain/community/-/community-0.0.52.tgz", - "integrity": "sha512-L+IMAAaLNP7++4HhdvuVJegc8bdw8WP77Jvp98YcySFZTZWH1yasSQSlFn3jgBk+3xLBsudpTZuttKTrZ/TtVQ==", + "version": "0.2.12", + "resolved": "https://registry.npmjs.org/@langchain/community/-/community-0.2.12.tgz", + "integrity": "sha512-bFhWNyPXqd/V2fduJ6BWipEkAQQHLnGs6IqKmxJMf7FvhN16DfhWK/PpPrNUltE/b5cl5gDuTzdpEsyvuw7fHg==", + "license": "MIT", "dependencies": { - "@langchain/core": "~0.1.60", - "@langchain/openai": "~0.0.28", + "@langchain/core": "~0.2.6", + "@langchain/openai": "~0.1.0", + "binary-extensions": "^2.2.0", "expr-eval": "^2.0.2", "flat": "^5.0.2", - "langsmith": "~0.1.1", + "js-yaml": "^4.1.0", + "langchain": "0.2.3", + "langsmith": "~0.1.30", "uuid": "^9.0.0", "zod": "^3.22.3", "zod-to-json-schema": "^3.22.5" @@ -622,55 +598,69 @@ }, "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", "@aws-sdk/client-lambda": "^3.310.0", + "@aws-sdk/client-s3": "^3.310.0", "@aws-sdk/client-sagemaker-runtime": "^3.310.0", "@aws-sdk/client-sfn": "^3.310.0", "@aws-sdk/credential-provider-node": "^3.388.0", "@azure/search-documents": "^12.0.0", + "@azure/storage-blob": "^12.15.0", + "@browserbasehq/sdk": "*", "@clickhouse/client": "^0.2.5", "@cloudflare/ai": "*", "@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", + "@layerup/layerup-security": "^1.5.12", + "@mendable/firecrawl-js": "^0.0.13", + "@mlc-ai/web-llm": "0.2.46", "@mozilla/readability": "*", "@neondatabase/serverless": "*", + "@notionhq/client": "^2.2.10", "@opensearch-project/opensearch": "*", "@pinecone-database/pinecone": "*", "@planetscale/database": "^1.8.0", "@premai/prem-sdk": "^0.3.25", - "@qdrant/js-client-rest": "^1.2.0", + "@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", + "@spider-cloud/spider-client": "^0.0.21", "@supabase/postgrest-js": "^1.1.1", "@supabase/supabase-js": "^2.10.0", "@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", "@xata.io/client": "^0.28.0", "@xenova/transformers": "^2.5.4", - "@zilliz/milvus2-sdk-node": ">=2.2.7", - "better-sqlite3": "^9.4.0", + "@zilliz/milvus2-sdk-node": ">=2.3.5", + "apify-client": "^2.7.1", + "assemblyai": "^4.0.0", + "better-sqlite3": ">=9.4.0 <12.0.0", "cassandra-driver": "^4.7.2", "cborg": "^4.1.1", + "cheerio": "^1.0.0-rc.12", "chromadb": "*", "closevector-common": "0.1.3", "closevector-node": "0.1.6", @@ -678,15 +668,19 @@ "cohere-ai": "*", "convex": "^1.3.1", "couchbase": "^4.3.0", + "crypto-js": "^4.2.0", + "d3-dsv": "^2.0.0", "discord.js": "^14.14.1", "dria": "^0.0.3", "duck-duck-scrape": "^2.2.5", + "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", + "ignore": "^5.2.0", "interface-datastore": "^8.2.11", "ioredis": "^5.3.2", "it-all": "^3.0.4", @@ -695,24 +689,34 @@ "llmonitor": "^0.5.9", "lodash": "^4.17.21", "lunary": "^0.6.11", + "mammoth": "^1.6.0", "mongodb": ">=5.2.0", "mysql2": "^3.3.3", "neo4j-driver": "*", "node-llama-cpp": "*", + "notion-to-md": "^3.1.0", + "officeparser": "^4.0.4", + "pdf-parse": "1.1.1", "pg": "^8.11.0", "pg-copy-streams": "^6.0.5", "pickleparser": "^0.2.1", + "playwright": "^1.32.1", "portkey-ai": "^0.1.11", + "puppeteer": "^19.7.2", "redis": "*", - "replicate": "^0.18.0", - "typeorm": "^0.3.12", + "replicate": "^0.29.4", + "sonix-speech-recognition": "^2.1.1", + "srt-parser-2": "^1.2.3", + "typeorm": "^0.3.20", "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" + "ws": "^8.14.2", + "youtube-transcript": "^1.0.6", + "youtubei.js": "^9.1.0" }, "peerDependenciesMeta": { "@aws-crypto/sha256-js": { @@ -733,6 +737,9 @@ "@aws-sdk/client-lambda": { "optional": true }, + "@aws-sdk/client-s3": { + "optional": true + }, "@aws-sdk/client-sagemaker-runtime": { "optional": true }, @@ -745,6 +752,12 @@ "@azure/search-documents": { "optional": true }, + "@azure/storage-blob": { + "optional": true + }, + "@browserbasehq/sdk": { + "optional": true + }, "@clickhouse/client": { "optional": true }, @@ -760,6 +773,9 @@ "@getmetal/metal-sdk": { "optional": true }, + "@getzep/zep-cloud": { + "optional": true + }, "@getzep/zep-js": { "optional": true }, @@ -772,18 +788,33 @@ "@google-ai/generativelanguage": { "optional": true }, + "@google-cloud/storage": { + "optional": true + }, "@gradientai/nodejs-sdk": { "optional": true }, "@huggingface/inference": { "optional": true }, + "@layerup/layerup-security": { + "optional": true + }, + "@mendable/firecrawl-js": { + "optional": true + }, + "@mlc-ai/web-llm": { + "optional": true + }, "@mozilla/readability": { "optional": true }, "@neondatabase/serverless": { "optional": true }, + "@notionhq/client": { + "optional": true + }, "@opensearch-project/opensearch": { "optional": true }, @@ -817,6 +848,9 @@ "@smithy/util-utf8": { "optional": true }, + "@spider-cloud/spider-client": { + "optional": true + }, "@supabase/postgrest-js": { "optional": true }, @@ -832,6 +866,9 @@ "@tensorflow/tfjs-core": { "optional": true }, + "@upstash/ratelimit": { + "optional": true + }, "@upstash/redis": { "optional": true }, @@ -856,6 +893,12 @@ "@zilliz/milvus2-sdk-node": { "optional": true }, + "apify-client": { + "optional": true + }, + "assemblyai": { + "optional": true + }, "better-sqlite3": { "optional": true }, @@ -865,6 +908,9 @@ "cborg": { "optional": true }, + "cheerio": { + "optional": true + }, "chromadb": { "optional": true }, @@ -886,6 +932,12 @@ "couchbase": { "optional": true }, + "crypto-js": { + "optional": true + }, + "d3-dsv": { + "optional": true + }, "discord.js": { "optional": true }, @@ -895,6 +947,9 @@ "duck-duck-scrape": { "optional": true }, + "epub2": { + "optional": true + }, "faiss-node": { "optional": true }, @@ -913,6 +968,9 @@ "html-to-text": { "optional": true }, + "ignore": { + "optional": true + }, "interface-datastore": { "optional": true }, @@ -937,6 +995,9 @@ "lunary": { "optional": true }, + "mammoth": { + "optional": true + }, "mongodb": { "optional": true }, @@ -949,6 +1010,15 @@ "node-llama-cpp": { "optional": true }, + "notion-to-md": { + "optional": true + }, + "officeparser": { + "optional": true + }, + "pdf-parse": { + "optional": true + }, "pg": { "optional": true }, @@ -958,15 +1028,27 @@ "pickleparser": { "optional": true }, + "playwright": { + "optional": true + }, "portkey-ai": { "optional": true }, + "puppeteer": { + "optional": true + }, "redis": { "optional": true }, "replicate": { "optional": true }, + "sonix-speech-recognition": { + "optional": true + }, + "srt-parser-2": { + "optional": true + }, "typeorm": { "optional": true }, @@ -990,19 +1072,272 @@ }, "ws": { "optional": true + }, + "youtube-transcript": { + "optional": true + }, + "youtubei.js": { + "optional": true } } }, + "node_modules/@langchain/community/node_modules/langchain": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/langchain/-/langchain-0.2.3.tgz", + "integrity": "sha512-T9xR7zd+Nj0oXy6WoYKmZLy0DlQiDLFPGYWdOXDxy+AvqlujoPdVQgDSpdqiOHvAjezrByAoKxoHCz5XMwTP/Q==", + "license": "MIT", + "dependencies": { + "@langchain/core": "~0.2.0", + "@langchain/openai": "~0.0.28", + "@langchain/textsplitters": "~0.0.0", + "binary-extensions": "^2.2.0", + "js-tiktoken": "^1.0.12", + "js-yaml": "^4.1.0", + "jsonpointer": "^5.0.1", + "langchainhub": "~0.0.8", + "langsmith": "~0.1.7", + "ml-distance": "^4.0.0", + "openapi-types": "^12.1.3", + "p-retry": "4", + "uuid": "^9.0.0", + "yaml": "^2.2.1", + "zod": "^3.22.4", + "zod-to-json-schema": "^3.22.3" + }, + "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", + "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 + } + } + }, + "node_modules/@langchain/community/node_modules/langchain/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/core": { - "version": "0.1.60", - "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.1.60.tgz", - "integrity": "sha512-3EJW4ir0tFe17AakpXCgO9flSoDjFELpSQs2w/CMZ5FBlHYxo3ODgVQAZvlHy97khEVgcnvlL3EDhPE7IdNibA==", + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.2.7.tgz", + "integrity": "sha512-FdFiNWhszFuUyAhYdY+l5DtPnAnWCAjXMnkLmUJ1J54NeUiUm7gy26Hnd4bkvaOQJ8ddHH/EX03ZwdoYfLv1jw==", + "license": "MIT", "dependencies": { "ansi-styles": "^5.0.0", "camelcase": "6", "decamelize": "1.2.0", - "js-tiktoken": "^1.0.8", - "langsmith": "~0.1.7", + "js-tiktoken": "^1.0.12", + "langsmith": "~0.1.30", "ml-distance": "^4.0.0", "mustache": "^4.2.0", "p-queue": "^6.6.2", @@ -1027,23 +1362,26 @@ } }, "node_modules/@langchain/google-genai": { - "version": "0.0.12", - "resolved": "https://registry.npmjs.org/@langchain/google-genai/-/google-genai-0.0.12.tgz", - "integrity": "sha512-NDARJ+ZxjlkTHDvNroiG6V+3gW0u0OlMvbDEYAAXR6wFGIV09//ekolr+bA290ZCN77Ei+BEOsd6Ax1wBk3Z4w==", + "version": "0.0.19", + "resolved": "https://registry.npmjs.org/@langchain/google-genai/-/google-genai-0.0.19.tgz", + "integrity": "sha512-TPHdWQef4xxBtXoHAUIrgaWlKgr9YgAYS4put69uc2Luuynown0eQGkZEN1mCPIb0u8bBrJMdN/eXgWu01JrDw==", + "license": "MIT", "dependencies": { "@google/generative-ai": "^0.7.0", - "@langchain/core": "~0.1.5" + "@langchain/core": ">=0.2.5 <0.3.0", + "zod-to-json-schema": "^3.22.4" }, "engines": { "node": ">=18" } }, "node_modules/@langchain/groq": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/@langchain/groq/-/groq-0.0.8.tgz", - "integrity": "sha512-xqbe35K+12fiYtC/uqkaTT4AXxqL5uvhCrHzc+nBoFkTwM6YfTFE1ch95RZ5G2JnK1U9pKAre/trUSzlU1/6Kg==", + "version": "0.0.12", + "resolved": "https://registry.npmjs.org/@langchain/groq/-/groq-0.0.12.tgz", + "integrity": "sha512-qgrVBdUnK9Qe8fzMc9gmMPGzc/8swDYbQuHoqsZmeK7M3wxEPR60rKdZvbbkFzqn+1NdquyRTeVKSgihPCib5Q==", + "license": "MIT", "dependencies": { - "@langchain/core": "~0.1.56", + "@langchain/core": ">0.1.56 <0.3.0", "@langchain/openai": "~0.0.28", "groq-sdk": "^0.3.2", "zod": "^3.22.4", @@ -1053,14 +1391,31 @@ "node": ">=18" } }, + "node_modules/@langchain/groq/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/openai": { - "version": "0.0.28", - "resolved": "https://registry.npmjs.org/@langchain/openai/-/openai-0.0.28.tgz", - "integrity": "sha512-2s1RA3/eAnz4ahdzsMPBna9hfAqpFNlWdHiPxVGZ5yrhXsbLWWoPcF+22LCk9t0HJKtazi2GCIWc0HVXH9Abig==", + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@langchain/openai/-/openai-0.1.3.tgz", + "integrity": "sha512-riv/JC9x2A8b7GcHu8sx+mlZJ8KAwSSi231IPTlcciYnKozmrQ5H0vrtiD31fxiDbaRsk7tyCpkSBIOQEo7CyQ==", + "license": "MIT", "dependencies": { - "@langchain/core": "~0.1.56", - "js-tiktoken": "^1.0.7", - "openai": "^4.32.1", + "@langchain/core": ">=0.2.5 <0.3.0", + "js-tiktoken": "^1.0.12", + "openai": "^4.49.1", "zod": "^3.22.4", "zod-to-json-schema": "^3.22.3" }, @@ -1080,6 +1435,41 @@ "node": ">=18" } }, + "node_modules/@langchain/textsplitters/node_modules/@langchain/core": { + "version": "0.1.63", + "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.1.63.tgz", + "integrity": "sha512-+fjyYi8wy6x1P+Ee1RWfIIEyxd9Ee9jksEwvrggPwwI/p45kIDTdYTblXsM13y4mNWTiACyLSdbwnPaxxdoz+w==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^5.0.0", + "camelcase": "6", + "decamelize": "1.2.0", + "js-tiktoken": "^1.0.12", + "langsmith": "~0.1.7", + "ml-distance": "^4.0.0", + "mustache": "^4.2.0", + "p-queue": "^6.6.2", + "p-retry": "4", + "uuid": "^9.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/@lezer/common": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.2.1.tgz", @@ -2607,9 +2997,10 @@ "dev": true }, "node_modules/js-tiktoken": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/js-tiktoken/-/js-tiktoken-1.0.11.tgz", - "integrity": "sha512-PajXFLq2vx7/8jllQZ43vzNpAai/0MOVdJjW/UrNyJorNQRTjHrqdGJG/mjHVy7h9M6dW6CaG43eNLMYFkTh6w==", + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/js-tiktoken/-/js-tiktoken-1.0.12.tgz", + "integrity": "sha512-L7wURW1fH9Qaext0VzaUDpFGVQgjkdE3Dgsy9/+yXyGEpBKnylTd0mU0bfbNkKDlXRb6TEsZkwuflu1B8uQbJQ==", + "license": "MIT", "dependencies": { "base64-js": "^1.5.1" } @@ -2661,21 +3052,20 @@ } }, "node_modules/langchain": { - "version": "0.1.36", - "resolved": "https://registry.npmjs.org/langchain/-/langchain-0.1.36.tgz", - "integrity": "sha512-NTbnCL/jKWIeEI//Nm1oG8nhW3vkYWvEMr1MPotmTThTfeKfO87eV/OAzAyh6Ruy6GFs/qofRgQZGIe6XvXTNQ==", + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/langchain/-/langchain-0.2.5.tgz", + "integrity": "sha512-H5WL0NanCdQ+tzoeEt7Fyz9YGdR3wbfDvfQrJvxAO95istKo5JraRh24dzyvqxM9439xwRMNaMIpMwsyqtWDtQ==", + "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/core": "~0.2.0", + "@langchain/openai": "~0.1.0", "@langchain/textsplitters": "~0.0.0", "binary-extensions": "^2.2.0", - "js-tiktoken": "^1.0.7", + "js-tiktoken": "^1.0.12", "js-yaml": "^4.1.0", "jsonpointer": "^5.0.1", "langchainhub": "~0.0.8", - "langsmith": "~0.1.7", + "langsmith": "~0.1.30", "ml-distance": "^4.0.0", "openapi-types": "^12.1.3", "p-retry": "4", @@ -2693,11 +3083,10 @@ "@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": "*", @@ -2714,7 +3103,6 @@ "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", @@ -2756,6 +3144,9 @@ "@azure/storage-blob": { "optional": true }, + "@browserbasehq/sdk": { + "optional": true + }, "@gomomento/sdk": { "optional": true }, @@ -2765,12 +3156,6 @@ "@gomomento/sdk-web": { "optional": true }, - "@google-ai/generativelanguage": { - "optional": true - }, - "@google-cloud/storage": { - "optional": true - }, "@mendable/firecrawl-js": { "optional": true }, @@ -2822,9 +3207,6 @@ "fast-xml-parser": { "optional": true }, - "google-auth-library": { - "optional": true - }, "handlebars": { "optional": true }, @@ -2905,15 +3287,32 @@ "integrity": "sha512-Woyb8YDHgqqTOZvWIbm2CaFDGfZ4NTSyXV687AG4vXEfoNo7cGQp7nhl7wL3ehenKWmNEmcxCLgOZzW8jE6lOQ==" }, "node_modules/langsmith": { - "version": "0.1.18", - "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.1.18.tgz", - "integrity": "sha512-LHk0aIFAl3/iiKvUzAiM8Xdm13bRO70XERQeHCF99fL2X815Jc47nxu6m7usSuQC8sw6rirCKZbGm18cqdUEzA==", + "version": "0.1.32", + "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.1.32.tgz", + "integrity": "sha512-EUWHIH6fiOCGRYdzgwGoXwJxCMyUrL+bmUcxoVmkXoXoAGDOVinz8bqJLKbxotsQWqM64NKKsW85OTIutgNaMQ==", + "license": "MIT", "dependencies": { "@types/uuid": "^9.0.1", "commander": "^10.0.1", "p-queue": "^6.6.2", "p-retry": "4", "uuid": "^9.0.0" + }, + "peerDependencies": { + "@langchain/core": "*", + "langchain": "*", + "openai": "*" + }, + "peerDependenciesMeta": { + "@langchain/core": { + "optional": true + }, + "langchain": { + "optional": true + }, + "openai": { + "optional": true + } } }, "node_modules/levn": { @@ -3280,9 +3679,10 @@ } }, "node_modules/openai": { - "version": "4.38.5", - "resolved": "https://registry.npmjs.org/openai/-/openai-4.38.5.tgz", - "integrity": "sha512-Ym5GJL98ZhLJJ7enBx53jjG3vwN/fsB+Ozh46nnRZZS9W1NiYqbwkJ+sXd3dkCIiWIgcyyOPL2Zr8SQAzbpj3g==", + "version": "4.52.0", + "resolved": "https://registry.npmjs.org/openai/-/openai-4.52.0.tgz", + "integrity": "sha512-xmiNcdA9QJ5wffHpZDpIsge6AsPTETJ6h5iqDNuFQ7qGSNtonHn8Qe0VHy4UwLE8rBWiSqh4j+iSvuYZSeKkPg==", + "license": "Apache-2.0", "dependencies": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", @@ -4019,37 +4419,6 @@ "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", "dev": true }, - "@anthropic-ai/sdk": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.9.1.tgz", - "integrity": "sha512-wa1meQ2WSfoY8Uor3EdrJq0jTiZJoKoSii2ZVWRY1oN4Tlr5s59pADg9T79FTbPe1/se5c3pBeZgJL63wmuoBA==", - "requires": { - "@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" - }, - "dependencies": { - "@types/node": { - "version": "18.19.31", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.31.tgz", - "integrity": "sha512-ArgCD39YpyyrtFKIqMDvjz79jto5fcI/SVUs2HwB+f0dAzq68yqOdyaSivLiLugSziTpNXLQrVb7RZFmdZzbhA==", - "requires": { - "undici-types": "~5.26.4" - } - }, - "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==" - } - } - }, "@codemirror/language": { "version": "git+ssh://git@github.com/lishid/cm-language.git#2644bfc27afda707a7e1f3aedaf3ca7120f63cd9", "from": "@codemirror/language@git+https://github.com/lishid/cm-language.git", @@ -4298,21 +4667,21 @@ "dev": true }, "@langchain/anthropic": { - "version": "0.1.16", - "resolved": "https://registry.npmjs.org/@langchain/anthropic/-/anthropic-0.1.16.tgz", - "integrity": "sha512-vCbwkZ3pkMSKf67fBgNlslvuW9f3EZGBbO8Ic2etgX3xFl6L0WuMtfS26P1FCDpRwaKuC1BrCj2aLAeMzMq/Fg==", + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@langchain/anthropic/-/anthropic-0.2.1.tgz", + "integrity": "sha512-HoN8uHks0dnA8yK6sWO6Oz3N4c5YxLAGhNzxxAD4bIBnmD2ZvQq54Skjxh+m0ANkbjH7yJwRqU3HJyIhOUeLtA==", "requires": { - "@anthropic-ai/sdk": "^0.20.1", - "@langchain/core": "~0.1.56", + "@anthropic-ai/sdk": "^0.21.0", + "@langchain/core": ">=0.2.5 <0.3.0", "fast-xml-parser": "^4.3.5", "zod": "^3.22.4", "zod-to-json-schema": "^3.22.4" }, "dependencies": { "@anthropic-ai/sdk": { - "version": "0.20.7", - "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.20.7.tgz", - "integrity": "sha512-uyc+3WGLpe8ur6mSIKSab7P9JdBerTdmqb7popc/yROYLLCW/Ykyw4ZfjmN/cLmxjnAKnv5YUngzbPM0BJuGjg==", + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.21.1.tgz", + "integrity": "sha512-fqdt74RTdplnaFOYhwNjjK/Ec09Dqv9ekYr7PuC6GdhV1RWkziqbpJBewn42CYYqCr92JeX6g+IXVgXmq9l7XQ==", "requires": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", @@ -4325,9 +4694,9 @@ } }, "@types/node": { - "version": "18.19.31", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.31.tgz", - "integrity": "sha512-ArgCD39YpyyrtFKIqMDvjz79jto5fcI/SVUs2HwB+f0dAzq68yqOdyaSivLiLugSziTpNXLQrVb7RZFmdZzbhA==", + "version": "18.19.37", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.37.tgz", + "integrity": "sha512-Pi53fdVMk7Ig5IfAMltQQMgtY7xLzHaEous8IQasYsdQbYK3v90FkxI3XYQCe/Qme58pqp14lXJIsFmGP8VoZQ==", "requires": { "undici-types": "~5.26.4" } @@ -4340,30 +4709,72 @@ } }, "@langchain/community": { - "version": "0.0.52", - "resolved": "https://registry.npmjs.org/@langchain/community/-/community-0.0.52.tgz", - "integrity": "sha512-L+IMAAaLNP7++4HhdvuVJegc8bdw8WP77Jvp98YcySFZTZWH1yasSQSlFn3jgBk+3xLBsudpTZuttKTrZ/TtVQ==", + "version": "0.2.12", + "resolved": "https://registry.npmjs.org/@langchain/community/-/community-0.2.12.tgz", + "integrity": "sha512-bFhWNyPXqd/V2fduJ6BWipEkAQQHLnGs6IqKmxJMf7FvhN16DfhWK/PpPrNUltE/b5cl5gDuTzdpEsyvuw7fHg==", "requires": { - "@langchain/core": "~0.1.60", - "@langchain/openai": "~0.0.28", + "@langchain/core": "~0.2.6", + "@langchain/openai": "~0.1.0", + "binary-extensions": "^2.2.0", "expr-eval": "^2.0.2", "flat": "^5.0.2", - "langsmith": "~0.1.1", + "js-yaml": "^4.1.0", + "langchain": "0.2.3", + "langsmith": "~0.1.30", "uuid": "^9.0.0", "zod": "^3.22.3", "zod-to-json-schema": "^3.22.5" + }, + "dependencies": { + "langchain": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/langchain/-/langchain-0.2.3.tgz", + "integrity": "sha512-T9xR7zd+Nj0oXy6WoYKmZLy0DlQiDLFPGYWdOXDxy+AvqlujoPdVQgDSpdqiOHvAjezrByAoKxoHCz5XMwTP/Q==", + "requires": { + "@langchain/core": "~0.2.0", + "@langchain/openai": "~0.0.28", + "@langchain/textsplitters": "~0.0.0", + "binary-extensions": "^2.2.0", + "js-tiktoken": "^1.0.12", + "js-yaml": "^4.1.0", + "jsonpointer": "^5.0.1", + "langchainhub": "~0.0.8", + "langsmith": "~0.1.7", + "ml-distance": "^4.0.0", + "openapi-types": "^12.1.3", + "p-retry": "4", + "uuid": "^9.0.0", + "yaml": "^2.2.1", + "zod": "^3.22.4", + "zod-to-json-schema": "^3.22.3" + }, + "dependencies": { + "@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==", + "requires": { + "@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" + } + } + } + } } }, "@langchain/core": { - "version": "0.1.60", - "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.1.60.tgz", - "integrity": "sha512-3EJW4ir0tFe17AakpXCgO9flSoDjFELpSQs2w/CMZ5FBlHYxo3ODgVQAZvlHy97khEVgcnvlL3EDhPE7IdNibA==", + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.2.7.tgz", + "integrity": "sha512-FdFiNWhszFuUyAhYdY+l5DtPnAnWCAjXMnkLmUJ1J54NeUiUm7gy26Hnd4bkvaOQJ8ddHH/EX03ZwdoYfLv1jw==", "requires": { "ansi-styles": "^5.0.0", "camelcase": "6", "decamelize": "1.2.0", - "js-tiktoken": "^1.0.8", - "langsmith": "~0.1.7", + "js-tiktoken": "^1.0.12", + "langsmith": "~0.1.30", "ml-distance": "^4.0.0", "mustache": "^4.2.0", "p-queue": "^6.6.2", @@ -4381,34 +4792,49 @@ } }, "@langchain/google-genai": { - "version": "0.0.12", - "resolved": "https://registry.npmjs.org/@langchain/google-genai/-/google-genai-0.0.12.tgz", - "integrity": "sha512-NDARJ+ZxjlkTHDvNroiG6V+3gW0u0OlMvbDEYAAXR6wFGIV09//ekolr+bA290ZCN77Ei+BEOsd6Ax1wBk3Z4w==", + "version": "0.0.19", + "resolved": "https://registry.npmjs.org/@langchain/google-genai/-/google-genai-0.0.19.tgz", + "integrity": "sha512-TPHdWQef4xxBtXoHAUIrgaWlKgr9YgAYS4put69uc2Luuynown0eQGkZEN1mCPIb0u8bBrJMdN/eXgWu01JrDw==", "requires": { "@google/generative-ai": "^0.7.0", - "@langchain/core": "~0.1.5" + "@langchain/core": ">=0.2.5 <0.3.0", + "zod-to-json-schema": "^3.22.4" } }, "@langchain/groq": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/@langchain/groq/-/groq-0.0.8.tgz", - "integrity": "sha512-xqbe35K+12fiYtC/uqkaTT4AXxqL5uvhCrHzc+nBoFkTwM6YfTFE1ch95RZ5G2JnK1U9pKAre/trUSzlU1/6Kg==", + "version": "0.0.12", + "resolved": "https://registry.npmjs.org/@langchain/groq/-/groq-0.0.12.tgz", + "integrity": "sha512-qgrVBdUnK9Qe8fzMc9gmMPGzc/8swDYbQuHoqsZmeK7M3wxEPR60rKdZvbbkFzqn+1NdquyRTeVKSgihPCib5Q==", "requires": { - "@langchain/core": "~0.1.56", + "@langchain/core": ">0.1.56 <0.3.0", "@langchain/openai": "~0.0.28", "groq-sdk": "^0.3.2", "zod": "^3.22.4", "zod-to-json-schema": "^3.22.5" + }, + "dependencies": { + "@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==", + "requires": { + "@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" + } + } } }, "@langchain/openai": { - "version": "0.0.28", - "resolved": "https://registry.npmjs.org/@langchain/openai/-/openai-0.0.28.tgz", - "integrity": "sha512-2s1RA3/eAnz4ahdzsMPBna9hfAqpFNlWdHiPxVGZ5yrhXsbLWWoPcF+22LCk9t0HJKtazi2GCIWc0HVXH9Abig==", + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@langchain/openai/-/openai-0.1.3.tgz", + "integrity": "sha512-riv/JC9x2A8b7GcHu8sx+mlZJ8KAwSSi231IPTlcciYnKozmrQ5H0vrtiD31fxiDbaRsk7tyCpkSBIOQEo7CyQ==", "requires": { - "@langchain/core": "~0.1.56", - "js-tiktoken": "^1.0.7", - "openai": "^4.32.1", + "@langchain/core": ">=0.2.5 <0.3.0", + "js-tiktoken": "^1.0.12", + "openai": "^4.49.1", "zod": "^3.22.4", "zod-to-json-schema": "^3.22.3" } @@ -4420,6 +4846,32 @@ "requires": { "@langchain/core": "~0.1", "js-tiktoken": "^1.0.11" + }, + "dependencies": { + "@langchain/core": { + "version": "0.1.63", + "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.1.63.tgz", + "integrity": "sha512-+fjyYi8wy6x1P+Ee1RWfIIEyxd9Ee9jksEwvrggPwwI/p45kIDTdYTblXsM13y4mNWTiACyLSdbwnPaxxdoz+w==", + "requires": { + "ansi-styles": "^5.0.0", + "camelcase": "6", + "decamelize": "1.2.0", + "js-tiktoken": "^1.0.12", + "langsmith": "~0.1.7", + "ml-distance": "^4.0.0", + "mustache": "^4.2.0", + "p-queue": "^6.6.2", + "p-retry": "4", + "uuid": "^9.0.0", + "zod": "^3.22.4", + "zod-to-json-schema": "^3.22.3" + } + }, + "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==" + } } }, "@lezer/common": { @@ -5551,9 +6003,9 @@ "dev": true }, "js-tiktoken": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/js-tiktoken/-/js-tiktoken-1.0.11.tgz", - "integrity": "sha512-PajXFLq2vx7/8jllQZ43vzNpAai/0MOVdJjW/UrNyJorNQRTjHrqdGJG/mjHVy7h9M6dW6CaG43eNLMYFkTh6w==", + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/js-tiktoken/-/js-tiktoken-1.0.12.tgz", + "integrity": "sha512-L7wURW1fH9Qaext0VzaUDpFGVQgjkdE3Dgsy9/+yXyGEpBKnylTd0mU0bfbNkKDlXRb6TEsZkwuflu1B8uQbJQ==", "requires": { "base64-js": "^1.5.1" } @@ -5599,21 +6051,19 @@ } }, "langchain": { - "version": "0.1.36", - "resolved": "https://registry.npmjs.org/langchain/-/langchain-0.1.36.tgz", - "integrity": "sha512-NTbnCL/jKWIeEI//Nm1oG8nhW3vkYWvEMr1MPotmTThTfeKfO87eV/OAzAyh6Ruy6GFs/qofRgQZGIe6XvXTNQ==", + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/langchain/-/langchain-0.2.5.tgz", + "integrity": "sha512-H5WL0NanCdQ+tzoeEt7Fyz9YGdR3wbfDvfQrJvxAO95istKo5JraRh24dzyvqxM9439xwRMNaMIpMwsyqtWDtQ==", "requires": { - "@anthropic-ai/sdk": "^0.9.1", - "@langchain/community": "~0.0.47", - "@langchain/core": "~0.1.60", - "@langchain/openai": "~0.0.28", + "@langchain/core": "~0.2.0", + "@langchain/openai": "~0.1.0", "@langchain/textsplitters": "~0.0.0", "binary-extensions": "^2.2.0", - "js-tiktoken": "^1.0.7", + "js-tiktoken": "^1.0.12", "js-yaml": "^4.1.0", "jsonpointer": "^5.0.1", "langchainhub": "~0.0.8", - "langsmith": "~0.1.7", + "langsmith": "~0.1.30", "ml-distance": "^4.0.0", "openapi-types": "^12.1.3", "p-retry": "4", @@ -5629,9 +6079,9 @@ "integrity": "sha512-Woyb8YDHgqqTOZvWIbm2CaFDGfZ4NTSyXV687AG4vXEfoNo7cGQp7nhl7wL3ehenKWmNEmcxCLgOZzW8jE6lOQ==" }, "langsmith": { - "version": "0.1.18", - "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.1.18.tgz", - "integrity": "sha512-LHk0aIFAl3/iiKvUzAiM8Xdm13bRO70XERQeHCF99fL2X815Jc47nxu6m7usSuQC8sw6rirCKZbGm18cqdUEzA==", + "version": "0.1.32", + "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.1.32.tgz", + "integrity": "sha512-EUWHIH6fiOCGRYdzgwGoXwJxCMyUrL+bmUcxoVmkXoXoAGDOVinz8bqJLKbxotsQWqM64NKKsW85OTIutgNaMQ==", "requires": { "@types/uuid": "^9.0.1", "commander": "^10.0.1", @@ -5920,9 +6370,9 @@ } }, "openai": { - "version": "4.38.5", - "resolved": "https://registry.npmjs.org/openai/-/openai-4.38.5.tgz", - "integrity": "sha512-Ym5GJL98ZhLJJ7enBx53jjG3vwN/fsB+Ozh46nnRZZS9W1NiYqbwkJ+sXd3dkCIiWIgcyyOPL2Zr8SQAzbpj3g==", + "version": "4.52.0", + "resolved": "https://registry.npmjs.org/openai/-/openai-4.52.0.tgz", + "integrity": "sha512-xmiNcdA9QJ5wffHpZDpIsge6AsPTETJ6h5iqDNuFQ7qGSNtonHn8Qe0VHy4UwLE8rBWiSqh4j+iSvuYZSeKkPg==", "requires": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", diff --git a/package.json b/package.json index 405d575..4096169 100644 --- a/package.json +++ b/package.json @@ -28,15 +28,15 @@ "typescript": "^5.3.3" }, "dependencies": { - "@langchain/anthropic": "^0.1.16", - "@langchain/community": "^0.0.52", - "@langchain/core": "^0.1.60", - "@langchain/google-genai": "^0.0.12", - "@langchain/groq": "^0.0.8", - "@langchain/openai": "^0.0.28", + "@langchain/anthropic": "0.2.1", + "@langchain/community": "0.2.12", + "@langchain/core": "0.2.7", + "@langchain/google-genai": "0.0.19", + "@langchain/groq": "0.0.12", + "@langchain/openai": "0.1.3", "esbuild-plugin-wat": "^0.2.7", "js-yaml": "^4.1.0", - "langchain": "^0.1.36", + "langchain": "0.2.5", "obsidian-dataview": "^0.5.66", "openai": "^4.24.1", "p-limit": "^4.0.0", diff --git a/src/providers.ts b/src/providers.ts index 2e279b1..9b949ef 100644 --- a/src/providers.ts +++ b/src/providers.ts @@ -1,6 +1,6 @@ -import { ChatOpenAI } from "@langchain/openai"; -import { OllamaFunctions } from "langchain/experimental/chat_models/ollama_functions"; +import { ChatOpenAI, AzureChatOpenAI } from "@langchain/openai"; import { ChatOllama } from "@langchain/community/chat_models/ollama"; +import { OllamaFunctions } from "@langchain/community/experimental/chat_models/ollama_functions"; import { ChatGoogleGenerativeAI } from "@langchain/google-genai"; import { BaseChatModel } from "@langchain/core/language_models/chat_models"; import { ChatGroq } from "@langchain/groq"; @@ -16,7 +16,7 @@ import { messagesWithFnCallPrompts } from "src/fn_calling"; const stringParser = new StringOutputParser(); -export type SupportedProviders = "openai" | "ollama" | "gemini" | "anthropic" | "groq"; +export type SupportedProviders = "openai" | "ollama" | "gemini" | "anthropic" | "groq" | "azure_openai"; export type GenericFunctionCall = { name: string; @@ -53,6 +53,10 @@ export type GenericModelConfig = { seed?: number; tfs_z?: number; num_predict?: number; + + azureOpenAIApiDeploymentName?: string, + azureOpenAIApiInstanceName?: string, + azureOpenAIApiVersion?: string, }; type ConstructorArgs = { @@ -104,7 +108,7 @@ export type GetDefaultsByProvider = (provider: SupportedProviders) => GenericMod export type LangchainMessages = ReturnType; -const SUPPORTED_FN_PROVIDERS = ["openai", "ollama"]; +const SUPPORTED_FN_PROVIDERS = ["openai", "ollama", "azure_openai"]; const removeUndefinedKeys = >(obj: T): T => { Object.keys(obj).forEach((key: keyof T) => obj[key] === undefined && delete obj[key]); @@ -169,6 +173,9 @@ export class LLMProvider { ): BaseChatModel => { const config = this.getMergedConfig(args); const provider = config.provider; + const [urlString, queryString] = config.baseURL?.split("?") || [undefined, undefined]; + const url = urlString || undefined; + const query = queryString ? Object.fromEntries(new URLSearchParams(queryString).entries()) : undefined switch (provider) { case "openai": return new ChatOpenAI({ @@ -176,7 +183,24 @@ export class LLMProvider { model: config.model, temperature: config.temperature, configuration: { - baseURL: config.baseURL, + baseURL: url, + defaultQuery: query + } + }); + case "azure_openai": + return new AzureChatOpenAI({ + temperature: config.temperature, + model: config.model, + apiKey: config.apiKey, + azureOpenAIApiKey: config.apiKey, + azureOpenAIApiDeploymentName: config.azureOpenAIApiDeploymentName, + azureOpenAIApiInstanceName: config.azureOpenAIApiInstanceName, + azureOpenAIApiVersion: config.azureOpenAIApiVersion, + azureOpenAIBasePath: url, + maxRetries: 3, + configuration: { + baseURL: url, + defaultQuery: query, } }); case "ollama":