From cc76721d86510da79344a074f17a9c64d78c9482 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Thu, 25 Jul 2024 00:12:19 +0800 Subject: [PATCH 01/11] fix typo of tutorials (#6191) --- docs/core_docs/docs/tutorials/llm_chain.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core_docs/docs/tutorials/llm_chain.ipynb b/docs/core_docs/docs/tutorials/llm_chain.ipynb index d5a83e50d681..59791535b5e8 100644 --- a/docs/core_docs/docs/tutorials/llm_chain.ipynb +++ b/docs/core_docs/docs/tutorials/llm_chain.ipynb @@ -76,7 +76,7 @@ "```{=mdx}\n", "import ChatModelTabs from \"@theme/ChatModelTabs\";\n", "\n", - "\n", + "\n", "```" ] }, From 02314656bb20761df89b8ceaa096175e25ed434e Mon Sep 17 00:00:00 2001 From: Jacob Lee Date: Wed, 24 Jul 2024 10:34:09 -0700 Subject: [PATCH 02/11] core[patch]: Use console.warn for swallowed errors in a callback handler (#6192) * Use console.warn for swallowed errors in a callback handler * Fix typo --- langchain-core/src/callbacks/manager.ts | 93 +++++++++++++++---- .../src/callbacks/tests/callbacks.test.ts | 18 ++++ 2 files changed, 92 insertions(+), 19 deletions(-) diff --git a/langchain-core/src/callbacks/manager.ts b/langchain-core/src/callbacks/manager.ts index 6e784c0f90f0..9a6cbe9405cf 100644 --- a/langchain-core/src/callbacks/manager.ts +++ b/langchain-core/src/callbacks/manager.ts @@ -140,7 +140,10 @@ export class BaseRunManager { this.tags ); } catch (err) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleText: ${err}` ); if (handler.raiseError) { @@ -185,7 +188,10 @@ export class CallbackManagerForRetrieverRun this.tags ); } catch (err) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleRetriever` ); if (handler.raiseError) { @@ -211,7 +217,10 @@ export class CallbackManagerForRetrieverRun this.tags ); } catch (error) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleRetrieverError: ${error}` ); if (handler.raiseError) { @@ -251,7 +260,10 @@ export class CallbackManagerForLLMRun fields ); } catch (err) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleLLMNewToken: ${err}` ); if (handler.raiseError) { @@ -277,7 +289,10 @@ export class CallbackManagerForLLMRun this.tags ); } catch (err) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleLLMError: ${err}` ); if (handler.raiseError) { @@ -303,7 +318,10 @@ export class CallbackManagerForLLMRun this.tags ); } catch (err) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleLLMEnd: ${err}` ); if (handler.raiseError) { @@ -353,7 +371,10 @@ export class CallbackManagerForChainRun kwargs ); } catch (err) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleChainError: ${err}` ); if (handler.raiseError) { @@ -386,7 +407,10 @@ export class CallbackManagerForChainRun kwargs ); } catch (err) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleChainEnd: ${err}` ); if (handler.raiseError) { @@ -412,7 +436,10 @@ export class CallbackManagerForChainRun this.tags ); } catch (err) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleAgentAction: ${err}` ); if (handler.raiseError) { @@ -438,7 +465,10 @@ export class CallbackManagerForChainRun this.tags ); } catch (err) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleAgentEnd: ${err}` ); if (handler.raiseError) { @@ -481,7 +511,10 @@ export class CallbackManagerForToolRun this.tags ); } catch (err) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleToolError: ${err}` ); if (handler.raiseError) { @@ -508,7 +541,10 @@ export class CallbackManagerForToolRun this.tags ); } catch (err) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleToolEnd: ${err}` ); if (handler.raiseError) { @@ -640,7 +676,10 @@ export class CallbackManager runName ); } catch (err) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleLLMStart: ${err}` ); if (handler.raiseError) { @@ -727,7 +766,10 @@ export class CallbackManager ); } } catch (err) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleLLMStart: ${err}` ); if (handler.raiseError) { @@ -794,7 +836,10 @@ export class CallbackManager runName ); } catch (err) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleChainStart: ${err}` ); if (handler.raiseError) { @@ -856,7 +901,10 @@ export class CallbackManager runName ); } catch (err) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleToolStart: ${err}` ); if (handler.raiseError) { @@ -918,7 +966,10 @@ export class CallbackManager runName ); } catch (err) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleRetrieverStart: ${err}` ); if (handler.raiseError) { @@ -963,7 +1014,10 @@ export class CallbackManager this.metadata ); } catch (err) { - console.error( + const logFunction = handler.raiseError + ? console.error + : console.warn; + logFunction( `Error in handler ${handler.constructor.name}, handleCustomEvent: ${err}` ); if (handler.raiseError) { @@ -1217,7 +1271,8 @@ export function ensureHandler( * ]; * * // Run the example - * processQuestions(questions).catch(console.error); +const logFunction = handler.raiseError ? console.error : console.warn; +* processQuestions(questions).catch(consolelogFunction; * * ``` */ diff --git a/langchain-core/src/callbacks/tests/callbacks.test.ts b/langchain-core/src/callbacks/tests/callbacks.test.ts index 58644caa40e1..37e9e5d84410 100644 --- a/langchain-core/src/callbacks/tests/callbacks.test.ts +++ b/langchain-core/src/callbacks/tests/callbacks.test.ts @@ -9,6 +9,7 @@ import type { ChainValues } from "../../utils/types/index.js"; import type { AgentAction, AgentFinish } from "../../agents.js"; import { BaseMessage, HumanMessage } from "../../messages/index.js"; import type { LLMResult } from "../../outputs.js"; +import { RunnableLambda } from "../../runnables/base.js"; class FakeCallbackHandler extends BaseCallbackHandler { name = `fake-${uuid.v4()}`; @@ -518,3 +519,20 @@ test("error handling in llm start", async () => { await manager.handleLLMStart(serialized, ["test"]); }).rejects.toThrowError(); }); + +test("chain should still run if a normal callback handler throws an error", async () => { + const chain = RunnableLambda.from(async () => "hello world"); + const res = await chain.invoke( + {}, + { + callbacks: [ + { + handleChainStart: () => { + throw new Error("Bad"); + }, + }, + ], + } + ); + expect(res).toEqual("hello world"); +}); From de0becdc65db748d4fb4e0998d2ac4515e8d8023 Mon Sep 17 00:00:00 2001 From: Jacob Lee Date: Wed, 24 Jul 2024 10:34:54 -0700 Subject: [PATCH 03/11] Make legacy OpenAI path respect a passed model (#6193) --- libs/langchain-openai/src/legacy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/langchain-openai/src/legacy.ts b/libs/langchain-openai/src/legacy.ts index 16e0452af2e2..f9c18f0f8cfb 100644 --- a/libs/langchain-openai/src/legacy.ts +++ b/libs/langchain-openai/src/legacy.ts @@ -191,7 +191,7 @@ export class OpenAIChat fields?.configuration?.organization ?? getEnvironmentVariable("OPENAI_ORGANIZATION"); - this.modelName = fields?.modelName ?? this.modelName; + this.modelName = fields?.model ?? fields?.modelName ?? this.modelName; this.prefixMessages = fields?.prefixMessages ?? this.prefixMessages; this.modelKwargs = fields?.modelKwargs ?? {}; this.timeout = fields?.timeout; From 29c08a3cca4a71bfaf8876d82bc71fd6e45fd026 Mon Sep 17 00:00:00 2001 From: Jacob Lee Date: Wed, 24 Jul 2024 10:59:30 -0700 Subject: [PATCH 04/11] docs[patch]: Fix broken link (#6194) @bracesproul let's try not to prefix API refs --- docs/core_docs/docs/how_to/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core_docs/docs/how_to/index.mdx b/docs/core_docs/docs/how_to/index.mdx index 88e4a79e4e86..c728d251b54c 100644 --- a/docs/core_docs/docs/how_to/index.mdx +++ b/docs/core_docs/docs/how_to/index.mdx @@ -9,7 +9,7 @@ Here you'll find answers to “How do I….?” types of questions. These guides are _goal-oriented_ and _concrete_; they're meant to help you complete a specific task. For conceptual explanations see [Conceptual Guides](/docs/concepts/). For end-to-end walkthroughs see [Tutorials](/docs/tutorials). -For comprehensive descriptions of every class and function see [API Reference](https://v2.v02.api.js.langchain.com/). +For comprehensive descriptions of every class and function see [API Reference](https://api.js.langchain.com/). ## Installation From 63305a0c0edd67f3452af8befcf7ac87459ed6f4 Mon Sep 17 00:00:00 2001 From: Jorge Lanzarotti <94814971+jl4nz@users.noreply.github.com> Date: Thu, 25 Jul 2024 04:57:20 +0900 Subject: [PATCH 05/11] Update for AWS Bedrock knowledge bases to support filters and overrideSearchType, Update the KB to support other locations as sources (#6189) Co-authored-by: Brace Sproul --- libs/langchain-aws/package.json | 6 +- libs/langchain-aws/src/retrievers/bedrock.ts | 68 +- .../src/retrievers/tests/bedrock.int.test.ts | 2 + yarn.lock | 871 +++++++++++++++++- 4 files changed, 931 insertions(+), 16 deletions(-) diff --git a/libs/langchain-aws/package.json b/libs/langchain-aws/package.json index 14a206c3fa4b..5bfac18e5270 100644 --- a/libs/langchain-aws/package.json +++ b/libs/langchain-aws/package.json @@ -39,7 +39,7 @@ "author": "LangChain", "license": "MIT", "dependencies": { - "@aws-sdk/client-bedrock-agent-runtime": "^3.583.0", + "@aws-sdk/client-bedrock-agent-runtime": "^3.616.0", "@aws-sdk/client-bedrock-runtime": "^3.602.0", "@aws-sdk/client-kendra": "^3.352.0", "@aws-sdk/credential-provider-node": "^3.600.0", @@ -47,7 +47,7 @@ "zod-to-json-schema": "^3.22.5" }, "devDependencies": { - "@aws-sdk/types": "^3.598.0", + "@aws-sdk/types": "^3.609.0", "@jest/globals": "^29.5.0", "@langchain/scripts": "~0.0.14", "@langchain/standard-tests": "0.0.0", @@ -97,4 +97,4 @@ "index.d.ts", "index.d.cts" ] -} +} \ No newline at end of file diff --git a/libs/langchain-aws/src/retrievers/bedrock.ts b/libs/langchain-aws/src/retrievers/bedrock.ts index 65748566de12..a67528b0d5e5 100644 --- a/libs/langchain-aws/src/retrievers/bedrock.ts +++ b/libs/langchain-aws/src/retrievers/bedrock.ts @@ -2,6 +2,8 @@ import { RetrieveCommand, BedrockAgentRuntimeClient, type BedrockAgentRuntimeClientConfig, + type SearchType, + type RetrievalFilter, } from "@aws-sdk/client-bedrock-agent-runtime"; import { BaseRetriever } from "@langchain/core/retrievers"; @@ -16,6 +18,8 @@ export interface AmazonKnowledgeBaseRetrieverArgs { topK: number; region: string; clientOptions?: BedrockAgentRuntimeClientConfig; + filter?: RetrievalFilter; + overrideSearchType?: SearchType; } /** @@ -51,15 +55,23 @@ export class AmazonKnowledgeBaseRetriever extends BaseRetriever { bedrockAgentRuntimeClient: BedrockAgentRuntimeClient; + filter?: RetrievalFilter; + + overrideSearchType?: SearchType; + constructor({ knowledgeBaseId, topK = 10, clientOptions, region, + filter, + overrideSearchType, }: AmazonKnowledgeBaseRetrieverArgs) { super(); this.topK = topK; + this.filter = filter; + this.overrideSearchType = overrideSearchType; this.bedrockAgentRuntimeClient = new BedrockAgentRuntimeClient({ region, ...clientOptions, @@ -78,7 +90,12 @@ export class AmazonKnowledgeBaseRetriever extends BaseRetriever { return res; } - async queryKnowledgeBase(query: string, topK: number) { + async queryKnowledgeBase( + query: string, + topK: number, + filter?: RetrievalFilter, + overrideSearchType?: SearchType + ) { const retrieveCommand = new RetrieveCommand({ knowledgeBaseId: this.knowledgeBaseId, retrievalQuery: { @@ -87,6 +104,8 @@ export class AmazonKnowledgeBaseRetriever extends BaseRetriever { retrievalConfiguration: { vectorSearchConfiguration: { numberOfResults: topK, + overrideSearchType, + filter, }, }, }); @@ -96,19 +115,48 @@ export class AmazonKnowledgeBaseRetriever extends BaseRetriever { ); return ( - retrieveResponse.retrievalResults?.map((result) => ({ - pageContent: this.cleanResult(result.content?.text || ""), - metadata: { - source: result.location?.s3Location?.uri, - score: result.score, - ...result.metadata, - }, - })) ?? ([] as Array) + retrieveResponse.retrievalResults?.map((result) => { + let source; + switch (result.location?.type) { + case "CONFLUENCE": + source = result.location?.confluenceLocation?.url; + break; + case "S3": + source = result.location?.s3Location?.uri; + break; + case "SALESFORCE": + source = result.location?.salesforceLocation?.url; + break; + case "SHAREPOINT": + source = result.location?.sharePointLocation?.url; + break; + case "WEB": + source = result.location?.webLocation?.url; + break; + default: + source = result.location?.s3Location?.uri; + break; + } + + return { + pageContent: this.cleanResult(result.content?.text || ""), + metadata: { + source, + score: result.score, + ...result.metadata, + }, + }; + }) ?? ([] as Array) ); } async _getRelevantDocuments(query: string): Promise { - const docs = await this.queryKnowledgeBase(query, this.topK); + const docs = await this.queryKnowledgeBase( + query, + this.topK, + this.filter, + this.overrideSearchType + ); return docs; } } diff --git a/libs/langchain-aws/src/retrievers/tests/bedrock.int.test.ts b/libs/langchain-aws/src/retrievers/tests/bedrock.int.test.ts index 69b536f7e3fc..b44b91eea60d 100644 --- a/libs/langchain-aws/src/retrievers/tests/bedrock.int.test.ts +++ b/libs/langchain-aws/src/retrievers/tests/bedrock.int.test.ts @@ -16,6 +16,8 @@ test("AmazonKnowledgeBaseRetriever", async () => { topK: 10, knowledgeBaseId: process.env.AMAZON_KNOWLEDGE_BASE_ID || "", region: process.env.BEDROCK_AWS_REGION, + overrideSearchType: "HYBRID", + filter: undefined, clientOptions: { credentials: { accessKeyId: process.env.BEDROCK_AWS_ACCESS_KEY_ID, diff --git a/yarn.lock b/yarn.lock index 3c34ea815cab..a0ba67609156 100644 --- a/yarn.lock +++ b/yarn.lock @@ -515,6 +515,58 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/client-bedrock-agent-runtime@npm:^3.616.0": + version: 3.616.0 + resolution: "@aws-sdk/client-bedrock-agent-runtime@npm:3.616.0" + dependencies: + "@aws-crypto/sha256-browser": 5.2.0 + "@aws-crypto/sha256-js": 5.2.0 + "@aws-sdk/client-sso-oidc": 3.616.0 + "@aws-sdk/client-sts": 3.616.0 + "@aws-sdk/core": 3.616.0 + "@aws-sdk/credential-provider-node": 3.616.0 + "@aws-sdk/middleware-host-header": 3.616.0 + "@aws-sdk/middleware-logger": 3.609.0 + "@aws-sdk/middleware-recursion-detection": 3.616.0 + "@aws-sdk/middleware-user-agent": 3.616.0 + "@aws-sdk/region-config-resolver": 3.614.0 + "@aws-sdk/types": 3.609.0 + "@aws-sdk/util-endpoints": 3.614.0 + "@aws-sdk/util-user-agent-browser": 3.609.0 + "@aws-sdk/util-user-agent-node": 3.614.0 + "@smithy/config-resolver": ^3.0.5 + "@smithy/core": ^2.2.7 + "@smithy/eventstream-serde-browser": ^3.0.4 + "@smithy/eventstream-serde-config-resolver": ^3.0.3 + "@smithy/eventstream-serde-node": ^3.0.4 + "@smithy/fetch-http-handler": ^3.2.2 + "@smithy/hash-node": ^3.0.3 + "@smithy/invalid-dependency": ^3.0.3 + "@smithy/middleware-content-length": ^3.0.4 + "@smithy/middleware-endpoint": ^3.0.5 + "@smithy/middleware-retry": ^3.0.10 + "@smithy/middleware-serde": ^3.0.3 + "@smithy/middleware-stack": ^3.0.3 + "@smithy/node-config-provider": ^3.1.4 + "@smithy/node-http-handler": ^3.1.3 + "@smithy/protocol-http": ^4.0.4 + "@smithy/smithy-client": ^3.1.8 + "@smithy/types": ^3.3.0 + "@smithy/url-parser": ^3.0.3 + "@smithy/util-base64": ^3.0.0 + "@smithy/util-body-length-browser": ^3.0.0 + "@smithy/util-body-length-node": ^3.0.0 + "@smithy/util-defaults-mode-browser": ^3.0.10 + "@smithy/util-defaults-mode-node": ^3.0.10 + "@smithy/util-endpoints": ^2.0.5 + "@smithy/util-middleware": ^3.0.3 + "@smithy/util-retry": ^3.0.3 + "@smithy/util-utf8": ^3.0.0 + tslib: ^2.6.2 + checksum: d25373b0ef8b8df63f2bc935bf9d2aefa9a17d68fedd70bca21122add6ea21c3a914916cf8ad69b6a0f73a6ca43d98e9c56843aea69ea76f0cefff63aaeb24bc + languageName: node + linkType: hard + "@aws-sdk/client-bedrock-runtime@npm:^3.422.0": version: 3.490.0 resolution: "@aws-sdk/client-bedrock-runtime@npm:3.490.0" @@ -1319,6 +1371,55 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/client-sso-oidc@npm:3.616.0": + version: 3.616.0 + resolution: "@aws-sdk/client-sso-oidc@npm:3.616.0" + dependencies: + "@aws-crypto/sha256-browser": 5.2.0 + "@aws-crypto/sha256-js": 5.2.0 + "@aws-sdk/core": 3.616.0 + "@aws-sdk/credential-provider-node": 3.616.0 + "@aws-sdk/middleware-host-header": 3.616.0 + "@aws-sdk/middleware-logger": 3.609.0 + "@aws-sdk/middleware-recursion-detection": 3.616.0 + "@aws-sdk/middleware-user-agent": 3.616.0 + "@aws-sdk/region-config-resolver": 3.614.0 + "@aws-sdk/types": 3.609.0 + "@aws-sdk/util-endpoints": 3.614.0 + "@aws-sdk/util-user-agent-browser": 3.609.0 + "@aws-sdk/util-user-agent-node": 3.614.0 + "@smithy/config-resolver": ^3.0.5 + "@smithy/core": ^2.2.7 + "@smithy/fetch-http-handler": ^3.2.2 + "@smithy/hash-node": ^3.0.3 + "@smithy/invalid-dependency": ^3.0.3 + "@smithy/middleware-content-length": ^3.0.4 + "@smithy/middleware-endpoint": ^3.0.5 + "@smithy/middleware-retry": ^3.0.10 + "@smithy/middleware-serde": ^3.0.3 + "@smithy/middleware-stack": ^3.0.3 + "@smithy/node-config-provider": ^3.1.4 + "@smithy/node-http-handler": ^3.1.3 + "@smithy/protocol-http": ^4.0.4 + "@smithy/smithy-client": ^3.1.8 + "@smithy/types": ^3.3.0 + "@smithy/url-parser": ^3.0.3 + "@smithy/util-base64": ^3.0.0 + "@smithy/util-body-length-browser": ^3.0.0 + "@smithy/util-body-length-node": ^3.0.0 + "@smithy/util-defaults-mode-browser": ^3.0.10 + "@smithy/util-defaults-mode-node": ^3.0.10 + "@smithy/util-endpoints": ^2.0.5 + "@smithy/util-middleware": ^3.0.3 + "@smithy/util-retry": ^3.0.3 + "@smithy/util-utf8": ^3.0.0 + tslib: ^2.6.2 + peerDependencies: + "@aws-sdk/client-sts": ^3.616.0 + checksum: cc6fab0e7369b0dbb7d03dbfcdc4e1dedd9bf395ed468c0c22b0c141ab35fc286d27f54a075584395dd5ca8a134682e9aa119e95b52694fb061aa8c389d6fc42 + languageName: node + linkType: hard + "@aws-sdk/client-sso@npm:3.310.0": version: 3.310.0 resolution: "@aws-sdk/client-sso@npm:3.310.0" @@ -1747,6 +1848,52 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/client-sso@npm:3.616.0": + version: 3.616.0 + resolution: "@aws-sdk/client-sso@npm:3.616.0" + dependencies: + "@aws-crypto/sha256-browser": 5.2.0 + "@aws-crypto/sha256-js": 5.2.0 + "@aws-sdk/core": 3.616.0 + "@aws-sdk/middleware-host-header": 3.616.0 + "@aws-sdk/middleware-logger": 3.609.0 + "@aws-sdk/middleware-recursion-detection": 3.616.0 + "@aws-sdk/middleware-user-agent": 3.616.0 + "@aws-sdk/region-config-resolver": 3.614.0 + "@aws-sdk/types": 3.609.0 + "@aws-sdk/util-endpoints": 3.614.0 + "@aws-sdk/util-user-agent-browser": 3.609.0 + "@aws-sdk/util-user-agent-node": 3.614.0 + "@smithy/config-resolver": ^3.0.5 + "@smithy/core": ^2.2.7 + "@smithy/fetch-http-handler": ^3.2.2 + "@smithy/hash-node": ^3.0.3 + "@smithy/invalid-dependency": ^3.0.3 + "@smithy/middleware-content-length": ^3.0.4 + "@smithy/middleware-endpoint": ^3.0.5 + "@smithy/middleware-retry": ^3.0.10 + "@smithy/middleware-serde": ^3.0.3 + "@smithy/middleware-stack": ^3.0.3 + "@smithy/node-config-provider": ^3.1.4 + "@smithy/node-http-handler": ^3.1.3 + "@smithy/protocol-http": ^4.0.4 + "@smithy/smithy-client": ^3.1.8 + "@smithy/types": ^3.3.0 + "@smithy/url-parser": ^3.0.3 + "@smithy/util-base64": ^3.0.0 + "@smithy/util-body-length-browser": ^3.0.0 + "@smithy/util-body-length-node": ^3.0.0 + "@smithy/util-defaults-mode-browser": ^3.0.10 + "@smithy/util-defaults-mode-node": ^3.0.10 + "@smithy/util-endpoints": ^2.0.5 + "@smithy/util-middleware": ^3.0.3 + "@smithy/util-retry": ^3.0.3 + "@smithy/util-utf8": ^3.0.0 + tslib: ^2.6.2 + checksum: 0a0d5560a84b381caad36264cc3760a0aa2c1dfa980429dc55c582447e7e7242f0947963815f7b91c0b92fc4b3b95507fd37cf9eb155b5409a6f9303f6efaed7 + languageName: node + linkType: hard + "@aws-sdk/client-sts@npm:3.310.0": version: 3.310.0 resolution: "@aws-sdk/client-sts@npm:3.310.0" @@ -2163,6 +2310,54 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/client-sts@npm:3.616.0": + version: 3.616.0 + resolution: "@aws-sdk/client-sts@npm:3.616.0" + dependencies: + "@aws-crypto/sha256-browser": 5.2.0 + "@aws-crypto/sha256-js": 5.2.0 + "@aws-sdk/client-sso-oidc": 3.616.0 + "@aws-sdk/core": 3.616.0 + "@aws-sdk/credential-provider-node": 3.616.0 + "@aws-sdk/middleware-host-header": 3.616.0 + "@aws-sdk/middleware-logger": 3.609.0 + "@aws-sdk/middleware-recursion-detection": 3.616.0 + "@aws-sdk/middleware-user-agent": 3.616.0 + "@aws-sdk/region-config-resolver": 3.614.0 + "@aws-sdk/types": 3.609.0 + "@aws-sdk/util-endpoints": 3.614.0 + "@aws-sdk/util-user-agent-browser": 3.609.0 + "@aws-sdk/util-user-agent-node": 3.614.0 + "@smithy/config-resolver": ^3.0.5 + "@smithy/core": ^2.2.7 + "@smithy/fetch-http-handler": ^3.2.2 + "@smithy/hash-node": ^3.0.3 + "@smithy/invalid-dependency": ^3.0.3 + "@smithy/middleware-content-length": ^3.0.4 + "@smithy/middleware-endpoint": ^3.0.5 + "@smithy/middleware-retry": ^3.0.10 + "@smithy/middleware-serde": ^3.0.3 + "@smithy/middleware-stack": ^3.0.3 + "@smithy/node-config-provider": ^3.1.4 + "@smithy/node-http-handler": ^3.1.3 + "@smithy/protocol-http": ^4.0.4 + "@smithy/smithy-client": ^3.1.8 + "@smithy/types": ^3.3.0 + "@smithy/url-parser": ^3.0.3 + "@smithy/util-base64": ^3.0.0 + "@smithy/util-body-length-browser": ^3.0.0 + "@smithy/util-body-length-node": ^3.0.0 + "@smithy/util-defaults-mode-browser": ^3.0.10 + "@smithy/util-defaults-mode-node": ^3.0.10 + "@smithy/util-endpoints": ^2.0.5 + "@smithy/util-middleware": ^3.0.3 + "@smithy/util-retry": ^3.0.3 + "@smithy/util-utf8": ^3.0.0 + tslib: ^2.6.2 + checksum: bad2619661085259ccfa2cd95f721ed1dc479c6871a8927648d182c6fbe3d25989a904d6b9430eac762c1d2a25d370a89879b9d1f2375f2cbfa869949288643f + languageName: node + linkType: hard + "@aws-sdk/config-resolver@npm:3.310.0": version: 3.310.0 resolution: "@aws-sdk/config-resolver@npm:3.310.0" @@ -2246,6 +2441,21 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/core@npm:3.616.0": + version: 3.616.0 + resolution: "@aws-sdk/core@npm:3.616.0" + dependencies: + "@smithy/core": ^2.2.7 + "@smithy/protocol-http": ^4.0.4 + "@smithy/signature-v4": ^4.0.0 + "@smithy/smithy-client": ^3.1.8 + "@smithy/types": ^3.3.0 + fast-xml-parser: 4.2.5 + tslib: ^2.6.2 + checksum: b19c43578beba8e90c1dac2a4842012e0ac2469fb0a8a72801677268447f5de2ad92ebcadc83826a7bfc360ef345c1686f2f76a04fc77f478e1c7512759789a9 + languageName: node + linkType: hard + "@aws-sdk/credential-provider-cognito-identity@npm:3.592.0": version: 3.592.0 resolution: "@aws-sdk/credential-provider-cognito-identity@npm:3.592.0" @@ -2353,6 +2563,18 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/credential-provider-env@npm:3.609.0": + version: 3.609.0 + resolution: "@aws-sdk/credential-provider-env@npm:3.609.0" + dependencies: + "@aws-sdk/types": 3.609.0 + "@smithy/property-provider": ^3.1.3 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: eda20122740481d04f5110fb9349df339562da1e1d5217e6c47e5f80ed0cce1b3bea01081272487bf04e402fcecc2734a352b0b57ae80b090dd8a0b3547ad185 + languageName: node + linkType: hard + "@aws-sdk/credential-provider-http@npm:3.582.0": version: 3.582.0 resolution: "@aws-sdk/credential-provider-http@npm:3.582.0" @@ -2404,6 +2626,23 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/credential-provider-http@npm:3.616.0": + version: 3.616.0 + resolution: "@aws-sdk/credential-provider-http@npm:3.616.0" + dependencies: + "@aws-sdk/types": 3.609.0 + "@smithy/fetch-http-handler": ^3.2.2 + "@smithy/node-http-handler": ^3.1.3 + "@smithy/property-provider": ^3.1.3 + "@smithy/protocol-http": ^4.0.4 + "@smithy/smithy-client": ^3.1.8 + "@smithy/types": ^3.3.0 + "@smithy/util-stream": ^3.1.0 + tslib: ^2.6.2 + checksum: a1afc3d78bc2496b57583a0d4e2ce080ba6f365c5b84aba39b070e51daee677256b32b8dcd93278c3c82a9c1288b2691c8f02624d23e819817fd55fa8377ddb4 + languageName: node + linkType: hard + "@aws-sdk/credential-provider-imds@npm:3.310.0": version: 3.310.0 resolution: "@aws-sdk/credential-provider-imds@npm:3.310.0" @@ -2614,6 +2853,27 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/credential-provider-ini@npm:3.616.0": + version: 3.616.0 + resolution: "@aws-sdk/credential-provider-ini@npm:3.616.0" + dependencies: + "@aws-sdk/credential-provider-env": 3.609.0 + "@aws-sdk/credential-provider-http": 3.616.0 + "@aws-sdk/credential-provider-process": 3.614.0 + "@aws-sdk/credential-provider-sso": 3.616.0 + "@aws-sdk/credential-provider-web-identity": 3.609.0 + "@aws-sdk/types": 3.609.0 + "@smithy/credential-provider-imds": ^3.1.4 + "@smithy/property-provider": ^3.1.3 + "@smithy/shared-ini-file-loader": ^3.1.4 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + peerDependencies: + "@aws-sdk/client-sts": ^3.616.0 + checksum: 2de4455b8bc58ebed180954d04e4f3de35a390778156a99a5581b7ebbf9adf01df6166f3dc60129a465865f110d30352b740ee92591169a1cb56d11e5ea21d38 + languageName: node + linkType: hard + "@aws-sdk/credential-provider-node@npm:3.310.0": version: 3.310.0 resolution: "@aws-sdk/credential-provider-node@npm:3.310.0" @@ -2784,6 +3044,26 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/credential-provider-node@npm:3.616.0": + version: 3.616.0 + resolution: "@aws-sdk/credential-provider-node@npm:3.616.0" + dependencies: + "@aws-sdk/credential-provider-env": 3.609.0 + "@aws-sdk/credential-provider-http": 3.616.0 + "@aws-sdk/credential-provider-ini": 3.616.0 + "@aws-sdk/credential-provider-process": 3.614.0 + "@aws-sdk/credential-provider-sso": 3.616.0 + "@aws-sdk/credential-provider-web-identity": 3.609.0 + "@aws-sdk/types": 3.609.0 + "@smithy/credential-provider-imds": ^3.1.4 + "@smithy/property-provider": ^3.1.3 + "@smithy/shared-ini-file-loader": ^3.1.4 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 9a66c9401eb152711a69010bfe9adc55fedd445d4d9754bd26490bf7b75c6606486dde9495893f893998ba74786ff4703ba94f0bdef92e2aa4c0d5baa605757a + languageName: node + linkType: hard + "@aws-sdk/credential-provider-node@npm:^3.388.0": version: 3.388.0 resolution: "@aws-sdk/credential-provider-node@npm:3.388.0" @@ -2905,6 +3185,19 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/credential-provider-process@npm:3.614.0": + version: 3.614.0 + resolution: "@aws-sdk/credential-provider-process@npm:3.614.0" + dependencies: + "@aws-sdk/types": 3.609.0 + "@smithy/property-provider": ^3.1.3 + "@smithy/shared-ini-file-loader": ^3.1.4 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 8bbbbf66911f38818e801187ae8df000e92b4e1c0dbe6d6b9afae81e08fb771302d2dc86c459653a2ed71acc10b9773885ae28d6fbce0031e082e9a6e61c85ee + languageName: node + linkType: hard + "@aws-sdk/credential-provider-sso@npm:3.310.0": version: 3.310.0 resolution: "@aws-sdk/credential-provider-sso@npm:3.310.0" @@ -3051,6 +3344,21 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/credential-provider-sso@npm:3.616.0": + version: 3.616.0 + resolution: "@aws-sdk/credential-provider-sso@npm:3.616.0" + dependencies: + "@aws-sdk/client-sso": 3.616.0 + "@aws-sdk/token-providers": 3.614.0 + "@aws-sdk/types": 3.609.0 + "@smithy/property-provider": ^3.1.3 + "@smithy/shared-ini-file-loader": ^3.1.4 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 773fb35df0bb769964dd1da86e9a498620ba411b664e9ef968ba33d222dbc29849eb95a556f11bb23a3893141815db9be098cba3c99dd0148b34f116f5e1ef56 + languageName: node + linkType: hard + "@aws-sdk/credential-provider-web-identity@npm:3.310.0": version: 3.310.0 resolution: "@aws-sdk/credential-provider-web-identity@npm:3.310.0" @@ -3151,6 +3459,20 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/credential-provider-web-identity@npm:3.609.0": + version: 3.609.0 + resolution: "@aws-sdk/credential-provider-web-identity@npm:3.609.0" + dependencies: + "@aws-sdk/types": 3.609.0 + "@smithy/property-provider": ^3.1.3 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + peerDependencies: + "@aws-sdk/client-sts": ^3.609.0 + checksum: 7a95a6c4792491122677fab6f01a9a46c8aa2f94d95255430bbd3fdcd514ab05ecf92c0ab169c8b30215b6b9181165f8d009774ba5a39cdd633162ef30879e56 + languageName: node + linkType: hard + "@aws-sdk/credential-providers@npm:^3.583.0": version: 3.592.0 resolution: "@aws-sdk/credential-providers@npm:3.592.0" @@ -3580,6 +3902,18 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/middleware-host-header@npm:3.616.0": + version: 3.616.0 + resolution: "@aws-sdk/middleware-host-header@npm:3.616.0" + dependencies: + "@aws-sdk/types": 3.609.0 + "@smithy/protocol-http": ^4.0.4 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 7936068785a58e35adf96b90d6e72d9defca2d1051992bfd7bf5bbc150d000942ff587151d27d40276942d430817bac9985ab68d926333dfb581983b6236a21c + languageName: node + linkType: hard + "@aws-sdk/middleware-location-constraint@npm:3.310.0": version: 3.310.0 resolution: "@aws-sdk/middleware-location-constraint@npm:3.310.0" @@ -3675,6 +4009,17 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/middleware-logger@npm:3.609.0": + version: 3.609.0 + resolution: "@aws-sdk/middleware-logger@npm:3.609.0" + dependencies: + "@aws-sdk/types": 3.609.0 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: b6f67a2e9ba082c8aec9d45905ae45ea5a95896f1beecb0c2d7fecfe17dd8fad99513f43b11ed7fd6ca9ff7764a0fc1ce63af91b1baed92b36f7b4b5390be5c6 + languageName: node + linkType: hard + "@aws-sdk/middleware-recursion-detection@npm:3.310.0": version: 3.310.0 resolution: "@aws-sdk/middleware-recursion-detection@npm:3.310.0" @@ -3768,6 +4113,18 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/middleware-recursion-detection@npm:3.616.0": + version: 3.616.0 + resolution: "@aws-sdk/middleware-recursion-detection@npm:3.616.0" + dependencies: + "@aws-sdk/types": 3.609.0 + "@smithy/protocol-http": ^4.0.4 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 43bd173705125f07e44c0c0feb85af0edba1503fe629d9eacdcc446d45d038fca6148415a9f721d80a80a5dab390585ef122823f30bd8e06d723f523c6fc58c3 + languageName: node + linkType: hard + "@aws-sdk/middleware-retry@npm:3.310.0": version: 3.310.0 resolution: "@aws-sdk/middleware-retry@npm:3.310.0" @@ -4138,6 +4495,19 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/middleware-user-agent@npm:3.616.0": + version: 3.616.0 + resolution: "@aws-sdk/middleware-user-agent@npm:3.616.0" + dependencies: + "@aws-sdk/types": 3.609.0 + "@aws-sdk/util-endpoints": 3.614.0 + "@smithy/protocol-http": ^4.0.4 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 6525d9061e0993f338c6dbb2c55e3e094aa02801d0814824cd4a0c0d9810e0f82fc7af4f6f2010723b18a856da241c3daded3fd9bc16b991cffef5f3031f0941 + languageName: node + linkType: hard + "@aws-sdk/node-config-provider@npm:3.310.0": version: 3.310.0 resolution: "@aws-sdk/node-config-provider@npm:3.310.0" @@ -4375,6 +4745,20 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/region-config-resolver@npm:3.614.0": + version: 3.614.0 + resolution: "@aws-sdk/region-config-resolver@npm:3.614.0" + dependencies: + "@aws-sdk/types": 3.609.0 + "@smithy/node-config-provider": ^3.1.4 + "@smithy/types": ^3.3.0 + "@smithy/util-config-provider": ^3.0.0 + "@smithy/util-middleware": ^3.0.3 + tslib: ^2.6.2 + checksum: dbaca50792c99685845b21dd4a53228613e0458ee517a21db941890ee521d91eff80704f08e9ee71b6f04e70fb86362c4823750bb0b3727240af68d78d8fa4be + languageName: node + linkType: hard + "@aws-sdk/service-error-classification@npm:3.310.0": version: 3.310.0 resolution: "@aws-sdk/service-error-classification@npm:3.310.0" @@ -4750,6 +5134,21 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/token-providers@npm:3.614.0": + version: 3.614.0 + resolution: "@aws-sdk/token-providers@npm:3.614.0" + dependencies: + "@aws-sdk/types": 3.609.0 + "@smithy/property-provider": ^3.1.3 + "@smithy/shared-ini-file-loader": ^3.1.4 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + peerDependencies: + "@aws-sdk/client-sso-oidc": ^3.614.0 + checksum: 2901b8428afc3b76ff1df9ac29a2698db6bf65d1d2afcd8424b9bf187313d2a3ca747c3b205afeb5c132068b5a5a94d84ce82710f775fa0cbb79499d7fea2d64 + languageName: node + linkType: hard + "@aws-sdk/types@npm:3.310.0, @aws-sdk/types@npm:^3.222.0": version: 3.310.0 resolution: "@aws-sdk/types@npm:3.310.0" @@ -4808,7 +5207,7 @@ __metadata: languageName: node linkType: hard -"@aws-sdk/types@npm:3.598.0, @aws-sdk/types@npm:^3.598.0": +"@aws-sdk/types@npm:3.598.0": version: 3.598.0 resolution: "@aws-sdk/types@npm:3.598.0" dependencies: @@ -4818,6 +5217,16 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/types@npm:3.609.0, @aws-sdk/types@npm:^3.609.0": + version: 3.609.0 + resolution: "@aws-sdk/types@npm:3.609.0" + dependencies: + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 522768d08f104065b0ff6a37eddaa7803186014acee1c0011b3dbd3ef841e47ae694e58f608aeec8a39d22d644d759ade996fe51d18b880617778dc2dbbe1ede + languageName: node + linkType: hard + "@aws-sdk/types@npm:^3.357.0": version: 3.378.0 resolution: "@aws-sdk/types@npm:3.378.0" @@ -5109,6 +5518,18 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/util-endpoints@npm:3.614.0": + version: 3.614.0 + resolution: "@aws-sdk/util-endpoints@npm:3.614.0" + dependencies: + "@aws-sdk/types": 3.609.0 + "@smithy/types": ^3.3.0 + "@smithy/util-endpoints": ^2.0.5 + tslib: ^2.6.2 + checksum: 9d9973ceee59bf30af85c7f4328083daea033a987ec396dcb89eb7649f470ceb19c6b96635e121f3557e726f7ec7453236c956cf43f22128883c277f17d2a13f + languageName: node + linkType: hard + "@aws-sdk/util-hex-encoding@npm:3.310.0": version: 3.310.0 resolution: "@aws-sdk/util-hex-encoding@npm:3.310.0" @@ -5334,6 +5755,18 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/util-user-agent-browser@npm:3.609.0": + version: 3.609.0 + resolution: "@aws-sdk/util-user-agent-browser@npm:3.609.0" + dependencies: + "@aws-sdk/types": 3.609.0 + "@smithy/types": ^3.3.0 + bowser: ^2.11.0 + tslib: ^2.6.2 + checksum: 75ba1ae74dd1001f47870766d92b66ac02a0a488efcf42c1a368962a7978a778d99536e880f07f7db1c2ca66cc9b1863fd3342957a22dcf78bf2f4398265a7a5 + languageName: node + linkType: hard + "@aws-sdk/util-user-agent-node@npm:3.310.0": version: 3.310.0 resolution: "@aws-sdk/util-user-agent-node@npm:3.310.0" @@ -5468,6 +5901,23 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/util-user-agent-node@npm:3.614.0": + version: 3.614.0 + resolution: "@aws-sdk/util-user-agent-node@npm:3.614.0" + dependencies: + "@aws-sdk/types": 3.609.0 + "@smithy/node-config-provider": ^3.1.4 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + peerDependencies: + aws-crt: ">=1.0.0" + peerDependenciesMeta: + aws-crt: + optional: true + checksum: 1f010080c2301fd836908963a235ef39e597d959e27461d15d4958fa582ab20795022f8cb7429c183c386f558a5c125cb254a0c4e844dbc6422169f4884be34a + languageName: node + linkType: hard + "@aws-sdk/util-utf8-browser@npm:^3.0.0": version: 3.259.0 resolution: "@aws-sdk/util-utf8-browser@npm:3.259.0" @@ -10244,11 +10694,11 @@ __metadata: version: 0.0.0-use.local resolution: "@langchain/aws@workspace:libs/langchain-aws" dependencies: - "@aws-sdk/client-bedrock-agent-runtime": ^3.583.0 + "@aws-sdk/client-bedrock-agent-runtime": ^3.616.0 "@aws-sdk/client-bedrock-runtime": ^3.602.0 "@aws-sdk/client-kendra": ^3.352.0 "@aws-sdk/credential-provider-node": ^3.600.0 - "@aws-sdk/types": ^3.598.0 + "@aws-sdk/types": ^3.609.0 "@jest/globals": ^29.5.0 "@langchain/core": ">=0.2.16 <0.3.0" "@langchain/scripts": ~0.0.14 @@ -13393,6 +13843,16 @@ __metadata: languageName: node linkType: hard +"@smithy/abort-controller@npm:^3.1.1": + version: 3.1.1 + resolution: "@smithy/abort-controller@npm:3.1.1" + dependencies: + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 7b7497f49d58787cad858f8c5ea9931ccd44d39536db4abdd531a5abf37784469522e41d9ad1d541892caa0ed3bea750447809a0a18f4689a9543d672aa61d48 + languageName: node + linkType: hard + "@smithy/config-resolver@npm:^2.0.11": version: 2.0.11 resolution: "@smithy/config-resolver@npm:2.0.11" @@ -13483,6 +13943,19 @@ __metadata: languageName: node linkType: hard +"@smithy/config-resolver@npm:^3.0.5": + version: 3.0.5 + resolution: "@smithy/config-resolver@npm:3.0.5" + dependencies: + "@smithy/node-config-provider": ^3.1.4 + "@smithy/types": ^3.3.0 + "@smithy/util-config-provider": ^3.0.0 + "@smithy/util-middleware": ^3.0.3 + tslib: ^2.6.2 + checksum: 96895ae0622a229655fa08f009d29a20157043020125014e84cb5ca33a10171c9724c309491214c2422d9c4c6681e7f5ec5f7faa8f45e11250449cf07f3552ec + languageName: node + linkType: hard + "@smithy/core@npm:^1.2.2": version: 1.2.2 resolution: "@smithy/core@npm:1.2.2" @@ -13547,6 +14020,22 @@ __metadata: languageName: node linkType: hard +"@smithy/core@npm:^2.2.7": + version: 2.2.8 + resolution: "@smithy/core@npm:2.2.8" + dependencies: + "@smithy/middleware-endpoint": ^3.0.5 + "@smithy/middleware-retry": ^3.0.11 + "@smithy/middleware-serde": ^3.0.3 + "@smithy/protocol-http": ^4.0.4 + "@smithy/smithy-client": ^3.1.9 + "@smithy/types": ^3.3.0 + "@smithy/util-middleware": ^3.0.3 + tslib: ^2.6.2 + checksum: c6dbf5e7ce509779e57889a67036e67f7c9ba39ce93eac087162997105d4afd14b34a5b145ffdcf2c56d1afa65661fc0b42705705c140a79cf0cea78f7739919 + languageName: node + linkType: hard + "@smithy/credential-provider-imds@npm:^2.0.0": version: 2.0.1 resolution: "@smithy/credential-provider-imds@npm:2.0.1" @@ -13638,6 +14127,19 @@ __metadata: languageName: node linkType: hard +"@smithy/credential-provider-imds@npm:^3.1.4": + version: 3.1.4 + resolution: "@smithy/credential-provider-imds@npm:3.1.4" + dependencies: + "@smithy/node-config-provider": ^3.1.4 + "@smithy/property-provider": ^3.1.3 + "@smithy/types": ^3.3.0 + "@smithy/url-parser": ^3.0.3 + tslib: ^2.6.2 + checksum: c75a653970f5e7b888dddbcb916fadd2c45fe59b1a776de9b44f39771b3941fb536684d2407aef88ce376afa6024f38759290db966b07e9213c49a9427ea4a7c + languageName: node + linkType: hard + "@smithy/eventstream-codec@npm:^1.1.0": version: 1.1.0 resolution: "@smithy/eventstream-codec@npm:1.1.0" @@ -13722,6 +14224,18 @@ __metadata: languageName: node linkType: hard +"@smithy/eventstream-codec@npm:^3.1.2": + version: 3.1.2 + resolution: "@smithy/eventstream-codec@npm:3.1.2" + dependencies: + "@aws-crypto/crc32": 5.2.0 + "@smithy/types": ^3.3.0 + "@smithy/util-hex-encoding": ^3.0.0 + tslib: ^2.6.2 + checksum: b0c836acbf59b57a7e2ef948a54bd441d11b75d70f1c334723c27fce1ab0ff93ea9f936976b754272b5e90413b5a169c60b1df7ecfd7d061ebaae8d5cc067d94 + languageName: node + linkType: hard + "@smithy/eventstream-serde-browser@npm:^2.0.10": version: 2.0.11 resolution: "@smithy/eventstream-serde-browser@npm:2.0.11" @@ -13766,6 +14280,17 @@ __metadata: languageName: node linkType: hard +"@smithy/eventstream-serde-browser@npm:^3.0.4": + version: 3.0.5 + resolution: "@smithy/eventstream-serde-browser@npm:3.0.5" + dependencies: + "@smithy/eventstream-serde-universal": ^3.0.4 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 14e8a2027745e7a1ad261068e792e4a660043ce53fefc5f564b38b841ba02d40992b38fbd2357e762f0a1ecb658df3bbf23cf5ef33c3ec2488d316be95b61b9e + languageName: node + linkType: hard + "@smithy/eventstream-serde-config-resolver@npm:^2.0.10": version: 2.0.11 resolution: "@smithy/eventstream-serde-config-resolver@npm:2.0.11" @@ -13806,6 +14331,16 @@ __metadata: languageName: node linkType: hard +"@smithy/eventstream-serde-config-resolver@npm:^3.0.3": + version: 3.0.3 + resolution: "@smithy/eventstream-serde-config-resolver@npm:3.0.3" + dependencies: + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: c61780aa0ad8c479618d0b3fcb2b42f1f9a74dcf814dba08305107ed1f088f56aa1c346db9c72439ff18617f31b9c59c6895060e4c9765c81d759150a22674af + languageName: node + linkType: hard + "@smithy/eventstream-serde-node@npm:^2.0.10": version: 2.0.11 resolution: "@smithy/eventstream-serde-node@npm:2.0.11" @@ -13850,6 +14385,17 @@ __metadata: languageName: node linkType: hard +"@smithy/eventstream-serde-node@npm:^3.0.4": + version: 3.0.4 + resolution: "@smithy/eventstream-serde-node@npm:3.0.4" + dependencies: + "@smithy/eventstream-serde-universal": ^3.0.4 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 0a75b184d95ab8c08efd93bf32c5fd9d735b5879df556599bd2ab78f23e3f77452e597bbdd42586c9bbedcc2b0b7683de4c816db739c19a2ebd62a34096ca86d + languageName: node + linkType: hard + "@smithy/eventstream-serde-universal@npm:^2.0.11": version: 2.0.11 resolution: "@smithy/eventstream-serde-universal@npm:2.0.11" @@ -13894,6 +14440,17 @@ __metadata: languageName: node linkType: hard +"@smithy/eventstream-serde-universal@npm:^3.0.4": + version: 3.0.4 + resolution: "@smithy/eventstream-serde-universal@npm:3.0.4" + dependencies: + "@smithy/eventstream-codec": ^3.1.2 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 8463403ca4caf4ad48dba89b126f394439a289c9095ce6361c1f186c6021c1cd8ea402d1ce06b7284069c3415091ae4d802f66ded1b89e9da9d4c255b8402668 + languageName: node + linkType: hard + "@smithy/fetch-http-handler@npm:^2.0.2, @smithy/fetch-http-handler@npm:^2.0.3": version: 2.0.3 resolution: "@smithy/fetch-http-handler@npm:2.0.3" @@ -13972,6 +14529,19 @@ __metadata: languageName: node linkType: hard +"@smithy/fetch-http-handler@npm:^3.2.2": + version: 3.2.2 + resolution: "@smithy/fetch-http-handler@npm:3.2.2" + dependencies: + "@smithy/protocol-http": ^4.0.4 + "@smithy/querystring-builder": ^3.0.3 + "@smithy/types": ^3.3.0 + "@smithy/util-base64": ^3.0.0 + tslib: ^2.6.2 + checksum: ec7f0d648d0bb2e674ca6fda040357c462833825bba6d2b1549de4b6a8d0ffdd17d6effb2dbd56241b58e76f3e7c1afba5f321f3d592c39bf5007b89e9197875 + languageName: node + linkType: hard + "@smithy/hash-node@npm:^2.0.10": version: 2.0.11 resolution: "@smithy/hash-node@npm:2.0.11" @@ -14032,6 +14602,18 @@ __metadata: languageName: node linkType: hard +"@smithy/hash-node@npm:^3.0.3": + version: 3.0.3 + resolution: "@smithy/hash-node@npm:3.0.3" + dependencies: + "@smithy/types": ^3.3.0 + "@smithy/util-buffer-from": ^3.0.0 + "@smithy/util-utf8": ^3.0.0 + tslib: ^2.6.2 + checksum: 203a3581bec5373e63d42e03f62129022f03d17390e9358a4e25fc1d44c43962ea80ab5bcbb91605e3025e22136bed059665a3b16835f66316f43ed391df9548 + languageName: node + linkType: hard + "@smithy/invalid-dependency@npm:^2.0.10": version: 2.0.11 resolution: "@smithy/invalid-dependency@npm:2.0.11" @@ -14082,6 +14664,16 @@ __metadata: languageName: node linkType: hard +"@smithy/invalid-dependency@npm:^3.0.3": + version: 3.0.3 + resolution: "@smithy/invalid-dependency@npm:3.0.3" + dependencies: + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 459b4ae4e47595e8a675ff2e8bfea7f58a41f77138416ea310c89e29312e08963a701cdc354324da9dd578a7995158b4421695365070d74b0276ddff7f701bba + languageName: node + linkType: hard + "@smithy/is-array-buffer@npm:^1.1.0": version: 1.1.0 resolution: "@smithy/is-array-buffer@npm:1.1.0" @@ -14164,6 +14756,17 @@ __metadata: languageName: node linkType: hard +"@smithy/middleware-content-length@npm:^3.0.4": + version: 3.0.4 + resolution: "@smithy/middleware-content-length@npm:3.0.4" + dependencies: + "@smithy/protocol-http": ^4.0.4 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 462ed3511b5cf849d272c4a6e1a1b72f6f676252e208ebd652528e3d45f132859cbcbcf9e8cb127680fbbc587ab35965225fd7421a3711f4d125738b3e7f528e + languageName: node + linkType: hard + "@smithy/middleware-endpoint@npm:^2.0.10": version: 2.0.11 resolution: "@smithy/middleware-endpoint@npm:2.0.11" @@ -14250,6 +14853,21 @@ __metadata: languageName: node linkType: hard +"@smithy/middleware-endpoint@npm:^3.0.5": + version: 3.0.5 + resolution: "@smithy/middleware-endpoint@npm:3.0.5" + dependencies: + "@smithy/middleware-serde": ^3.0.3 + "@smithy/node-config-provider": ^3.1.4 + "@smithy/shared-ini-file-loader": ^3.1.4 + "@smithy/types": ^3.3.0 + "@smithy/url-parser": ^3.0.3 + "@smithy/util-middleware": ^3.0.3 + tslib: ^2.6.2 + checksum: 4ab0272efd47baa528a04c5413fb224e41be144902680239fffc83cf1fb7e9b5342e8b627a4149136efa2b29baacc84baa4dbcef5fd2fa55c70e169c7f4ba750 + languageName: node + linkType: hard + "@smithy/middleware-retry@npm:^2.0.13": version: 2.0.16 resolution: "@smithy/middleware-retry@npm:2.0.16" @@ -14315,6 +14933,23 @@ __metadata: languageName: node linkType: hard +"@smithy/middleware-retry@npm:^3.0.10, @smithy/middleware-retry@npm:^3.0.11": + version: 3.0.11 + resolution: "@smithy/middleware-retry@npm:3.0.11" + dependencies: + "@smithy/node-config-provider": ^3.1.4 + "@smithy/protocol-http": ^4.0.4 + "@smithy/service-error-classification": ^3.0.3 + "@smithy/smithy-client": ^3.1.9 + "@smithy/types": ^3.3.0 + "@smithy/util-middleware": ^3.0.3 + "@smithy/util-retry": ^3.0.3 + tslib: ^2.6.2 + uuid: ^9.0.1 + checksum: 4061f4823c949f5e9920b4840cfbc1472f38bac05cefc511a7731afa9372dab0fb238f48b6ce7a8d4d24fa966fa80f9eb7165d29fd90fd3854d72006f612d662 + languageName: node + linkType: hard + "@smithy/middleware-retry@npm:^3.0.3": version: 3.0.3 resolution: "@smithy/middleware-retry@npm:3.0.3" @@ -14409,6 +15044,16 @@ __metadata: languageName: node linkType: hard +"@smithy/middleware-serde@npm:^3.0.3": + version: 3.0.3 + resolution: "@smithy/middleware-serde@npm:3.0.3" + dependencies: + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 6c633bb8957e078d480888bd33d5a8c269a483a1358c2b28c62daecfd442c711c509d9e69302e6b19fc298139ee67cdda63a604e7da0e4ef9005117d8e0897cc + languageName: node + linkType: hard + "@smithy/middleware-stack@npm:^2.0.0": version: 2.0.0 resolution: "@smithy/middleware-stack@npm:2.0.0" @@ -14468,6 +15113,16 @@ __metadata: languageName: node linkType: hard +"@smithy/middleware-stack@npm:^3.0.3": + version: 3.0.3 + resolution: "@smithy/middleware-stack@npm:3.0.3" + dependencies: + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: f4a450e2ebca0a8a3b4e1bbfad7d7e9c45edccbe1c984a22f2228092a526120748365e8964b478357249675d8bbc28fdaa8a4a19643a3c1d86bd74e1499327c5 + languageName: node + linkType: hard + "@smithy/node-config-provider@npm:^2.0.1": version: 2.0.1 resolution: "@smithy/node-config-provider@npm:2.0.1" @@ -14564,6 +15219,18 @@ __metadata: languageName: node linkType: hard +"@smithy/node-config-provider@npm:^3.1.4": + version: 3.1.4 + resolution: "@smithy/node-config-provider@npm:3.1.4" + dependencies: + "@smithy/property-provider": ^3.1.3 + "@smithy/shared-ini-file-loader": ^3.1.4 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 7ea4e7cea93ab154ab89a9d6b2453c8f96b96db18883070d287bc5fa9cfd10091bb00006a15bb7e6ed25810fd1a133d458e45310a8eaa1727a55d4ce2be3ba09 + languageName: node + linkType: hard + "@smithy/node-http-handler@npm:^2.0.2, @smithy/node-http-handler@npm:^2.0.3": version: 2.0.3 resolution: "@smithy/node-http-handler@npm:2.0.3" @@ -14642,6 +15309,19 @@ __metadata: languageName: node linkType: hard +"@smithy/node-http-handler@npm:^3.1.3": + version: 3.1.3 + resolution: "@smithy/node-http-handler@npm:3.1.3" + dependencies: + "@smithy/abort-controller": ^3.1.1 + "@smithy/protocol-http": ^4.0.4 + "@smithy/querystring-builder": ^3.0.3 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 2e07687544dc77714912467268db820cb76bffcb0f4cdb5d5f12b05561d8baedb98cb478ceb4e247151e2d7d30af7de88095f9b96037e56f58a371b2a7bab85e + languageName: node + linkType: hard + "@smithy/property-provider@npm:^2.0.0, @smithy/property-provider@npm:^2.0.1": version: 2.0.1 resolution: "@smithy/property-provider@npm:2.0.1" @@ -14722,6 +15402,16 @@ __metadata: languageName: node linkType: hard +"@smithy/property-provider@npm:^3.1.3": + version: 3.1.3 + resolution: "@smithy/property-provider@npm:3.1.3" + dependencies: + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 37a3d92267a2a32c2cc17fd1f0ab2b336f75fb7807db88f6194efede9d6a66068658a7effb7773451404fca990924393dbbf3d57e2aca67ef2e489a85666e225 + languageName: node + linkType: hard + "@smithy/protocol-http@npm:^1.0.1": version: 1.1.0 resolution: "@smithy/protocol-http@npm:1.1.0" @@ -14802,6 +15492,16 @@ __metadata: languageName: node linkType: hard +"@smithy/protocol-http@npm:^4.0.4": + version: 4.0.4 + resolution: "@smithy/protocol-http@npm:4.0.4" + dependencies: + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: a0155381d24f02d279f0b895c179e98af0a6dd1c8a1765666c856f0bca41aa7d4a245a228bc17ddde5f68c631ffe8684440051416757169074dfa5c7a7087e94 + languageName: node + linkType: hard + "@smithy/querystring-builder@npm:^2.0.10": version: 2.0.10 resolution: "@smithy/querystring-builder@npm:2.0.10" @@ -14868,6 +15568,17 @@ __metadata: languageName: node linkType: hard +"@smithy/querystring-builder@npm:^3.0.3": + version: 3.0.3 + resolution: "@smithy/querystring-builder@npm:3.0.3" + dependencies: + "@smithy/types": ^3.3.0 + "@smithy/util-uri-escape": ^3.0.0 + tslib: ^2.6.2 + checksum: 5c46c620d87f9b4e67b8eb543667b0160fb05bbec01d62d45adb94305369dca9e82daba47d81e840fdc399fa47f9b5930ce668d65fe83ee278a1b27d59d0b5d3 + languageName: node + linkType: hard + "@smithy/querystring-parser@npm:^2.0.1": version: 2.0.1 resolution: "@smithy/querystring-parser@npm:2.0.1" @@ -14938,6 +15649,16 @@ __metadata: languageName: node linkType: hard +"@smithy/querystring-parser@npm:^3.0.3": + version: 3.0.3 + resolution: "@smithy/querystring-parser@npm:3.0.3" + dependencies: + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 1de11cbc4325578b243a0e3e89b46371f4705d3df41ea51b37e8efa655d3b75253180b0fca9ceed8b3955a2d458689f551cd24fd904d0f65647c62c6b08795bf + languageName: node + linkType: hard + "@smithy/service-error-classification@npm:^2.0.0": version: 2.0.0 resolution: "@smithy/service-error-classification@npm:2.0.0" @@ -14990,6 +15711,15 @@ __metadata: languageName: node linkType: hard +"@smithy/service-error-classification@npm:^3.0.3": + version: 3.0.3 + resolution: "@smithy/service-error-classification@npm:3.0.3" + dependencies: + "@smithy/types": ^3.3.0 + checksum: 5bef710f5698c929c97865cba41f36b0c59100b9a1c4478a2d47caeb5e3a1a18077b870b365efaa45c94666f2075bc8978f7a6e8b964afbba3a4e490eb6c13eb + languageName: node + linkType: hard + "@smithy/shared-ini-file-loader@npm:^2.0.0, @smithy/shared-ini-file-loader@npm:^2.0.1": version: 2.0.1 resolution: "@smithy/shared-ini-file-loader@npm:2.0.1" @@ -15070,6 +15800,16 @@ __metadata: languageName: node linkType: hard +"@smithy/shared-ini-file-loader@npm:^3.1.4": + version: 3.1.4 + resolution: "@smithy/shared-ini-file-loader@npm:3.1.4" + dependencies: + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: c5321635f3be34e424009fc9045454a9ceec543ec20b3b9719bf3a48bbfc03b794f4545546e9c2dcb0a987de2ca5ff8999df9bf7c166c6fc7685c1fa1f068bc1 + languageName: node + linkType: hard + "@smithy/signature-v4@npm:^1.0.1": version: 1.1.0 resolution: "@smithy/signature-v4@npm:1.1.0" @@ -15132,6 +15872,21 @@ __metadata: languageName: node linkType: hard +"@smithy/signature-v4@npm:^4.0.0": + version: 4.0.0 + resolution: "@smithy/signature-v4@npm:4.0.0" + dependencies: + "@smithy/is-array-buffer": ^3.0.0 + "@smithy/types": ^3.3.0 + "@smithy/util-hex-encoding": ^3.0.0 + "@smithy/util-middleware": ^3.0.3 + "@smithy/util-uri-escape": ^3.0.0 + "@smithy/util-utf8": ^3.0.0 + tslib: ^2.6.2 + checksum: 9cebd322cbfbc8794f4a21af1152d343c4ec431d0732985e6067d3d0038d2ae970e5f12cd4862b1380a3cd1d86230bdf90a171a93d3cd82b8cbe140a4d3685b0 + languageName: node + linkType: hard + "@smithy/smithy-client@npm:^2.0.2": version: 2.0.3 resolution: "@smithy/smithy-client@npm:2.0.3" @@ -15224,6 +15979,20 @@ __metadata: languageName: node linkType: hard +"@smithy/smithy-client@npm:^3.1.8, @smithy/smithy-client@npm:^3.1.9": + version: 3.1.9 + resolution: "@smithy/smithy-client@npm:3.1.9" + dependencies: + "@smithy/middleware-endpoint": ^3.0.5 + "@smithy/middleware-stack": ^3.0.3 + "@smithy/protocol-http": ^4.0.4 + "@smithy/types": ^3.3.0 + "@smithy/util-stream": ^3.1.1 + tslib: ^2.6.2 + checksum: 2d030ca4dd3e0767e30d3bd78d7eaea19ec96f8b03a8e15b61494ea4719f63d6f25290d2d4269fdbcc2df1912ece1aa8a4b92b5f2c2f3d3c75628002ce0b5b6a + languageName: node + linkType: hard + "@smithy/types@npm:^1.0.0, @smithy/types@npm:^1.1.0": version: 1.1.0 resolution: "@smithy/types@npm:1.1.0" @@ -15314,6 +16083,15 @@ __metadata: languageName: node linkType: hard +"@smithy/types@npm:^3.3.0": + version: 3.3.0 + resolution: "@smithy/types@npm:3.3.0" + dependencies: + tslib: ^2.6.2 + checksum: 29bb5f83c41e32f8d4094a2aba2d3dfbd763ab5943784a700f3fa22df0dcf0ccac1b1907f7a87fbb9f6f2269fcd4750524bcb48f892249e200ffe397c0981309 + languageName: node + linkType: hard + "@smithy/url-parser@npm:^2.0.1": version: 2.0.1 resolution: "@smithy/url-parser@npm:2.0.1" @@ -15391,6 +16169,17 @@ __metadata: languageName: node linkType: hard +"@smithy/url-parser@npm:^3.0.3": + version: 3.0.3 + resolution: "@smithy/url-parser@npm:3.0.3" + dependencies: + "@smithy/querystring-parser": ^3.0.3 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 86b4bc8e6c176b56076c30233ca4cfeb98d162fe27a348ddfda5f163ce7d173b8e684aa26202bbf4e0b5695b0ad43c0cb40170ca6793652d0ea6edb00443c036 + languageName: node + linkType: hard + "@smithy/util-base64@npm:^2.0.0": version: 2.0.0 resolution: "@smithy/util-base64@npm:2.0.0" @@ -15584,6 +16373,19 @@ __metadata: languageName: node linkType: hard +"@smithy/util-defaults-mode-browser@npm:^3.0.10": + version: 3.0.11 + resolution: "@smithy/util-defaults-mode-browser@npm:3.0.11" + dependencies: + "@smithy/property-provider": ^3.1.3 + "@smithy/smithy-client": ^3.1.9 + "@smithy/types": ^3.3.0 + bowser: ^2.11.0 + tslib: ^2.6.2 + checksum: 62536fc7e81a180e30445c94af022223a89346c3c2f2d3fe7e48ec67e198ed31e1de598f6195a3142b6db7edb94b701ad49f52a6ef9ed546b137b97219537014 + languageName: node + linkType: hard + "@smithy/util-defaults-mode-browser@npm:^3.0.3": version: 3.0.3 resolution: "@smithy/util-defaults-mode-browser@npm:3.0.3" @@ -15669,6 +16471,21 @@ __metadata: languageName: node linkType: hard +"@smithy/util-defaults-mode-node@npm:^3.0.10": + version: 3.0.11 + resolution: "@smithy/util-defaults-mode-node@npm:3.0.11" + dependencies: + "@smithy/config-resolver": ^3.0.5 + "@smithy/credential-provider-imds": ^3.1.4 + "@smithy/node-config-provider": ^3.1.4 + "@smithy/property-provider": ^3.1.3 + "@smithy/smithy-client": ^3.1.9 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: 3df80c51cf77cd5215e64a48936831fad5f7d2accff3bed1ac62813bbd49da601cbca386b6efe0af67d33ddea423f428df14b4ca750ec7a376eb8a2e95893ba8 + languageName: node + linkType: hard + "@smithy/util-defaults-mode-node@npm:^3.0.3": version: 3.0.3 resolution: "@smithy/util-defaults-mode-node@npm:3.0.3" @@ -15743,6 +16560,17 @@ __metadata: languageName: node linkType: hard +"@smithy/util-endpoints@npm:^2.0.5": + version: 2.0.5 + resolution: "@smithy/util-endpoints@npm:2.0.5" + dependencies: + "@smithy/node-config-provider": ^3.1.4 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: bb2a96323f52beaf2820f4e5764c865cff3ac5bca0c0df6923bb4582b0f87faf1606110cd4e36005ac43f41e9673ebdca4bbb8b913880fc2a4e0ff3301250da8 + languageName: node + linkType: hard + "@smithy/util-hex-encoding@npm:^1.1.0": version: 1.1.0 resolution: "@smithy/util-hex-encoding@npm:1.1.0" @@ -15838,6 +16666,16 @@ __metadata: languageName: node linkType: hard +"@smithy/util-middleware@npm:^3.0.3": + version: 3.0.3 + resolution: "@smithy/util-middleware@npm:3.0.3" + dependencies: + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: f37f25d65595af5ff4c3f69fa7e66545ac1651f77979e15ffbc9047e18fc668dae90458ee76add85a49ea3729c49d317e40542d5430e81e2eafe8dcae2ddb3bc + languageName: node + linkType: hard + "@smithy/util-retry@npm:^2.0.0": version: 2.0.0 resolution: "@smithy/util-retry@npm:2.0.0" @@ -15903,6 +16741,17 @@ __metadata: languageName: node linkType: hard +"@smithy/util-retry@npm:^3.0.3": + version: 3.0.3 + resolution: "@smithy/util-retry@npm:3.0.3" + dependencies: + "@smithy/service-error-classification": ^3.0.3 + "@smithy/types": ^3.3.0 + tslib: ^2.6.2 + checksum: c760595376154be67414083aa6f76094022df72987521469b124ef3ef5848c0536757dcd2006520580380db6a4d7b597a05569470c3151f71d5e678df63f4c13 + languageName: node + linkType: hard + "@smithy/util-stream@npm:^2.0.14": version: 2.0.14 resolution: "@smithy/util-stream@npm:2.0.14" @@ -15999,6 +16848,22 @@ __metadata: languageName: node linkType: hard +"@smithy/util-stream@npm:^3.1.0, @smithy/util-stream@npm:^3.1.1": + version: 3.1.1 + resolution: "@smithy/util-stream@npm:3.1.1" + dependencies: + "@smithy/fetch-http-handler": ^3.2.2 + "@smithy/node-http-handler": ^3.1.3 + "@smithy/types": ^3.3.0 + "@smithy/util-base64": ^3.0.0 + "@smithy/util-buffer-from": ^3.0.0 + "@smithy/util-hex-encoding": ^3.0.0 + "@smithy/util-utf8": ^3.0.0 + tslib: ^2.6.2 + checksum: a66ce6ffebfccbf5bf81cfef08f9286839e6d17406203e42d41d611e69da558a0c1ef98b218e5544a07a8171a60792437c3468d92ef41910a8472c052f47c6bc + languageName: node + linkType: hard + "@smithy/util-uri-escape@npm:^1.1.0": version: 1.1.0 resolution: "@smithy/util-uri-escape@npm:1.1.0" From f1ae405f7ba6b31e7f46ee8e605ee61a76eb12a0 Mon Sep 17 00:00:00 2001 From: Jacob Lee Date: Wed, 24 Jul 2024 13:55:52 -0700 Subject: [PATCH 06/11] Adds callback backgrounding env var in more places (#6196) --- docs/core_docs/docs/concepts.mdx | 3 +++ docs/core_docs/docs/how_to/agent_executor.ipynb | 3 +++ docs/core_docs/docs/how_to/debugging.mdx | 3 +++ .../docs/how_to/graph_constructing.ipynb | 3 +++ docs/core_docs/docs/how_to/graph_mapping.ipynb | 3 +++ docs/core_docs/docs/how_to/graph_prompting.ipynb | 3 +++ docs/core_docs/docs/how_to/graph_semantic.ipynb | 3 +++ docs/core_docs/docs/how_to/message_history.mdx | 3 +++ docs/core_docs/docs/how_to/migrate_agent.ipynb | 5 ++++- .../docs/how_to/qa_chat_history_how_to.ipynb | 3 +++ docs/core_docs/docs/how_to/qa_citations.ipynb | 3 +++ docs/core_docs/docs/how_to/qa_per_user.ipynb | 3 +++ docs/core_docs/docs/how_to/qa_sources.ipynb | 3 +++ docs/core_docs/docs/how_to/qa_streaming.ipynb | 3 +++ docs/core_docs/docs/how_to/query_few_shot.ipynb | 3 +++ .../docs/how_to/query_high_cardinality.ipynb | 3 +++ .../docs/how_to/query_multiple_queries.ipynb | 3 +++ .../docs/how_to/query_multiple_retrievers.ipynb | 3 +++ .../core_docs/docs/how_to/query_no_queries.ipynb | 3 +++ docs/core_docs/docs/how_to/sql_large_db.mdx | 3 +++ docs/core_docs/docs/how_to/sql_prompting.mdx | 3 +++ .../core_docs/docs/how_to/sql_query_checking.mdx | 3 +++ docs/core_docs/docs/how_to/tools_prompting.ipynb | 3 +++ docs/core_docs/docs/tutorials/agents.mdx | 3 +++ docs/core_docs/docs/tutorials/chatbot.ipynb | 3 +++ docs/core_docs/docs/tutorials/extraction.ipynb | 3 +++ docs/core_docs/docs/tutorials/graph.ipynb | 3 +++ docs/core_docs/docs/tutorials/llm_chain.ipynb | 3 +++ docs/core_docs/docs/tutorials/local_rag.ipynb | 3 +++ .../docs/tutorials/qa_chat_history.ipynb | 16 ++++++---------- .../docs/tutorials/query_analysis.ipynb | 3 +++ docs/core_docs/docs/tutorials/rag.ipynb | 3 +++ docs/core_docs/docs/tutorials/sql_qa.mdx | 3 +++ 33 files changed, 103 insertions(+), 11 deletions(-) diff --git a/docs/core_docs/docs/concepts.mdx b/docs/core_docs/docs/concepts.mdx index 84c48cdcaedb..93ae85ab9b68 100644 --- a/docs/core_docs/docs/concepts.mdx +++ b/docs/core_docs/docs/concepts.mdx @@ -72,6 +72,9 @@ After that, you can enable it by setting environment variables: ```shell export LANGCHAIN_TRACING_V2=true export LANGCHAIN_API_KEY=ls__... + +# Reduce tracing latency if you are not in a serverless environment +# export LANGCHAIN_CALLBACKS_BACKGROUND=true ``` ## LangChain Expression Language diff --git a/docs/core_docs/docs/how_to/agent_executor.ipynb b/docs/core_docs/docs/how_to/agent_executor.ipynb index 630c52d8aff1..1d68a826feff 100644 --- a/docs/core_docs/docs/how_to/agent_executor.ipynb +++ b/docs/core_docs/docs/how_to/agent_executor.ipynb @@ -67,6 +67,9 @@ "```shell\n", "export LANGCHAIN_TRACING_V2=\"true\"\n", "export LANGCHAIN_API_KEY=\"...\"\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```\n" ] }, diff --git a/docs/core_docs/docs/how_to/debugging.mdx b/docs/core_docs/docs/how_to/debugging.mdx index 2e93a2396536..dd92e4b15587 100644 --- a/docs/core_docs/docs/how_to/debugging.mdx +++ b/docs/core_docs/docs/how_to/debugging.mdx @@ -18,6 +18,9 @@ After you sign up at the link above, make sure to set your environment variables ```shell export LANGCHAIN_TRACING_V2="true" export LANGCHAIN_API_KEY="..." + +# Reduce tracing latency if you are not in a serverless environment +# export LANGCHAIN_CALLBACKS_BACKGROUND=true ``` Let's suppose we have an agent, and want to visualize the actions it takes and tool outputs it receives. Without any debugging, here's what we see: diff --git a/docs/core_docs/docs/how_to/graph_constructing.ipynb b/docs/core_docs/docs/how_to/graph_constructing.ipynb index 6e8b44adec70..8a78dc81aee4 100644 --- a/docs/core_docs/docs/how_to/graph_constructing.ipynb +++ b/docs/core_docs/docs/how_to/graph_constructing.ipynb @@ -42,6 +42,9 @@ "# Optional, use LangSmith for best-in-class observability\n", "LANGSMITH_API_KEY=your-api-key\n", "LANGCHAIN_TRACING_V2=true\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```\n", "\n", "Next, we need to define Neo4j credentials.\n", diff --git a/docs/core_docs/docs/how_to/graph_mapping.ipynb b/docs/core_docs/docs/how_to/graph_mapping.ipynb index 60c3ebd6b027..f715f75b9c5e 100644 --- a/docs/core_docs/docs/how_to/graph_mapping.ipynb +++ b/docs/core_docs/docs/how_to/graph_mapping.ipynb @@ -41,6 +41,9 @@ "# Optional, use LangSmith for best-in-class observability\n", "LANGSMITH_API_KEY=your-api-key\n", "LANGCHAIN_TRACING_V2=true\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```\n", "\n", "Next, we need to define Neo4j credentials.\n", diff --git a/docs/core_docs/docs/how_to/graph_prompting.ipynb b/docs/core_docs/docs/how_to/graph_prompting.ipynb index 73fca7deda39..6d3a442d279e 100644 --- a/docs/core_docs/docs/how_to/graph_prompting.ipynb +++ b/docs/core_docs/docs/how_to/graph_prompting.ipynb @@ -37,6 +37,9 @@ "# Optional, use LangSmith for best-in-class observability\n", "LANGSMITH_API_KEY=your-api-key\n", "LANGCHAIN_TRACING_V2=true\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```\n", "\n", "Next, we need to define Neo4j credentials.\n", diff --git a/docs/core_docs/docs/how_to/graph_semantic.ipynb b/docs/core_docs/docs/how_to/graph_semantic.ipynb index aec3aaf4f1d8..36f335e304b4 100644 --- a/docs/core_docs/docs/how_to/graph_semantic.ipynb +++ b/docs/core_docs/docs/how_to/graph_semantic.ipynb @@ -44,6 +44,9 @@ "# Optional, use LangSmith for best-in-class observability\n", "LANGSMITH_API_KEY=your-api-key\n", "LANGCHAIN_TRACING_V2=true\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```\n", "\n", "Next, we need to define Neo4j credentials.\n", diff --git a/docs/core_docs/docs/how_to/message_history.mdx b/docs/core_docs/docs/how_to/message_history.mdx index a3443322ed69..fe1c9c294c39 100644 --- a/docs/core_docs/docs/how_to/message_history.mdx +++ b/docs/core_docs/docs/how_to/message_history.mdx @@ -48,6 +48,9 @@ If you do want to use LangSmith, after you sign up at the link above, make sure ```bash export LANGCHAIN_TRACING_V2="true" export LANGCHAIN_API_KEY="" + +# Reduce tracing latency if you are not in a serverless environment +# export LANGCHAIN_CALLBACKS_BACKGROUND=true ``` Let's create a simple runnable that takes a dict as input and returns a `BaseMessage`. diff --git a/docs/core_docs/docs/how_to/migrate_agent.ipynb b/docs/core_docs/docs/how_to/migrate_agent.ipynb index f91cd3fd2454..26f5e0d5136c 100644 --- a/docs/core_docs/docs/how_to/migrate_agent.ipynb +++ b/docs/core_docs/docs/how_to/migrate_agent.ipynb @@ -60,7 +60,10 @@ "// process.env.LANGCHAIN_API_KEY = \"ls...\";\n", "// process.env.LANGCHAIN_CALLBACKS_BACKGROUND = \"true\";\n", "// process.env.LANGCHAIN_TRACING_V2 = \"true\";\n", - "// process.env.LANGCHAIN_PROJECT = \"How to migrate: LangGraphJS\";" + "// process.env.LANGCHAIN_PROJECT = \"How to migrate: LangGraphJS\";\n", + "\n", + "// Reduce tracing latency if you are not in a serverless environment\n", + "// process.env.LANGCHAIN_CALLBACKS_BACKGROUND = \"true\";" ] }, { diff --git a/docs/core_docs/docs/how_to/qa_chat_history_how_to.ipynb b/docs/core_docs/docs/how_to/qa_chat_history_how_to.ipynb index 2e276e92f1e2..db2f63d19198 100644 --- a/docs/core_docs/docs/how_to/qa_chat_history_how_to.ipynb +++ b/docs/core_docs/docs/how_to/qa_chat_history_how_to.ipynb @@ -60,6 +60,9 @@ "```bash\n", "export LANGCHAIN_TRACING_V2=true\n", "export LANGCHAIN_API_KEY=YOUR_KEY\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```" ] }, diff --git a/docs/core_docs/docs/how_to/qa_citations.ipynb b/docs/core_docs/docs/how_to/qa_citations.ipynb index cfcce3a490bd..4069fe97b022 100644 --- a/docs/core_docs/docs/how_to/qa_citations.ipynb +++ b/docs/core_docs/docs/how_to/qa_citations.ipynb @@ -57,6 +57,9 @@ "```bash\n", "export LANGCHAIN_TRACING_V2=true\n", "export LANGCHAIN_API_KEY=YOUR_KEY\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```" ] }, diff --git a/docs/core_docs/docs/how_to/qa_per_user.ipynb b/docs/core_docs/docs/how_to/qa_per_user.ipynb index 4e29ca6dd5b7..d3aa48764ece 100644 --- a/docs/core_docs/docs/how_to/qa_per_user.ipynb +++ b/docs/core_docs/docs/how_to/qa_per_user.ipynb @@ -89,6 +89,9 @@ "# Optional, use LangSmith for best-in-class observability\n", "LANGSMITH_API_KEY=your-api-key\n", "LANGCHAIN_TRACING_V2=true\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```" ] }, diff --git a/docs/core_docs/docs/how_to/qa_sources.ipynb b/docs/core_docs/docs/how_to/qa_sources.ipynb index 142f40e5909a..dde30197c953 100644 --- a/docs/core_docs/docs/how_to/qa_sources.ipynb +++ b/docs/core_docs/docs/how_to/qa_sources.ipynb @@ -55,6 +55,9 @@ "```bash\n", "export LANGCHAIN_TRACING_V2=true\n", "export LANGCHAIN_API_KEY=YOUR_KEY\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```" ] }, diff --git a/docs/core_docs/docs/how_to/qa_streaming.ipynb b/docs/core_docs/docs/how_to/qa_streaming.ipynb index 6a301673dc3e..882938a3eb9c 100644 --- a/docs/core_docs/docs/how_to/qa_streaming.ipynb +++ b/docs/core_docs/docs/how_to/qa_streaming.ipynb @@ -55,6 +55,9 @@ "```bash\n", "export LANGCHAIN_TRACING_V2=true\n", "export LANGCHAIN_API_KEY=YOUR_KEY\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```" ] }, diff --git a/docs/core_docs/docs/how_to/query_few_shot.ipynb b/docs/core_docs/docs/how_to/query_few_shot.ipynb index ce094a5bbdef..63c91e179561 100644 --- a/docs/core_docs/docs/how_to/query_few_shot.ipynb +++ b/docs/core_docs/docs/how_to/query_few_shot.ipynb @@ -46,6 +46,9 @@ "# Optional, use LangSmith for best-in-class observability\n", "LANGSMITH_API_KEY=your-api-key\n", "LANGCHAIN_TRACING_V2=true\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```" ] }, diff --git a/docs/core_docs/docs/how_to/query_high_cardinality.ipynb b/docs/core_docs/docs/how_to/query_high_cardinality.ipynb index 251e8c988f13..b07798438704 100644 --- a/docs/core_docs/docs/how_to/query_high_cardinality.ipynb +++ b/docs/core_docs/docs/how_to/query_high_cardinality.ipynb @@ -48,6 +48,9 @@ "# Optional, use LangSmith for best-in-class observability\n", "LANGSMITH_API_KEY=your-api-key\n", "LANGCHAIN_TRACING_V2=true\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```" ] }, diff --git a/docs/core_docs/docs/how_to/query_multiple_queries.ipynb b/docs/core_docs/docs/how_to/query_multiple_queries.ipynb index 67712988d1ea..acac9787666a 100644 --- a/docs/core_docs/docs/how_to/query_multiple_queries.ipynb +++ b/docs/core_docs/docs/how_to/query_multiple_queries.ipynb @@ -46,6 +46,9 @@ "# Optional, use LangSmith for best-in-class observability\n", "LANGSMITH_API_KEY=your-api-key\n", "LANGCHAIN_TRACING_V2=true\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```" ] }, diff --git a/docs/core_docs/docs/how_to/query_multiple_retrievers.ipynb b/docs/core_docs/docs/how_to/query_multiple_retrievers.ipynb index 933f5f49593e..74962e8e7634 100644 --- a/docs/core_docs/docs/how_to/query_multiple_retrievers.ipynb +++ b/docs/core_docs/docs/how_to/query_multiple_retrievers.ipynb @@ -46,6 +46,9 @@ "# Optional, use LangSmith for best-in-class observability\n", "LANGSMITH_API_KEY=your-api-key\n", "LANGCHAIN_TRACING_V2=true\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```" ] }, diff --git a/docs/core_docs/docs/how_to/query_no_queries.ipynb b/docs/core_docs/docs/how_to/query_no_queries.ipynb index 171f5ac8dda1..a97d0e7541d0 100644 --- a/docs/core_docs/docs/how_to/query_no_queries.ipynb +++ b/docs/core_docs/docs/how_to/query_no_queries.ipynb @@ -48,6 +48,9 @@ "# Optional, use LangSmith for best-in-class observability\n", "LANGSMITH_API_KEY=your-api-key\n", "LANGCHAIN_TRACING_V2=true\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```" ] }, diff --git a/docs/core_docs/docs/how_to/sql_large_db.mdx b/docs/core_docs/docs/how_to/sql_large_db.mdx index 8ce512bc8fc2..9c4895632d0e 100644 --- a/docs/core_docs/docs/how_to/sql_large_db.mdx +++ b/docs/core_docs/docs/how_to/sql_large_db.mdx @@ -25,6 +25,9 @@ export OPENAI_API_KEY="your api key" # Uncomment the below to use LangSmith. Not required. # export LANGCHAIN_API_KEY="your api key" # export LANGCHAIN_TRACING_V2=true + +# Reduce tracing latency if you are not in a serverless environment +# export LANGCHAIN_CALLBACKS_BACKGROUND=true ``` The below example will use a SQLite connection with Chinook database. Follow these [installation steps](https://database.guide/2-sample-databases-sqlite/) to create `Chinook.db` in the same directory as this notebook: diff --git a/docs/core_docs/docs/how_to/sql_prompting.mdx b/docs/core_docs/docs/how_to/sql_prompting.mdx index 827fd147a224..5cfbc2879cd2 100644 --- a/docs/core_docs/docs/how_to/sql_prompting.mdx +++ b/docs/core_docs/docs/how_to/sql_prompting.mdx @@ -24,6 +24,9 @@ export OPENAI_API_KEY="your api key" # Uncomment the below to use LangSmith. Not required. # export LANGCHAIN_API_KEY="your api key" # export LANGCHAIN_TRACING_V2=true + +# Reduce tracing latency if you are not in a serverless environment +# export LANGCHAIN_CALLBACKS_BACKGROUND=true ``` The below example will use a SQLite connection with Chinook database. Follow these [installation steps](https://database.guide/2-sample-databases-sqlite/) to create `Chinook.db` in the same directory as this notebook: diff --git a/docs/core_docs/docs/how_to/sql_query_checking.mdx b/docs/core_docs/docs/how_to/sql_query_checking.mdx index 66505a175256..7cb5146b6e8b 100644 --- a/docs/core_docs/docs/how_to/sql_query_checking.mdx +++ b/docs/core_docs/docs/how_to/sql_query_checking.mdx @@ -28,6 +28,9 @@ export OPENAI_API_KEY="your api key" # Uncomment the below to use LangSmith. Not required. # export LANGCHAIN_API_KEY="your api key" # export LANGCHAIN_TRACING_V2=true + +# Reduce tracing latency if you are not in a serverless environment +# export LANGCHAIN_CALLBACKS_BACKGROUND=true ``` The below example will use a SQLite connection with Chinook database. Follow these [installation steps](https://database.guide/2-sample-databases-sqlite/) to create `Chinook.db` in the same directory as this notebook: diff --git a/docs/core_docs/docs/how_to/tools_prompting.ipynb b/docs/core_docs/docs/how_to/tools_prompting.ipynb index a5ac5aa739d8..be665e49604c 100644 --- a/docs/core_docs/docs/how_to/tools_prompting.ipynb +++ b/docs/core_docs/docs/how_to/tools_prompting.ipynb @@ -53,6 +53,9 @@ "# Optional, use LangSmith for best-in-class observability\n", "LANGSMITH_API_KEY=your-api-key\n", "LANGCHAIN_TRACING_V2=true\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```" ] }, diff --git a/docs/core_docs/docs/tutorials/agents.mdx b/docs/core_docs/docs/tutorials/agents.mdx index abf836f1f152..6176affc1a07 100644 --- a/docs/core_docs/docs/tutorials/agents.mdx +++ b/docs/core_docs/docs/tutorials/agents.mdx @@ -31,6 +31,9 @@ When building with LangChain, all steps will automatically be traced in LangSmit ```bash export LANGCHAIN_TRACING_V2="true" export LANGCHAIN_API_KEY="" + +# Reduce tracing latency if you are not in a serverless environment +# export LANGCHAIN_CALLBACKS_BACKGROUND=true ``` ## Define tools diff --git a/docs/core_docs/docs/tutorials/chatbot.ipynb b/docs/core_docs/docs/tutorials/chatbot.ipynb index 90baa457d9e1..ea09b0aa4199 100644 --- a/docs/core_docs/docs/tutorials/chatbot.ipynb +++ b/docs/core_docs/docs/tutorials/chatbot.ipynb @@ -71,6 +71,9 @@ "```shell\n", "export LANGCHAIN_TRACING_V2=\"true\"\n", "export LANGCHAIN_API_KEY=\"...\"\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```\n", "\n", "## Quickstart\n", diff --git a/docs/core_docs/docs/tutorials/extraction.ipynb b/docs/core_docs/docs/tutorials/extraction.ipynb index e1a17a350f0b..696550cf3fc2 100644 --- a/docs/core_docs/docs/tutorials/extraction.ipynb +++ b/docs/core_docs/docs/tutorials/extraction.ipynb @@ -66,6 +66,9 @@ "```shell\n", "export LANGCHAIN_TRACING_V2=\"true\"\n", "export LANGCHAIN_API_KEY=\"...\"\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```" ] }, diff --git a/docs/core_docs/docs/tutorials/graph.ipynb b/docs/core_docs/docs/tutorials/graph.ipynb index 240f6014f6e3..723fdf971cbf 100644 --- a/docs/core_docs/docs/tutorials/graph.ipynb +++ b/docs/core_docs/docs/tutorials/graph.ipynb @@ -62,6 +62,9 @@ "# Optional, use LangSmith for best-in-class observability\n", "LANGSMITH_API_KEY=your-api-key\n", "LANGCHAIN_TRACING_V2=true\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```\n", "\n", "Next, we need to define Neo4j credentials.\n", diff --git a/docs/core_docs/docs/tutorials/llm_chain.ipynb b/docs/core_docs/docs/tutorials/llm_chain.ipynb index 59791535b5e8..592fef3cb35b 100644 --- a/docs/core_docs/docs/tutorials/llm_chain.ipynb +++ b/docs/core_docs/docs/tutorials/llm_chain.ipynb @@ -61,6 +61,9 @@ "```shell\n", "export LANGCHAIN_TRACING_V2=\"true\"\n", "export LANGCHAIN_API_KEY=\"...\"\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```" ] }, diff --git a/docs/core_docs/docs/tutorials/local_rag.ipynb b/docs/core_docs/docs/tutorials/local_rag.ipynb index be5cc79bbdd1..ca3d7a6af086 100644 --- a/docs/core_docs/docs/tutorials/local_rag.ipynb +++ b/docs/core_docs/docs/tutorials/local_rag.ipynb @@ -40,6 +40,9 @@ "```bash\n", "export LANGCHAIN_TRACING_V2=true\n", "export LANGCHAIN_API_KEY=YOUR_KEY\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```" ] }, diff --git a/docs/core_docs/docs/tutorials/qa_chat_history.ipynb b/docs/core_docs/docs/tutorials/qa_chat_history.ipynb index 73e71987570d..6c0c9f3e8c03 100644 --- a/docs/core_docs/docs/tutorials/qa_chat_history.ipynb +++ b/docs/core_docs/docs/tutorials/qa_chat_history.ipynb @@ -68,6 +68,9 @@ "```bash\n", "export LANGCHAIN_TRACING_V2=true\n", "export LANGCHAIN_API_KEY=YOUR_KEY\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```" ] }, @@ -80,7 +83,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -92,15 +95,8 @@ "import { pull } from \"langchain/hub\";\n", "import { ChatPromptTemplate } from \"@langchain/core/prompts\";\n", "import { RunnableSequence, RunnablePassthrough } from \"@langchain/core/runnables\";\n", - "import { StringOutputParser } from \"@langchain/core/output_parsers\";" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ + "import { StringOutputParser } from \"@langchain/core/output_parsers\";\n", + "\n", "import { createStuffDocumentsChain } from \"langchain/chains/combine_documents\";\n", "\n", "const loader = new CheerioWebBaseLoader(\n", diff --git a/docs/core_docs/docs/tutorials/query_analysis.ipynb b/docs/core_docs/docs/tutorials/query_analysis.ipynb index 26a5287eb85d..18c879293ced 100644 --- a/docs/core_docs/docs/tutorials/query_analysis.ipynb +++ b/docs/core_docs/docs/tutorials/query_analysis.ipynb @@ -69,6 +69,9 @@ "# Optional, use LangSmith for best-in-class observability\n", "LANGSMITH_API_KEY=your-api-key\n", "LANGCHAIN_TRACING_V2=true\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```" ] }, diff --git a/docs/core_docs/docs/tutorials/rag.ipynb b/docs/core_docs/docs/tutorials/rag.ipynb index b7fbcbc1a44f..7e48f61db958 100644 --- a/docs/core_docs/docs/tutorials/rag.ipynb +++ b/docs/core_docs/docs/tutorials/rag.ipynb @@ -74,6 +74,9 @@ "```shell\n", "export LANGCHAIN_TRACING_V2=\"true\"\n", "export LANGCHAIN_API_KEY=\"...\"\n", + "\n", + "# Reduce tracing latency if you are not in a serverless environment\n", + "# export LANGCHAIN_CALLBACKS_BACKGROUND=true\n", "```\n", "\n", "```{=mdx}\n", diff --git a/docs/core_docs/docs/tutorials/sql_qa.mdx b/docs/core_docs/docs/tutorials/sql_qa.mdx index 1357b9f45665..d0e0d2001424 100644 --- a/docs/core_docs/docs/tutorials/sql_qa.mdx +++ b/docs/core_docs/docs/tutorials/sql_qa.mdx @@ -51,6 +51,9 @@ export OPENAI_API_KEY= # Uncomment the below to use LangSmith. Not required, but recommended for debugging and observability. # export LANGCHAIN_API_KEY= # export LANGCHAIN_TRACING_V2=true + +# Reduce tracing latency if you are not in a serverless environment +# export LANGCHAIN_CALLBACKS_BACKGROUND=true ``` import CodeBlock from "@theme/CodeBlock"; From 636c17f3559da57cc73c0e930439d5606b0755ba Mon Sep 17 00:00:00 2001 From: Jacob Lee Date: Wed, 24 Jul 2024 14:23:08 -0700 Subject: [PATCH 07/11] openai[patch]: Release 0.2.5 (#6198) --- libs/langchain-openai/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/langchain-openai/package.json b/libs/langchain-openai/package.json index 7206318016bc..4c2cd0a04196 100644 --- a/libs/langchain-openai/package.json +++ b/libs/langchain-openai/package.json @@ -1,6 +1,6 @@ { "name": "@langchain/openai", - "version": "0.2.4", + "version": "0.2.5", "description": "OpenAI integrations for LangChain.js", "type": "module", "engines": { From 066f7836a650a3dc7044f1a1c785d25b401d5639 Mon Sep 17 00:00:00 2001 From: Brace Sproul Date: Wed, 24 Jul 2024 15:18:41 -0700 Subject: [PATCH 08/11] ci[minor]: Start building on windows (#6188) * ci[minor]: Start building on windows * use @rollup/wasm-node * new file url parser * cr * cr * cr * cr * cr * cr * cr * cr * use path.resolve * cr * cr * update rimraf add fs.rm * cr * cr * new * cr * better * shell true * cr * cr * cr * release 0.0.19 (non rc) * bump min langchain scripts v due to script name change * try dynamic node version in ci * re-release scripts w lower rimraf version, update min versions in pkgs --- .github/workflows/ci.yml | 17 +++ examples/package.json | 2 +- langchain-core/package.json | 4 +- langchain/package.json | 4 +- .../template/package.json | 4 +- libs/langchain-anthropic/package.json | 4 +- libs/langchain-aws/package.json | 4 +- .../package.json | 2 +- libs/langchain-azure-openai/package.json | 4 +- libs/langchain-baidu-qianfan/package.json | 4 +- libs/langchain-cloudflare/package.json | 4 +- libs/langchain-cohere/package.json | 4 +- libs/langchain-community/package.json | 4 +- libs/langchain-exa/package.json | 4 +- libs/langchain-google-common/package.json | 4 +- libs/langchain-google-gauth/package.json | 4 +- libs/langchain-google-genai/package.json | 4 +- .../package.json | 4 +- libs/langchain-google-vertexai/package.json | 4 +- libs/langchain-google-webauth/package.json | 4 +- libs/langchain-groq/package.json | 4 +- libs/langchain-mistralai/package.json | 4 +- libs/langchain-mixedbread-ai/package.json | 4 +- libs/langchain-mongodb/package.json | 4 +- libs/langchain-nomic/package.json | 4 +- libs/langchain-ollama/package.json | 4 +- libs/langchain-openai/package.json | 4 +- libs/langchain-pinecone/package.json | 4 +- libs/langchain-qdrant/package.json | 4 +- libs/langchain-redis/package.json | 4 +- libs/langchain-scripts/bin/build_v2.js | 2 +- libs/langchain-scripts/package.json | 8 +- libs/langchain-scripts/src/build_v2.ts | 106 ++++++++++++++++-- libs/langchain-standard-tests/package.json | 2 +- libs/langchain-textsplitters/package.json | 4 +- libs/langchain-weaviate/package.json | 4 +- libs/langchain-yandex/package.json | 4 +- yarn.lock | 89 +++++++++------ 38 files changed, 237 insertions(+), 111 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7eeac497481f..9688ce873994 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,3 +43,20 @@ jobs: uses: ./.github/workflows/test-exports.yml secrets: inherit + + platform-compatibility: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: "yarn" + - name: Install dependencies + run: yarn install --immutable + - name: Build `@langchain/core` + run: yarn build --filter=@langchain/core \ No newline at end of file diff --git a/examples/package.json b/examples/package.json index 80d6edd06752..5be71f5be945 100644 --- a/examples/package.json +++ b/examples/package.json @@ -57,7 +57,7 @@ "@langchain/pinecone": "workspace:*", "@langchain/qdrant": "workspace:*", "@langchain/redis": "workspace:*", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@langchain/textsplitters": "workspace:*", "@langchain/weaviate": "workspace:*", "@langchain/yandex": "workspace:*", diff --git a/langchain-core/package.json b/langchain-core/package.json index c0ebe813c0a4..501fabe33879 100644 --- a/langchain-core/package.json +++ b/langchain-core/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/langchain-core/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/core", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "clean": "rm -rf .turbo dist/", "build:deps": "yarn turbo build", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rimraf dist/tests dist/**/tests", @@ -56,7 +56,7 @@ }, "devDependencies": { "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", "@types/mustache": "^4", diff --git a/langchain/package.json b/langchain/package.json index 44211a3a0b14..02479401abba 100644 --- a/langchain/package.json +++ b/langchain/package.json @@ -570,7 +570,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/langchain/", "scripts": { "build": "yarn turbo:command build:internal --filter=langchain", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking --gen-maps", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking --gen-maps", "build:deps": "yarn run turbo:command build --filter=@langchain/openai --filter=@langchain/textsplitters --filter=@langchain/cohere --concurrency=1", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rimraf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rimraf dist-cjs", @@ -610,7 +610,7 @@ "@gomomento/sdk-core": "^1.51.1", "@jest/globals": "^29.5.0", "@langchain/cohere": "^0.0.8", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@mendable/firecrawl-js": "^0.0.13", "@notionhq/client": "^2.2.10", "@pinecone-database/pinecone": "^1.1.0", diff --git a/libs/create-langchain-integration/template/package.json b/libs/create-langchain-integration/template/package.json index bdbf6649f41b..e5598ae4c7da 100644 --- a/libs/create-langchain-integration/template/package.json +++ b/libs/create-langchain-integration/template/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-INTEGRATION_NAME/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/INTEGRATION_NAME", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", @@ -45,7 +45,7 @@ "@jest/globals": "^29.5.0", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@tsconfig/recommended": "^1.0.3", "@typescript-eslint/eslint-plugin": "^6.12.0", "@typescript-eslint/parser": "^6.12.0", diff --git a/libs/langchain-anthropic/package.json b/libs/langchain-anthropic/package.json index 7feeab136a27..b84dc13040f7 100644 --- a/libs/langchain-anthropic/package.json +++ b/libs/langchain-anthropic/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-anthropic/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/anthropic", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking --gen-maps", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking --gen-maps", "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", @@ -44,7 +44,7 @@ "devDependencies": { "@jest/globals": "^29.5.0", "@langchain/community": "workspace:*", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@langchain/standard-tests": "0.0.0", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", diff --git a/libs/langchain-aws/package.json b/libs/langchain-aws/package.json index 5bfac18e5270..784468d10feb 100644 --- a/libs/langchain-aws/package.json +++ b/libs/langchain-aws/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-aws/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/aws", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", @@ -49,7 +49,7 @@ "devDependencies": { "@aws-sdk/types": "^3.609.0", "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@langchain/standard-tests": "0.0.0", "@smithy/types": "^3.2.0", "@swc/core": "^1.3.90", diff --git a/libs/langchain-azure-dynamic-sessions/package.json b/libs/langchain-azure-dynamic-sessions/package.json index f26be33388ee..70a793156660 100644 --- a/libs/langchain-azure-dynamic-sessions/package.json +++ b/libs/langchain-azure-dynamic-sessions/package.json @@ -44,7 +44,7 @@ }, "devDependencies": { "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0", + "@langchain/scripts": "~0.0.20", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", "@tsconfig/recommended": "^1.0.3", diff --git a/libs/langchain-azure-openai/package.json b/libs/langchain-azure-openai/package.json index 99ec548694f3..4c2180c79530 100644 --- a/libs/langchain-azure-openai/package.json +++ b/libs/langchain-azure-openai/package.json @@ -14,7 +14,7 @@ }, "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/azure-openai", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", @@ -41,7 +41,7 @@ "devDependencies": { "@azure/identity": "^4.0.1", "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@langchain/standard-tests": "0.0.0", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", diff --git a/libs/langchain-baidu-qianfan/package.json b/libs/langchain-baidu-qianfan/package.json index 6b3bf46efc28..a78ca4b7674c 100644 --- a/libs/langchain-baidu-qianfan/package.json +++ b/libs/langchain-baidu-qianfan/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-baidu-qianfan/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/baidu-qianfan", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", @@ -40,7 +40,7 @@ "devDependencies": { "@jest/globals": "^29.5.0", "@langchain/openai": "~0.1.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", "@tsconfig/recommended": "^1.0.3", diff --git a/libs/langchain-cloudflare/package.json b/libs/langchain-cloudflare/package.json index 24669f14f9d1..31a6165706ca 100644 --- a/libs/langchain-cloudflare/package.json +++ b/libs/langchain-cloudflare/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-cloudflare/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/cloudflare", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", @@ -42,7 +42,7 @@ "devDependencies": { "@cloudflare/workers-types": "^4.20231218.0", "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@langchain/standard-tests": "0.0.0", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", diff --git a/libs/langchain-cohere/package.json b/libs/langchain-cohere/package.json index e2ea27eabf25..b2680f95f7d3 100644 --- a/libs/langchain-cohere/package.json +++ b/libs/langchain-cohere/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-cohere/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/cohere", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", @@ -43,7 +43,7 @@ }, "devDependencies": { "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@langchain/standard-tests": "0.0.0", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", diff --git a/libs/langchain-community/package.json b/libs/langchain-community/package.json index 0cf08f08c340..fb6c18f8c190 100644 --- a/libs/langchain-community/package.json +++ b/libs/langchain-community/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-community/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/community", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking --gen-maps", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking --gen-maps", "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", @@ -79,7 +79,7 @@ "@huggingface/inference": "^2.6.4", "@jest/globals": "^29.5.0", "@langchain/langgraph": "<0.1.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@langchain/standard-tests": "0.0.0", "@layerup/layerup-security": "^1.5.12", "@mendable/firecrawl-js": "^0.0.13", diff --git a/libs/langchain-exa/package.json b/libs/langchain-exa/package.json index d4cc7a84c435..da2a42deb93a 100644 --- a/libs/langchain-exa/package.json +++ b/libs/langchain-exa/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-exa/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/exa", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", @@ -45,7 +45,7 @@ }, "devDependencies": { "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", "@tsconfig/recommended": "^1.0.3", diff --git a/libs/langchain-google-common/package.json b/libs/langchain-google-common/package.json index fa371c0472ef..4f2cf4104989 100644 --- a/libs/langchain-google-common/package.json +++ b/libs/langchain-google-common/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-common/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/google-common", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", @@ -46,7 +46,7 @@ }, "devDependencies": { "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", "@tsconfig/recommended": "^1.0.3", diff --git a/libs/langchain-google-gauth/package.json b/libs/langchain-google-gauth/package.json index 462f4b13744a..55ba699a2c12 100644 --- a/libs/langchain-google-gauth/package.json +++ b/libs/langchain-google-gauth/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-gauth/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/google-gauth", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", @@ -41,7 +41,7 @@ }, "devDependencies": { "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", "@tsconfig/recommended": "^1.0.3", diff --git a/libs/langchain-google-genai/package.json b/libs/langchain-google-genai/package.json index 3cf012e763ac..525087d0420c 100644 --- a/libs/langchain-google-genai/package.json +++ b/libs/langchain-google-genai/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-genai/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/google-genai", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", @@ -41,7 +41,7 @@ }, "devDependencies": { "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@langchain/standard-tests": "0.0.0", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", diff --git a/libs/langchain-google-vertexai-web/package.json b/libs/langchain-google-vertexai-web/package.json index 7cbcdc643b14..aca3cfecef72 100644 --- a/libs/langchain-google-vertexai-web/package.json +++ b/libs/langchain-google-vertexai-web/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-vertexai-web/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/google-vertexai-web", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/google-gauth", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", @@ -45,7 +45,7 @@ }, "devDependencies": { "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", "@tsconfig/recommended": "^1.0.3", diff --git a/libs/langchain-google-vertexai/package.json b/libs/langchain-google-vertexai/package.json index 8d37a978879c..34a52b83c702 100644 --- a/libs/langchain-google-vertexai/package.json +++ b/libs/langchain-google-vertexai/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-vertexai/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/google-vertexai", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/google-gauth", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", @@ -49,7 +49,7 @@ "devDependencies": { "@jest/globals": "^29.5.0", "@langchain/google-common": "latest", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@langchain/standard-tests": "0.0.0", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", diff --git a/libs/langchain-google-webauth/package.json b/libs/langchain-google-webauth/package.json index c4319a7031be..2c8f96b0c785 100644 --- a/libs/langchain-google-webauth/package.json +++ b/libs/langchain-google-webauth/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-webauth/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/google-webauth", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/google-common", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", @@ -46,7 +46,7 @@ }, "devDependencies": { "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", "@tsconfig/recommended": "^1.0.3", diff --git a/libs/langchain-groq/package.json b/libs/langchain-groq/package.json index f0515fa6f1e7..b09839b1771c 100644 --- a/libs/langchain-groq/package.json +++ b/libs/langchain-groq/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-groq/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/groq", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", @@ -44,7 +44,7 @@ "devDependencies": { "@jest/globals": "^29.5.0", "@langchain/openai": "workspace:^", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@langchain/standard-tests": "0.0.0", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", diff --git a/libs/langchain-mistralai/package.json b/libs/langchain-mistralai/package.json index c48db01b7e19..702c96067e32 100644 --- a/libs/langchain-mistralai/package.json +++ b/libs/langchain-mistralai/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-mistralai/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/mistralai", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", @@ -43,7 +43,7 @@ }, "devDependencies": { "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@langchain/standard-tests": "0.0.0", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", diff --git a/libs/langchain-mixedbread-ai/package.json b/libs/langchain-mixedbread-ai/package.json index 2109c5aae39a..a0b95cf43c78 100644 --- a/libs/langchain-mixedbread-ai/package.json +++ b/libs/langchain-mixedbread-ai/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-mixedbread-ai/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/mixedbread-ai", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", @@ -40,7 +40,7 @@ }, "devDependencies": { "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@langchain/standard-tests": "0.0.0", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", diff --git a/libs/langchain-mongodb/package.json b/libs/langchain-mongodb/package.json index 01b385097794..4c0dc4d80895 100644 --- a/libs/langchain-mongodb/package.json +++ b/libs/langchain-mongodb/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-mongodb/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/mongodb", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/openai", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", @@ -46,7 +46,7 @@ "devDependencies": { "@jest/globals": "^29.5.0", "@langchain/openai": "workspace:*", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", "@tsconfig/recommended": "^1.0.3", diff --git a/libs/langchain-nomic/package.json b/libs/langchain-nomic/package.json index 2de4973cbc01..bb0e44ce12da 100644 --- a/libs/langchain-nomic/package.json +++ b/libs/langchain-nomic/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-nomic/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/nomic", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", @@ -46,7 +46,7 @@ "devDependencies": { "@jest/globals": "^29.5.0", "@langchain/openai": "workspace:^", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", "@tsconfig/recommended": "^1.0.3", diff --git a/libs/langchain-ollama/package.json b/libs/langchain-ollama/package.json index d6e7a7924f7a..7c9c819d0e76 100644 --- a/libs/langchain-ollama/package.json +++ b/libs/langchain-ollama/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-ollama/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/ollama", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", @@ -41,7 +41,7 @@ }, "devDependencies": { "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@langchain/standard-tests": "0.0.0", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", diff --git a/libs/langchain-openai/package.json b/libs/langchain-openai/package.json index 4c2cd0a04196..af3a0b010611 100644 --- a/libs/langchain-openai/package.json +++ b/libs/langchain-openai/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-openai/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/openai", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", @@ -44,7 +44,7 @@ "devDependencies": { "@azure/identity": "^4.2.0", "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@langchain/standard-tests": "0.0.0", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", diff --git a/libs/langchain-pinecone/package.json b/libs/langchain-pinecone/package.json index 7ab8346bf7d3..ce5f3b26e87b 100644 --- a/libs/langchain-pinecone/package.json +++ b/libs/langchain-pinecone/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-pinecone/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/pinecone", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", @@ -48,7 +48,7 @@ "@faker-js/faker": "^8.3.1", "@jest/globals": "^29.5.0", "@langchain/openai": "workspace:*", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", "@tsconfig/recommended": "^1.0.3", diff --git a/libs/langchain-qdrant/package.json b/libs/langchain-qdrant/package.json index 4a6439c67a5c..199a2a98730c 100644 --- a/libs/langchain-qdrant/package.json +++ b/libs/langchain-qdrant/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-qdrant", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/qdrant", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", @@ -46,7 +46,7 @@ "devDependencies": { "@faker-js/faker": "^8.4.1", "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", "@tsconfig/recommended": "^1.0.3", diff --git a/libs/langchain-redis/package.json b/libs/langchain-redis/package.json index d8ff3deb8cc0..5904aa23470a 100644 --- a/libs/langchain-redis/package.json +++ b/libs/langchain-redis/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-redis/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/redis", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", @@ -45,7 +45,7 @@ "devDependencies": { "@faker-js/faker": "^8.4.0", "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", "@tsconfig/recommended": "^1.0.3", diff --git a/libs/langchain-scripts/bin/build_v2.js b/libs/langchain-scripts/bin/build_v2.js index 2424bde5af0f..0e57864f2fe0 100755 --- a/libs/langchain-scripts/bin/build_v2.js +++ b/libs/langchain-scripts/bin/build_v2.js @@ -1 +1 @@ -import "../dist_build/build_v2.js"; +import "../dist/build_v2.js"; diff --git a/libs/langchain-scripts/package.json b/libs/langchain-scripts/package.json index ffa7187fece6..4c183c1d436c 100644 --- a/libs/langchain-scripts/package.json +++ b/libs/langchain-scripts/package.json @@ -1,6 +1,6 @@ { "name": "@langchain/scripts", - "version": "0.0.18", + "version": "0.0.20", "description": "Shared scripts for LangChain.js", "type": "module", "engines": { @@ -15,11 +15,12 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-scripts/", "bin": { "lc-build": "bin/build.js", - "lc-build:v2": "bin/build_v2.js" + "lc_build_v2": "bin/build_v2.js" }, "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/scripts", - "build:internal": "rm -rf ./build_new && tsc --project ./tsconfig.build.json && yarn build:generated", + "build:internal": "tsc --project ./tsconfig.build.json && yarn move:artifacts && yarn build:generated", + "move:artifacts": "mkdir -p ./dist && mv ./dist_build/* ./dist/", "build:generated": "node bin/build_v2.js --create-entrypoints --pre --tree-shaking", "build:turbo": "yarn turbo:command build --filter=@langchain/scripts", "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", @@ -38,6 +39,7 @@ "author": "LangChain", "license": "MIT", "dependencies": { + "@rollup/wasm-node": "^4.19.0", "axios": "^1.6.7", "commander": "^11.1.0", "glob": "^10.3.10", diff --git a/libs/langchain-scripts/src/build_v2.ts b/libs/langchain-scripts/src/build_v2.ts index a07ae6ec9074..006b2cf7f79f 100644 --- a/libs/langchain-scripts/src/build_v2.ts +++ b/libs/langchain-scripts/src/build_v2.ts @@ -1,10 +1,10 @@ import { spawn } from "node:child_process"; import ts from "typescript"; import fs from "node:fs"; -import { rimraf } from "rimraf"; import { Command } from "commander"; -import { rollup } from "rollup"; +import { rollup } from "@rollup/wasm-node"; import path from "node:path"; +import { glob } from "glob"; import { ExportsMapValue, ImportData, LangChainConfig } from "./types.js"; async function asyncSpawn(command: string, args: string[]) { @@ -16,6 +16,7 @@ async function asyncSpawn(command: string, args: string[]) { ...process.env, NODE_OPTIONS: "--max-old-space-size=4096", }, + shell: true, }); child.on("close", (code) => { if (code !== 0) { @@ -27,6 +28,50 @@ async function asyncSpawn(command: string, args: string[]) { }); } +const deleteFolderRecursive = async function (inputPath: string) { + try { + // Verify the path exists + if ( + await fs.promises + .access(inputPath) + .then(() => true) + .catch(() => false) + ) { + const pathStat = await fs.promises.lstat(inputPath); + // If it's a file, delete it and return + if (pathStat.isFile()) { + await fs.promises.unlink(inputPath); + } else if (pathStat.isDirectory()) { + // List contents of directory + const directoryContents = await fs.promises.readdir(inputPath); + if (directoryContents.length) { + for await (const item of directoryContents) { + const itemStat = await fs.promises.lstat( + path.join(inputPath, item) + ); + if (itemStat.isFile()) { + // Delete file + await fs.promises.unlink(path.join(inputPath, item)); + } else if (itemStat.isDirectory()) { + await deleteFolderRecursive(path.join(inputPath, item)); + } + } + } else if (directoryContents.length === 0) { + // If the directory is empty, delete it + await fs.promises.rmdir(inputPath); + } + } + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } catch (error: any) { + if (error.code !== "ENOENT") { + // If the error is not "file or directory doesn't exist", rethrow it + throw error; + } + // Otherwise, ignore the error (file or directory already doesn't exist) + } +}; + const NEWLINE = ` `; @@ -560,6 +605,10 @@ export async function moveAndRename({ dest: string; abs: (p: string) => string; }) { + if (!fs.existsSync(abs(source))) { + return; + } + try { for (const file of await fs.promises.readdir(abs(source), { withFileTypes: true, @@ -612,14 +661,27 @@ export async function buildWithTSup() { pre, } = processOptions(); - const importPath = `${process.cwd()}/langchain.config.js`; - const { config }: { config: LangChainConfig } = await import(importPath); + let langchainConfigPath = path.resolve("langchain.config.js"); + if (process.platform === "win32") { + // windows, must resolve path with file:// + langchainConfigPath = `file:///${langchainConfigPath}`; + } + + const { config }: { config: LangChainConfig } = await import( + langchainConfigPath + ); // Clean & generate build files if (pre && shouldGenMaps) { await Promise.all([ - rimraf("dist"), - rimraf(".turbo"), + deleteFolderRecursive("dist").catch((e) => { + console.error("Error removing dist (pre && shouldGenMaps)"); + throw e; + }), + deleteFolderRecursive(".turbo").catch((e) => { + console.error("Error removing .turbo (pre && shouldGenMaps)"); + throw e; + }), cleanGeneratedFiles(config), createImportMapFile(config), generateImportConstants(config), @@ -627,8 +689,14 @@ export async function buildWithTSup() { ]); } else if (pre && !shouldGenMaps) { await Promise.all([ - rimraf("dist"), - rimraf(".turbo"), + deleteFolderRecursive("dist").catch((e) => { + console.error("Error removing dist (pre && !shouldGenMaps)"); + throw e; + }), + deleteFolderRecursive(".turbo").catch((e) => { + console.error("Error deleting with deleteFolderRecursive"); + throw e; + }), cleanGeneratedFiles(config), ]); } @@ -646,9 +714,25 @@ export async function buildWithTSup() { // move CJS to dist await Promise.all([ updatePackageJson(config), - rimraf("dist-cjs"), - rimraf("dist/tests"), - rimraf("dist/**/tests"), + deleteFolderRecursive("dist-cjs").catch((e) => { + console.error("Error removing dist-cjs"); + throw e; + }), + deleteFolderRecursive("dist/tests").catch((e) => { + console.error("Error removing dist/tests"); + throw e; + }), + (async () => { + // Required for cross-platform compatibility. + // Windows does not manage globs the same as Max/Linux when deleting directories. + const testFolders = await glob("dist/**/tests"); + await Promise.all( + testFolders.map((folder) => deleteFolderRecursive(folder)) + ); + })().catch((e) => { + console.error("Error removing dist/**/tests"); + throw e; + }), ]); } diff --git a/libs/langchain-standard-tests/package.json b/libs/langchain-standard-tests/package.json index b40701745743..699fff544525 100644 --- a/libs/langchain-standard-tests/package.json +++ b/libs/langchain-standard-tests/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-standard-tests/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/standard-tests", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", diff --git a/libs/langchain-textsplitters/package.json b/libs/langchain-textsplitters/package.json index 89eba2d93ebe..d0fb8c7733a4 100644 --- a/libs/langchain-textsplitters/package.json +++ b/libs/langchain-textsplitters/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-textsplitters/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/textsplitters", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", @@ -44,7 +44,7 @@ }, "devDependencies": { "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", "@tsconfig/recommended": "^1.0.3", diff --git a/libs/langchain-weaviate/package.json b/libs/langchain-weaviate/package.json index 6ddb76e23060..b973da7df257 100644 --- a/libs/langchain-weaviate/package.json +++ b/libs/langchain-weaviate/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-weaviate/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/weaviate", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", @@ -47,7 +47,7 @@ "devDependencies": { "@jest/globals": "^29.5.0", "@langchain/openai": "workspace:^", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", "@tsconfig/recommended": "^1.0.3", diff --git a/libs/langchain-yandex/package.json b/libs/langchain-yandex/package.json index 8fa657ae97e5..0e4d92802728 100644 --- a/libs/langchain-yandex/package.json +++ b/libs/langchain-yandex/package.json @@ -15,7 +15,7 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-yandex/", "scripts": { "build": "yarn turbo:command build:internal --filter=@langchain/yandex", - "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", @@ -44,7 +44,7 @@ }, "devDependencies": { "@jest/globals": "^29.5.0", - "@langchain/scripts": "~0.0.14", + "@langchain/scripts": "~0.0.20", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", "@tsconfig/recommended": "^1.0.3", diff --git a/yarn.lock b/yarn.lock index a0ba67609156..54116cda6786 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10665,7 +10665,7 @@ __metadata: "@jest/globals": ^29.5.0 "@langchain/community": "workspace:*" "@langchain/core": ">=0.2.16 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@langchain/standard-tests": 0.0.0 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 @@ -10701,7 +10701,7 @@ __metadata: "@aws-sdk/types": ^3.609.0 "@jest/globals": ^29.5.0 "@langchain/core": ">=0.2.16 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@langchain/standard-tests": 0.0.0 "@smithy/types": ^3.2.0 "@swc/core": ^1.3.90 @@ -10737,7 +10737,7 @@ __metadata: "@azure/identity": ^4.2.0 "@jest/globals": ^29.5.0 "@langchain/core": ~0.2 - "@langchain/scripts": ~0.0 + "@langchain/scripts": ~0.0.20 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 "@tsconfig/recommended": ^1.0.3 @@ -10772,7 +10772,7 @@ __metadata: "@azure/openai": 1.0.0-beta.11 "@jest/globals": ^29.5.0 "@langchain/core": ">0.1.0 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@langchain/standard-tests": 0.0.0 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 @@ -10804,7 +10804,7 @@ __metadata: "@jest/globals": ^29.5.0 "@langchain/core": ">0.1.56 <0.3.0" "@langchain/openai": ~0.1.0 - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 "@tsconfig/recommended": ^1.0.3 @@ -10840,7 +10840,7 @@ __metadata: "@cloudflare/workers-types": ^4.20231218.0 "@jest/globals": ^29.5.0 "@langchain/core": ">0.1.0 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@langchain/standard-tests": 0.0.0 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 @@ -10883,7 +10883,7 @@ __metadata: dependencies: "@jest/globals": ^29.5.0 "@langchain/core": ">=0.2.16 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@langchain/standard-tests": 0.0.0 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 @@ -10950,7 +10950,7 @@ __metadata: "@langchain/core": ">=0.2.16 <0.3.0" "@langchain/langgraph": <0.1.0 "@langchain/openai": ">=0.1.0 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@langchain/standard-tests": 0.0.0 "@layerup/layerup-security": ^1.5.12 "@mendable/firecrawl-js": ^0.0.13 @@ -11465,7 +11465,7 @@ __metadata: resolution: "@langchain/core@workspace:langchain-core" dependencies: "@jest/globals": ^29.5.0 - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 "@types/mustache": ^4 @@ -11507,7 +11507,7 @@ __metadata: dependencies: "@jest/globals": ^29.5.0 "@langchain/core": ">0.1.0 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 "@tsconfig/recommended": ^1.0.3 @@ -11550,7 +11550,7 @@ __metadata: dependencies: "@jest/globals": ^29.5.0 "@langchain/core": ">=0.2.16 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 "@tsconfig/recommended": ^1.0.3 @@ -11584,7 +11584,7 @@ __metadata: "@jest/globals": ^29.5.0 "@langchain/core": ">0.1.56 <0.3.0" "@langchain/google-common": ~0.0.21 - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 "@tsconfig/recommended": ^1.0.3 @@ -11617,7 +11617,7 @@ __metadata: "@google/generative-ai": ^0.7.0 "@jest/globals": ^29.5.0 "@langchain/core": ">=0.2.16 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@langchain/standard-tests": 0.0.0 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 @@ -11652,7 +11652,7 @@ __metadata: "@jest/globals": ^29.5.0 "@langchain/core": ">0.1.56 <0.3.0" "@langchain/google-webauth": ~0.0.20 - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 "@tsconfig/recommended": ^1.0.3 @@ -11685,7 +11685,7 @@ __metadata: "@langchain/core": ">0.1.56 <0.3.0" "@langchain/google-common": latest "@langchain/google-gauth": ~0.0.20 - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@langchain/standard-tests": 0.0.0 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 @@ -11717,7 +11717,7 @@ __metadata: "@jest/globals": ^29.5.0 "@langchain/core": ">0.1.56 <0.3.0" "@langchain/google-common": ~0.0.21 - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 "@tsconfig/recommended": ^1.0.3 @@ -11749,7 +11749,7 @@ __metadata: "@jest/globals": ^29.5.0 "@langchain/core": ">=0.2.16 <0.3.0" "@langchain/openai": "workspace:^" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@langchain/standard-tests": 0.0.0 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 @@ -11817,7 +11817,7 @@ __metadata: dependencies: "@jest/globals": ^29.5.0 "@langchain/core": ">=0.2.16 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@langchain/standard-tests": 0.0.0 "@mistralai/mistralai": ^0.4.0 "@swc/core": ^1.3.90 @@ -11853,7 +11853,7 @@ __metadata: dependencies: "@jest/globals": ^29.5.0 "@langchain/core": ">=0.2.5 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@langchain/standard-tests": 0.0.0 "@mixedbread-ai/sdk": ^2.2.3 "@swc/core": ^1.3.90 @@ -11887,7 +11887,7 @@ __metadata: "@jest/globals": ^29.5.0 "@langchain/core": ">0.1.0 <0.3.0" "@langchain/openai": "workspace:*" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 "@tsconfig/recommended": ^1.0.3 @@ -11921,7 +11921,7 @@ __metadata: "@jest/globals": ^29.5.0 "@langchain/core": ">0.1.0 <0.3.0" "@langchain/openai": "workspace:^" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@nomic-ai/atlas": ^0.8.0 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 @@ -11953,7 +11953,7 @@ __metadata: dependencies: "@jest/globals": ^29.5.0 "@langchain/core": ">=0.2.17 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@langchain/standard-tests": 0.0.0 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 @@ -11989,7 +11989,7 @@ __metadata: "@azure/identity": ^4.2.0 "@jest/globals": ^29.5.0 "@langchain/core": ">=0.2.16 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@langchain/standard-tests": 0.0.0 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 @@ -12036,7 +12036,7 @@ __metadata: "@jest/globals": ^29.5.0 "@langchain/core": ">0.2.0 <0.3.0" "@langchain/openai": "workspace:*" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@pinecone-database/pinecone": ^3.0.0 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 @@ -12071,7 +12071,7 @@ __metadata: "@faker-js/faker": ^8.4.1 "@jest/globals": ^29.5.0 "@langchain/core": ">0.1.0 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@qdrant/js-client-rest": ^1.9.0 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 @@ -12105,7 +12105,7 @@ __metadata: "@faker-js/faker": ^8.4.0 "@jest/globals": ^29.5.0 "@langchain/core": ">0.1.0 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 "@tsconfig/recommended": ^1.0.3 @@ -12132,11 +12132,12 @@ __metadata: languageName: unknown linkType: soft -"@langchain/scripts@workspace:*, @langchain/scripts@workspace:libs/langchain-scripts, @langchain/scripts@~0.0, @langchain/scripts@~0.0.14": +"@langchain/scripts@workspace:*, @langchain/scripts@workspace:libs/langchain-scripts, @langchain/scripts@~0.0.20": version: 0.0.0-use.local resolution: "@langchain/scripts@workspace:libs/langchain-scripts" dependencies: "@jest/globals": ^29.5.0 + "@rollup/wasm-node": ^4.19.0 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 "@tsconfig/recommended": ^1.0.3 @@ -12164,7 +12165,7 @@ __metadata: typescript: ^5.4.5 bin: lc-build: bin/build.js - "lc-build:v2": bin/build_v2.js + lc_build_v2: bin/build_v2.js languageName: unknown linkType: soft @@ -12206,7 +12207,7 @@ __metadata: dependencies: "@jest/globals": ^29.5.0 "@langchain/core": ">0.2.0 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 "@tsconfig/recommended": ^1.0.3 @@ -12238,7 +12239,7 @@ __metadata: "@jest/globals": ^29.5.0 "@langchain/core": ">0.2.0 <0.3.0" "@langchain/openai": "workspace:^" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 "@tsconfig/recommended": ^1.0.3 @@ -12272,7 +12273,7 @@ __metadata: dependencies: "@jest/globals": ^29.5.0 "@langchain/core": ">0.1.0 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@swc/core": ^1.3.90 "@swc/jest": ^0.2.29 "@tsconfig/recommended": ^1.0.3 @@ -13634,6 +13635,21 @@ __metadata: languageName: node linkType: hard +"@rollup/wasm-node@npm:^4.19.0": + version: 4.19.0 + resolution: "@rollup/wasm-node@npm:4.19.0" + dependencies: + "@types/estree": 1.0.5 + fsevents: ~2.3.2 + dependenciesMeta: + fsevents: + optional: true + bin: + rollup: dist/bin/rollup + checksum: c84a1e35296b95a80d9b587d8632ddb518083213548caf1292a782794a7439921d224deaa99a7f14cede99ce15a60d03ab6c7b2e4f41c5746002c521dbcba555 + languageName: node + linkType: hard + "@rushstack/eslint-patch@npm:^1.3.3": version: 1.5.1 resolution: "@rushstack/eslint-patch@npm:1.5.1" @@ -17844,6 +17860,13 @@ __metadata: languageName: node linkType: hard +"@types/estree@npm:1.0.5": + version: 1.0.5 + resolution: "@types/estree@npm:1.0.5" + checksum: dd8b5bed28e6213b7acd0fb665a84e693554d850b0df423ac8076cc3ad5823a6bc26b0251d080bdc545af83179ede51dd3f6fa78cad2c46ed1f29624ddf3e41a + languageName: node + linkType: hard + "@types/estree@npm:^1.0.0": version: 1.0.1 resolution: "@types/estree@npm:1.0.1" @@ -25845,7 +25868,7 @@ __metadata: "@langchain/pinecone": "workspace:*" "@langchain/qdrant": "workspace:*" "@langchain/redis": "workspace:*" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@langchain/textsplitters": "workspace:*" "@langchain/weaviate": "workspace:*" "@langchain/yandex": "workspace:*" @@ -30997,7 +31020,7 @@ __metadata: "@langchain/cohere": ^0.0.8 "@langchain/core": ">=0.2.11 <0.3.0" "@langchain/openai": ">=0.1.0 <0.3.0" - "@langchain/scripts": ~0.0.14 + "@langchain/scripts": ~0.0.20 "@langchain/textsplitters": ~0.0.0 "@mendable/firecrawl-js": ^0.0.13 "@notionhq/client": ^2.2.10 From af0a5906a686a6bc1d7d5b66accbd3bfe6a75e81 Mon Sep 17 00:00:00 2001 From: Brace Sproul Date: Wed, 24 Jul 2024 15:53:43 -0700 Subject: [PATCH 09/11] langchain[minor]: Generic chat models (#6171) * langchain[minor]: Generic chat models * fix build * chore: lint files * cr * added docs and entrypoints * cr * tetss * update expect error to plain ts-ignore * implemented bindTools and withStructuredOutput * cleanup jsdoc examples * issues w docs * cr * Update docs/core_docs/docs/how_to/index.mdx * drop docs * always return ConfigurableModel and code review fixes * make all actual versions, not workspace deps * cr * cr * docs * code review * cr * cr * cr * yarn --- .../how_to/chat_models_universal_init.mdx | 75 ++ docs/core_docs/docs/how_to/index.mdx | 1 + .../src/models/chat/configurable/basic.ts | 34 + .../chat/configurable/configurable_model.ts | 19 + .../configurable_model_declaratively.ts | 92 ++ .../configurable_model_with_defaults.ts | 25 + .../configurable/inferring_model_provider.ts | 11 + langchain-core/src/runnables/base.ts | 1 - langchain/.gitignore | 4 + langchain/langchain.config.js | 3 + langchain/package.json | 61 +- .../chat_models/tests/universal.int.test.ts | 561 ++++++++++++ langchain/src/chat_models/universal.ts | 830 ++++++++++++++++++ langchain/src/load/import_constants.ts | 1 + libs/langchain-anthropic/package.json | 1 - libs/langchain-aws/package.json | 3 +- .../src/tests/embeddings.int.test.ts | 46 +- libs/langchain-groq/package.json | 1 - .../src/tests/agent.int.test.ts | 45 + .../src/tests/chat_models.int.test.ts | 49 -- libs/langchain-mistralai/package.json | 1 - .../src/tests/agent.int.test.ts | 50 +- .../src/tests/chat_models.int.test.ts | 59 +- yarn.lock | 81 +- 24 files changed, 1878 insertions(+), 176 deletions(-) create mode 100644 docs/core_docs/docs/how_to/chat_models_universal_init.mdx create mode 100644 examples/src/models/chat/configurable/basic.ts create mode 100644 examples/src/models/chat/configurable/configurable_model.ts create mode 100644 examples/src/models/chat/configurable/configurable_model_declaratively.ts create mode 100644 examples/src/models/chat/configurable/configurable_model_with_defaults.ts create mode 100644 examples/src/models/chat/configurable/inferring_model_provider.ts create mode 100644 langchain/src/chat_models/tests/universal.int.test.ts create mode 100644 langchain/src/chat_models/universal.ts create mode 100644 libs/langchain-groq/src/tests/agent.int.test.ts diff --git a/docs/core_docs/docs/how_to/chat_models_universal_init.mdx b/docs/core_docs/docs/how_to/chat_models_universal_init.mdx new file mode 100644 index 000000000000..fcde843c20a4 --- /dev/null +++ b/docs/core_docs/docs/how_to/chat_models_universal_init.mdx @@ -0,0 +1,75 @@ +# How to init any model in one line + +import CodeBlock from "@theme/CodeBlock"; + +Many LLM applications let end users specify what model provider and model they want the application to be powered by. +This requires writing some logic to initialize different ChatModels based on some user configuration. +The `initChatModel()` helper method makes it easy to initialize a number of different model integrations without having to worry about import paths and class names. +Keep in mind this feature is only for chat models. + +:::info Prerequisites + +This guide assumes familiarity with the following concepts: + +- [Chat models](/docs/concepts/#chat-models) + +- [LangChain Expression Language (LCEL)](/docs/concepts#langchain-expression-language) + +- [Tool calling](/docs/concepts#tools) + +::: + +:::caution Compatibility +**This feature is only intended to be used in Node environments. Use in non Node environments or with bundlers is not guaranteed to work and not officially supported.** + +`initChatModel` requires `langchain>=0.2.11`. See [this guide](/docs/how_to/installation/#installing-integration-packages) for some considerations to take when upgrading. + +See the [initChatModel()](https://v02.api.js.langchain.com/functions/langchain_chat_models_configurable.initChatModel.html) API reference for a full list of supported integrations. + +Make sure you have the integration packages installed for any model providers you want to support. E.g. you should have `@langchain/openai` installed to init an OpenAI model. +::: + +## Basic usage + +import BasicExample from "@examples/models/chat/configurable/basic.ts"; + +{BasicExample} + +## Inferring model provider + +For common and distinct model names `initChatModel()` will attempt to infer the model provider. +See the [API reference](https://v02.api.js.langchain.com/functions/langchain_chat_models_configurable.initChatModel.html) for a full list of inference behavior. +E.g. any model that starts with `gpt-3...` or `gpt-4...` will be inferred as using model provider `openai`. + +import InferringProviderExample from "@examples/models/chat/configurable/inferring_model_provider.ts"; + +{InferringProviderExample} + +## Creating a configurable model + +You can also create a runtime-configurable model by specifying `configurableFields`. +If you don't specify a `model` value, then "model" and "modelProvider" be configurable by default. + +import ConfigurableModelExample from "@examples/models/chat/configurable/configurable_model.ts"; + +{ConfigurableModelExample} + +### Configurable model with default values + +We can create a configurable model with default model values, specify which parameters are configurable, and add prefixes to configurable params: + +import ConfigurableModelWithDefaultsExample from "@examples/models/chat/configurable/configurable_model_with_defaults.ts"; + + + {ConfigurableModelWithDefaultsExample} + + +### Using a configurable model declaratively + +We can call declarative operations like `bindTools`, `withStructuredOutput`, `withConfig`, etc. on a configurable model and chain a configurable model in the same way that we would a regularly instantiated chat model object. + +import ConfigurableModelDeclarativelyExample from "@examples/models/chat/configurable/configurable_model_declaratively.ts"; + + + {ConfigurableModelDeclarativelyExample} + diff --git a/docs/core_docs/docs/how_to/index.mdx b/docs/core_docs/docs/how_to/index.mdx index c728d251b54c..13baa0549444 100644 --- a/docs/core_docs/docs/how_to/index.mdx +++ b/docs/core_docs/docs/how_to/index.mdx @@ -76,6 +76,7 @@ These are the core building blocks you can use when building applications. - [How to: stream tool calls](/docs/how_to/tool_streaming) - [How to: few shot prompt tool behavior](/docs/how_to/tool_calling#few-shotting-with-tools) - [How to: force a specific tool call](/docs/how_to/tool_choice) +- [How to: init any model in one line](/docs/how_to/chat_models_universal_init/) ### Messages diff --git a/examples/src/models/chat/configurable/basic.ts b/examples/src/models/chat/configurable/basic.ts new file mode 100644 index 000000000000..b1c2de344625 --- /dev/null +++ b/examples/src/models/chat/configurable/basic.ts @@ -0,0 +1,34 @@ +import { initChatModel } from "langchain/chat_models/universal"; + +// Returns a @langchain/openai ChatOpenAI instance. +const gpt4o = await initChatModel("gpt-4o", { + modelProvider: "openai", + temperature: 0, +}); +// Returns a @langchain/anthropic ChatAnthropic instance. +const claudeOpus = await initChatModel("claude-3-opus-20240229", { + modelProvider: "anthropic", + temperature: 0, +}); +// Returns a @langchain/google-vertexai ChatVertexAI instance. +const gemini15 = await initChatModel("gemini-1.5-pro", { + modelProvider: "google-vertexai", + temperature: 0, +}); + +// Since all model integrations implement the ChatModel interface, you can use them in the same way. +console.log(`GPT-4o: ${(await gpt4o.invoke("what's your name")).content}\n`); +console.log( + `Claude Opus: ${(await claudeOpus.invoke("what's your name")).content}\n` +); +console.log( + `Gemini 1.5: ${(await gemini15.invoke("what's your name")).content}\n` +); + +/* +GPT-4o: I'm an AI language model created by OpenAI, and I don't have a personal name. You can call me Assistant or any other name you prefer! How can I help you today? + +Claude Opus: My name is Claude. It's nice to meet you! + +Gemini 1.5: I don't have a name. I am a large language model, and I am not a person. I am a computer program that can generate text, translate languages, write different kinds of creative content, and answer your questions in an informative way. +*/ diff --git a/examples/src/models/chat/configurable/configurable_model.ts b/examples/src/models/chat/configurable/configurable_model.ts new file mode 100644 index 000000000000..d2c0f2d49493 --- /dev/null +++ b/examples/src/models/chat/configurable/configurable_model.ts @@ -0,0 +1,19 @@ +import { initChatModel } from "langchain/chat_models/universal"; + +const configurableModel = await initChatModel(undefined, { temperature: 0 }); + +const gpt4Res = await configurableModel.invoke("what's your name", { + configurable: { model: "gpt-4o" }, +}); +console.log("gpt4Res: ", gpt4Res.content); +/* +gpt4Res: I'm an AI language model created by OpenAI, and I don't have a personal name. You can call me Assistant or any other name you prefer! How can I assist you today? +*/ + +const claudeRes = await configurableModel.invoke("what's your name", { + configurable: { model: "claude-3-5-sonnet-20240620" }, +}); +console.log("claudeRes: ", claudeRes.content); +/* +claudeRes: My name is Claude. It's nice to meet you! +*/ diff --git a/examples/src/models/chat/configurable/configurable_model_declaratively.ts b/examples/src/models/chat/configurable/configurable_model_declaratively.ts new file mode 100644 index 000000000000..f4513a9a320d --- /dev/null +++ b/examples/src/models/chat/configurable/configurable_model_declaratively.ts @@ -0,0 +1,92 @@ +import { z } from "zod"; +import { tool } from "@langchain/core/tools"; +import { initChatModel } from "langchain/chat_models/universal"; + +const GetWeather = z + .object({ + location: z.string().describe("The city and state, e.g. San Francisco, CA"), + }) + .describe("Get the current weather in a given location"); +const weatherTool = tool( + (_) => { + // do something + return "138 degrees"; + }, + { + name: "GetWeather", + schema: GetWeather, + } +); + +const GetPopulation = z + .object({ + location: z.string().describe("The city and state, e.g. San Francisco, CA"), + }) + .describe("Get the current population in a given location"); +const populationTool = tool( + (_) => { + // do something + return "one hundred billion"; + }, + { + name: "GetPopulation", + schema: GetPopulation, + } +); + +const llm = await initChatModel(undefined, { temperature: 0 }); +const llmWithTools = llm.bindTools([weatherTool, populationTool]); + +const toolCalls1 = ( + await llmWithTools.invoke("what's bigger in 2024 LA or NYC", { + configurable: { model: "gpt-4o" }, + }) +).tool_calls; +console.log("toolCalls1: ", JSON.stringify(toolCalls1, null, 2)); +/* +toolCalls1: [ + { + "name": "GetPopulation", + "args": { + "location": "Los Angeles, CA" + }, + "type": "tool_call", + "id": "call_DXRBVE4xfLYZfhZOsW1qRbr5" + }, + { + "name": "GetPopulation", + "args": { + "location": "New York, NY" + }, + "type": "tool_call", + "id": "call_6ec3m4eWhwGz97sCbNt7kOvC" + } +] +*/ + +const toolCalls2 = ( + await llmWithTools.invoke("what's bigger in 2024 LA or NYC", { + configurable: { model: "claude-3-5-sonnet-20240620" }, + }) +).tool_calls; +console.log("toolCalls2: ", JSON.stringify(toolCalls2, null, 2)); +/* +toolCalls2: [ + { + "name": "GetPopulation", + "args": { + "location": "Los Angeles, CA" + }, + "id": "toolu_01K3jNU8jx18sJ9Y6Q9SooJ7", + "type": "tool_call" + }, + { + "name": "GetPopulation", + "args": { + "location": "New York City, NY" + }, + "id": "toolu_01UiANKaSwYykuF4hi3t5oNB", + "type": "tool_call" + } +] +*/ diff --git a/examples/src/models/chat/configurable/configurable_model_with_defaults.ts b/examples/src/models/chat/configurable/configurable_model_with_defaults.ts new file mode 100644 index 000000000000..e4530fce30d0 --- /dev/null +++ b/examples/src/models/chat/configurable/configurable_model_with_defaults.ts @@ -0,0 +1,25 @@ +import { initChatModel } from "langchain/chat_models/universal"; + +const firstLlm = await initChatModel("gpt-4o", { + temperature: 0, + configurableFields: ["model", "modelProvider", "temperature", "maxTokens"], + configPrefix: "first", // useful when you have a chain with multiple models +}); + +const openaiRes = await firstLlm.invoke("what's your name"); +console.log("openaiRes: ", openaiRes.content); +/* +openaiRes: I'm an AI language model created by OpenAI, and I don't have a personal name. You can call me Assistant or any other name you prefer! How can I assist you today? +*/ + +const claudeRes = await firstLlm.invoke("what's your name", { + configurable: { + first_model: "claude-3-5-sonnet-20240620", + first_temperature: 0.5, + first_maxTokens: 100, + }, +}); +console.log("claudeRes: ", claudeRes.content); +/* +claudeRes: My name is Claude. It's nice to meet you! +*/ diff --git a/examples/src/models/chat/configurable/inferring_model_provider.ts b/examples/src/models/chat/configurable/inferring_model_provider.ts new file mode 100644 index 000000000000..5e23d1caa46a --- /dev/null +++ b/examples/src/models/chat/configurable/inferring_model_provider.ts @@ -0,0 +1,11 @@ +import { initChatModel } from "langchain/chat_models/universal"; + +const gpt4o = await initChatModel("gpt-4o", { + temperature: 0, +}); +const claudeOpus = await initChatModel("claude-3-opus-20240229", { + temperature: 0, +}); +const gemini15 = await initChatModel("gemini-1.5-pro", { + temperature: 0, +}); diff --git a/langchain-core/src/runnables/base.ts b/langchain-core/src/runnables/base.ts index 2f60d739eae7..4cb65f379f22 100644 --- a/langchain-core/src/runnables/base.ts +++ b/langchain-core/src/runnables/base.ts @@ -1311,7 +1311,6 @@ export class RunnableBinding< } async *transform( - // eslint-disable-next-line @typescript-eslint/no-explicit-any generator: AsyncGenerator, options: Partial ): AsyncGenerator { diff --git a/langchain/.gitignore b/langchain/.gitignore index 0047dee6bc98..63dd08cc6295 100644 --- a/langchain/.gitignore +++ b/langchain/.gitignore @@ -122,6 +122,10 @@ chains/graph_qa/cypher.cjs chains/graph_qa/cypher.js chains/graph_qa/cypher.d.ts chains/graph_qa/cypher.d.cts +chat_models/universal.cjs +chat_models/universal.js +chat_models/universal.d.ts +chat_models/universal.d.cts embeddings/cache_backed.cjs embeddings/cache_backed.js embeddings/cache_backed.d.ts diff --git a/langchain/langchain.config.js b/langchain/langchain.config.js index d086a9e2cdb8..9b03166fea60 100644 --- a/langchain/langchain.config.js +++ b/langchain/langchain.config.js @@ -65,6 +65,8 @@ export const config = { "chains/retrieval": "chains/retrieval", "chains/sql_db": "chains/sql_db/index", "chains/graph_qa/cypher": "chains/graph_qa/cypher", + // chat models + "chat_models/universal": "chat_models/universal", // embeddings "embeddings/cache_backed": "embeddings/cache_backed", "embeddings/fake": "embeddings/fake", @@ -226,6 +228,7 @@ export const config = { "chains/load", "chains/sql_db", "chains/graph_qa/cypher", + "chat_models/universal", "llms/load", "prompts/load", "memory/zep", diff --git a/langchain/package.json b/langchain/package.json index 02479401abba..d14c94caabfe 100644 --- a/langchain/package.json +++ b/langchain/package.json @@ -134,6 +134,10 @@ "chains/graph_qa/cypher.js", "chains/graph_qa/cypher.d.ts", "chains/graph_qa/cypher.d.cts", + "chat_models/universal.cjs", + "chat_models/universal.js", + "chat_models/universal.d.ts", + "chat_models/universal.d.cts", "embeddings/cache_backed.cjs", "embeddings/cache_backed.js", "embeddings/cache_backed.d.ts", @@ -609,7 +613,14 @@ "@gomomento/sdk": "^1.51.1", "@gomomento/sdk-core": "^1.51.1", "@jest/globals": "^29.5.0", - "@langchain/cohere": "^0.0.8", + "@langchain/anthropic": "^0.2.8", + "@langchain/aws": "^0.0.5", + "@langchain/cohere": "^0.2.1", + "@langchain/google-genai": "^0.0.23", + "@langchain/google-vertexai": "^0.0.20", + "@langchain/groq": "^0.0.15", + "@langchain/mistralai": "^0.0.26", + "@langchain/ollama": "^0.0.2", "@langchain/scripts": "~0.0.20", "@mendable/firecrawl-js": "^0.0.13", "@notionhq/client": "^2.2.10", @@ -694,6 +705,15 @@ "@gomomento/sdk": "^1.51.1", "@gomomento/sdk-core": "^1.51.1", "@gomomento/sdk-web": "^1.51.1", + "@langchain/anthropic": "*", + "@langchain/aws": "*", + "@langchain/cohere": "*", + "@langchain/community": "*", + "@langchain/google-genai": "*", + "@langchain/google-vertexai": "*", + "@langchain/groq": "*", + "@langchain/mistralai": "*", + "@langchain/ollama": "*", "@mendable/firecrawl-js": "^0.0.13", "@notionhq/client": "^2.2.10", "@pinecone-database/pinecone": "*", @@ -763,6 +783,36 @@ "@gomomento/sdk-web": { "optional": true }, + "@langchain/anthropic": { + "optional": true + }, + "@langchain/aws": { + "optional": true + }, + "@langchain/cohere": { + "optional": true + }, + "@langchain/community": { + "optional": true + }, + "@langchain/google-genai": { + "optional": true + }, + "@langchain/google-vertexai": { + "optional": true + }, + "@langchain/google-vertexai-web": { + "optional": true + }, + "@langchain/groq": { + "optional": true + }, + "@langchain/mistralai": { + "optional": true + }, + "@langchain/ollama": { + "optional": true + }, "@mendable/firecrawl-js": { "optional": true }, @@ -1202,6 +1252,15 @@ "import": "./chains/graph_qa/cypher.js", "require": "./chains/graph_qa/cypher.cjs" }, + "./chat_models/universal": { + "types": { + "import": "./chat_models/universal.d.ts", + "require": "./chat_models/universal.d.cts", + "default": "./chat_models/universal.d.ts" + }, + "import": "./chat_models/universal.js", + "require": "./chat_models/universal.cjs" + }, "./embeddings/cache_backed": { "types": { "import": "./embeddings/cache_backed.d.ts", diff --git a/langchain/src/chat_models/tests/universal.int.test.ts b/langchain/src/chat_models/tests/universal.int.test.ts new file mode 100644 index 000000000000..628b123bbcba --- /dev/null +++ b/langchain/src/chat_models/tests/universal.int.test.ts @@ -0,0 +1,561 @@ +/* eslint-disable no-process-env */ +import { tool } from "@langchain/core/tools"; +import { z } from "zod"; +import { it } from "@jest/globals"; +import { ChatPromptTemplate, PromptTemplate } from "@langchain/core/prompts"; +import { RunLogPatch, StreamEvent } from "@langchain/core/tracers/log_stream"; +import { AIMessageChunk } from "@langchain/core/messages"; +import { concat } from "@langchain/core/utils/stream"; +import { AgentExecutor, createReactAgent } from "../../agents/index.js"; +import { pull } from "../../hub.js"; +import { initChatModel } from "../universal.js"; + +// Make copies of API keys and remove them from the environment to avoid conflicts. + +// OpenAI +const openAIApiKey = process.env.OPENAI_API_KEY; +process.env.OPENAI_API_KEY = ""; + +// Azure OpenAI +const azureOpenAIApiKey = process.env.AZURE_OPENAI_API_KEY; +process.env.AZURE_OPENAI_API_KEY = ""; +const azureOpenAIApiDevelopmentName = + process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME; +process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME = ""; +const azureOpenAIApiVersion = process.env.AZURE_OPENAI_API_VERSION; +process.env.AZURE_OPENAI_API_VERSION = ""; +const azureOpenAIBasePath = process.env.AZURE_OPENAI_BASE_PATH; +process.env.AZURE_OPENAI_BASE_PATH = ""; + +// Google +const googleApiKey = process.env.GOOGLE_API_KEY; +process.env.GOOGLE_API_KEY = ""; + +test("Initialize non-configurable models", async () => { + const gpt4 = await initChatModel("gpt-4", { + modelProvider: "openai", + temperature: 0.25, // Funky temperature to verify it's being set properly. + apiKey: openAIApiKey, + }); + const claude = await initChatModel("claude-3-opus-20240229", { + modelProvider: "anthropic", + temperature: 0.25, + }); + const gemini = await initChatModel("gemini-1.5-pro", { + modelProvider: "google-genai", + temperature: 0.25, + }); + + const gpt4Result = await gpt4.invoke("what's your name"); + expect(gpt4Result).toBeDefined(); + expect(gpt4Result.content.length).toBeGreaterThan(0); + + const claudeResult = await claude.invoke("what's your name"); + expect(claudeResult).toBeDefined(); + expect(claudeResult.content.length).toBeGreaterThan(0); + + const geminiResult = await gemini.invoke("what's your name"); + expect(geminiResult).toBeDefined(); + expect(geminiResult.content.length).toBeGreaterThan(0); +}); + +test("Create a partially configurable model with no default model", async () => { + const configurableModel = await initChatModel(undefined, { + temperature: 0, + configurableFields: ["model", "apiKey"], + }); + + const gpt4Result = await configurableModel.invoke("what's your name", { + configurable: { + model: "gpt-4", + apiKey: openAIApiKey, + }, + }); + expect(gpt4Result).toBeDefined(); + expect(gpt4Result.content.length).toBeGreaterThan(0); + + const claudeResult = await configurableModel.invoke("what's your name", { + configurable: { + model: "claude-3-5-sonnet-20240620", + apiKey: process.env.ANTHROPIC_API_KEY, + }, + }); + expect(claudeResult).toBeDefined(); + expect(claudeResult.content.length).toBeGreaterThan(0); +}); + +test("Create a fully configurable model with a default model and a config prefix", async () => { + const configurableModelWithDefault = await initChatModel("gpt-4", { + modelProvider: "openai", + configurableFields: "any", + configPrefix: "foo", + temperature: 0, + }); + + const configurableResult = await configurableModelWithDefault.invoke( + "what's your name", + { + configurable: { + foo_apiKey: openAIApiKey, + }, + } + ); + expect(configurableResult).toBeDefined(); + expect(configurableResult.content.length).toBeGreaterThan(0); + + const configurableResult2 = await configurableModelWithDefault.invoke( + "what's your name", + { + configurable: { + foo_model: "claude-3-5-sonnet-20240620", + foo_modelProvider: "anthropic", + foo_temperature: 0.6, + foo_apiKey: process.env.ANTHROPIC_API_KEY, + }, + } + ); + expect(configurableResult2).toBeDefined(); + expect(configurableResult2.content.length).toBeGreaterThan(0); +}); + +test("Bind tools to a configurable model", async () => { + const getWeatherTool = tool( + (input) => { + // Do something with the input + return JSON.stringify(input); + }, + { + schema: z + .object({ + location: z + .string() + .describe("The city and state, e.g. San Francisco, CA"), + }) + .describe("Get the current weather in a given location"), + name: "GetWeather", + description: "Get the current weather in a given location", + } + ); + + const getPopulationTool = tool( + (input) => { + // Do something with the input + return JSON.stringify(input); + }, + { + schema: z + .object({ + location: z + .string() + .describe("The city and state, e.g. San Francisco, CA"), + }) + .describe("Get the current population in a given location"), + name: "GetPopulation", + description: "Get the current population in a given location", + } + ); + + const configurableModel = await initChatModel("gpt-4", { + configurableFields: ["model", "modelProvider", "apiKey"], + temperature: 0, + }); + + const configurableModelWithTools = configurableModel.bind({ + tools: [getWeatherTool, getPopulationTool], + }); + + const configurableToolResult = await configurableModelWithTools.invoke( + "Which city is hotter today and which is bigger: LA or NY?", + { + configurable: { + apiKey: openAIApiKey, + }, + } + ); + expect(configurableToolResult).toBeDefined(); + expect(configurableToolResult.tool_calls?.[0]).toBeDefined(); + if (!configurableToolResult.tool_calls?.[0]) return; + expect(configurableToolResult.tool_calls?.[0].name).toBe("GetWeather"); + + const configurableToolResult2 = await configurableModelWithTools.invoke( + "Which city is hotter today and which is bigger: LA or NY?", + { + configurable: { + model: "claude-3-5-sonnet-20240620", + apiKey: process.env.ANTHROPIC_API_KEY, + }, + } + ); + expect(configurableToolResult2).toBeDefined(); + expect(configurableToolResult2.tool_calls?.[0]).toBeDefined(); + if (!configurableToolResult2.tool_calls?.[0]) return; + expect(configurableToolResult2.tool_calls?.[0].name).toBe("GetWeather"); +}); + +test("Can call bindTools", async () => { + const gpt4 = await initChatModel(undefined, { + modelProvider: "openai", + temperature: 0.25, // Funky temperature to verify it's being set properly. + apiKey: openAIApiKey, + }); + const weatherTool = tool( + (input) => { + // Do something with the input + return JSON.stringify(input); + }, + { + schema: z + .object({ + location: z + .string() + .describe("The city and state, e.g. San Francisco, CA"), + }) + .describe("Get the current weather in a given location"), + name: "GetWeather", + description: "Get the current weather in a given location", + } + ); + + const gpt4WithTools = gpt4.bindTools([weatherTool]); + const result = await gpt4WithTools.invoke( + "What's the weather in San Francisco?" + ); + expect(result.tool_calls?.[0]).toBeDefined(); + expect(result.tool_calls?.[0].name).toBe("GetWeather"); +}); + +test("Can call withStructuredOutput", async () => { + const gpt4 = await initChatModel(undefined, { + modelProvider: "openai", + temperature: 0.25, // Funky temperature to verify it's being set properly. + apiKey: openAIApiKey, + }); + const weatherSchema = z + .object({ + location: z + .string() + .describe("The city and state, e.g. San Francisco, CA"), + }) + .describe("Get the current weather in a given location"); + + const gpt4WithTools = gpt4.withStructuredOutput(weatherSchema, { + name: "GetWeather", + }); + const result = await gpt4WithTools.invoke( + "What's the weather in San Francisco?" + ); + expect(result).toBeDefined(); + expect(result.location).toBeDefined(); + expect(result.location).not.toBe(""); +}); + +describe("Works with all model providers", () => { + it("Can invoke openai", async () => { + const gpt4 = await initChatModel(undefined, { + modelProvider: "openai", + temperature: 0, + apiKey: openAIApiKey, + }); + + const gpt4Result = await gpt4.invoke("what's your name"); + expect(gpt4Result).toBeDefined(); + expect(gpt4Result.content.length).toBeGreaterThan(0); + }); + + it("Can invoke anthropic", async () => { + const anthropic = await initChatModel(undefined, { + modelProvider: "anthropic", + temperature: 0, + }); + + const anthropicResult = await anthropic.invoke("what's your name"); + expect(anthropicResult).toBeDefined(); + expect(anthropicResult.content.length).toBeGreaterThan(0); + }); + + it("Can invoke azure_openai", async () => { + process.env.AZURE_OPENAI_API_KEY = azureOpenAIApiKey; + process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME = + azureOpenAIApiDevelopmentName; + process.env.AZURE_OPENAI_API_VERSION = azureOpenAIApiVersion; + process.env.AZURE_OPENAI_BASE_PATH = azureOpenAIBasePath; + + try { + const azure_openai = await initChatModel(undefined, { + modelProvider: "azure_openai", + temperature: 0, + }); + + const azure_openaiResult = await azure_openai.invoke("what's your name"); + expect(azure_openaiResult).toBeDefined(); + expect(azure_openaiResult.content.length).toBeGreaterThan(0); + } catch (e) { + // Re-assign the original env vars. + process.env.AZURE_OPENAI_API_KEY = ""; + process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME = ""; + process.env.AZURE_OPENAI_API_VERSION = ""; + process.env.AZURE_OPENAI_BASE_PATH = ""; + // Re-throw the error. + throw e; + } + }); + + it("Can invoke cohere", async () => { + const cohere = await initChatModel(undefined, { + modelProvider: "cohere", + temperature: 0, + }); + + const cohereResult = await cohere.invoke("what's your name"); + expect(cohereResult).toBeDefined(); + expect(cohereResult.content.length).toBeGreaterThan(0); + }); + + it("Can invoke google-genai", async () => { + const googleVertexai = await initChatModel(undefined, { + modelProvider: "google-genai", + temperature: 0, + }); + + const googleVertexaiResult = await googleVertexai.invoke( + "what's your name" + ); + expect(googleVertexaiResult).toBeDefined(); + expect(googleVertexaiResult.content.length).toBeGreaterThan(0); + }); + + it("Can invoke google-genai", async () => { + // Remove VertexAI env vars to avoid conflict. + const googleApplicationCredentials = + process.env.GOOGLE_APPLICATION_CREDENTIALS; + process.env.GOOGLE_APPLICATION_CREDENTIALS = ""; + // Re-assign the Google API key for this test. + process.env.GOOGLE_API_KEY = googleApiKey; + + try { + const googleGenai = await initChatModel(undefined, { + modelProvider: "google-genai", + temperature: 0, + }); + + const googleGenaiResult = await googleGenai.invoke("what's your name"); + expect(googleGenaiResult).toBeDefined(); + expect(googleGenaiResult.content.length).toBeGreaterThan(0); + } catch (e) { + // Re-assign the original env vars. + process.env.GOOGLE_APPLICATION_CREDENTIALS = googleApplicationCredentials; + process.env.GOOGLE_API_KEY = ""; + throw e; + } + }); + + it.skip("Can invoke ollama", async () => { + const ollama = await initChatModel(undefined, { + modelProvider: "ollama", + temperature: 0, + model: "llama3", + }); + + const ollamaResult = await ollama.invoke("what's your name"); + expect(ollamaResult).toBeDefined(); + expect(ollamaResult.content.length).toBeGreaterThan(0); + }); + + it("Can invoke mistralai", async () => { + const mistralai = await initChatModel(undefined, { + modelProvider: "mistralai", + temperature: 0, + }); + + const mistralaiResult = await mistralai.invoke("what's your name"); + expect(mistralaiResult).toBeDefined(); + expect(mistralaiResult.content.length).toBeGreaterThan(0); + }); + + it("Can invoke groq", async () => { + const groq = await initChatModel(undefined, { + modelProvider: "groq", + temperature: 0, + }); + + const groqResult = await groq.invoke("what's your name"); + expect(groqResult).toBeDefined(); + expect(groqResult.content.length).toBeGreaterThan(0); + }); + + it("Can invoke bedrock", async () => { + const bedrock = await initChatModel(undefined, { + modelProvider: "bedrock", + temperature: 0, + region: process.env.BEDROCK_AWS_REGION ?? "us-east-1", + credentials: { + secretAccessKey: process.env.BEDROCK_AWS_SECRET_ACCESS_KEY, + accessKeyId: process.env.BEDROCK_AWS_ACCESS_KEY_ID, + }, + }); + + const bedrockResult = await bedrock.invoke("what's your name"); + expect(bedrockResult).toBeDefined(); + expect(bedrockResult.content.length).toBeGreaterThan(0); + }); + + // If these two fail with an import error you should explicitly build `@langchain/community` + it("Can invoke fireworks", async () => { + const fireworks = await initChatModel(undefined, { + modelProvider: "fireworks", + temperature: 0, + }); + + const fireworksResult = await fireworks.invoke("what's your name"); + expect(fireworksResult).toBeDefined(); + expect(fireworksResult.content.length).toBeGreaterThan(0); + }); + + it("Can invoke together", async () => { + const together = await initChatModel(undefined, { + modelProvider: "together", + temperature: 0, + }); + + const togetherResult = await together.invoke("what's your name"); + expect(togetherResult).toBeDefined(); + expect(togetherResult.content.length).toBeGreaterThan(0); + }); +}); + +test("Is compatible with agents", async () => { + const gpt4 = await initChatModel(undefined, { + modelProvider: "openai", + temperature: 0.25, // Funky temperature to verify it's being set properly. + apiKey: openAIApiKey, + }); + + const weatherTool = tool( + (_) => { + // Do something with the input + return "The current weather is partly cloudy with a high of 75 degrees."; + }, + { + schema: z.string().describe("The city and state, e.g. San Francisco, CA"), + name: "GetWeather", + description: "Get the current weather in a given location", + } + ); + + const prompt = await pull("hwchase17/react"); + + const agent = await createReactAgent({ + llm: gpt4, + tools: [weatherTool], + prompt, + }); + + const agentExecutor = new AgentExecutor({ + agent, + tools: [weatherTool], + }); + + const result = await agentExecutor.invoke({ + input: + "What's the weather in San Francisco right now? Ensure you use the 'GetWeather' tool to answer.", + }); + expect(result).toHaveProperty("output"); + expect(result.output).not.toBe(""); +}); + +describe("Can call base runnable methods", () => { + it("can call streamEvents", async () => { + const gpt4 = await initChatModel(undefined, { + modelProvider: "openai", + temperature: 0.25, // Funky temperature to verify it's being set properly. + apiKey: openAIApiKey, + }); + + const prompt = ChatPromptTemplate.fromMessages([["human", "{input}"]]); + const stream = prompt.pipe(gpt4).streamEvents( + { + input: "what's your name", + }, + { + version: "v2", + configurable: { + model: "gpt-4o", + }, + } + ); + + const events: StreamEvent[] = []; + for await (const event of stream) { + events.push(event); + } + + // The first event should be a start event. + expect(events[0].event).toBe("on_chain_start"); + + // Events in the middle should be stream events + expect( + events[Math.floor(events.length / 2)].event.endsWith("_stream") + ).toBe(true); + + // The ;ast event should be an end event. + expect(events[events.length - 1].event).toBe("on_chain_end"); + }); + + it("can call streamLog", async () => { + const gpt4 = await initChatModel(undefined, { + modelProvider: "openai", + temperature: 0.25, // Funky temperature to verify it's being set properly. + apiKey: openAIApiKey, + }); + + const stream = gpt4.streamLog("what's your name"); + + let runLog: RunLogPatch | undefined; + for await (const event of stream) { + if (!runLog) { + runLog = event; + } else { + runLog = runLog.concat(event); + } + } + expect(runLog).toBeDefined(); + if (!runLog) return; + expect(runLog.ops.length).toBeGreaterThan(0); + }); + + it("can call stream", async () => { + const gpt4 = await initChatModel(undefined, { + modelProvider: "openai", + temperature: 0.25, // Funky temperature to verify it's being set properly. + apiKey: openAIApiKey, + }); + + const stream = await gpt4.stream("what's your name"); + let finalChunk: AIMessageChunk | undefined; + for await (const chunk of stream) { + finalChunk = !finalChunk ? chunk : concat(finalChunk, chunk); + } + + expect(finalChunk).toBeDefined(); + if (!finalChunk) return; + expect(finalChunk.content).not.toBe(""); + }); + + it("can call batch", async () => { + const gpt4 = await initChatModel(undefined, { + modelProvider: "openai", + temperature: 0.25, // Funky temperature to verify it's being set properly. + apiKey: openAIApiKey, + }); + + const batchResult = await gpt4.batch([ + "what's your name", + "what's your name", + ]); + + expect(batchResult).toHaveLength(2); + if (batchResult.length !== 2) return; + expect(batchResult[0].content).not.toBe(""); + expect(batchResult[1].content).not.toBe(""); + }); +}); diff --git a/langchain/src/chat_models/universal.ts b/langchain/src/chat_models/universal.ts new file mode 100644 index 000000000000..3afbdc0d46f3 --- /dev/null +++ b/langchain/src/chat_models/universal.ts @@ -0,0 +1,830 @@ +import { + BaseLanguageModelInput, + ToolDefinition, +} from "@langchain/core/language_models/base"; +import { + BaseChatModel, + BaseChatModelParams, + type BaseChatModelCallOptions, +} from "@langchain/core/language_models/chat_models"; +import { BaseMessage, type AIMessageChunk } from "@langchain/core/messages"; +import { + type RunnableBatchOptions, + RunnableBinding, + type RunnableConfig, + type RunnableToolLike, + ensureConfig, +} from "@langchain/core/runnables"; +import { + AsyncGeneratorWithSetup, + IterableReadableStream, +} from "@langchain/core/utils/stream"; +import { + type LogStreamCallbackHandlerInput, + type RunLogPatch, + type StreamEvent, +} from "@langchain/core/tracers/log_stream"; +import { type StructuredToolInterface } from "@langchain/core/tools"; +import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager"; +import { ChatResult } from "@langchain/core/outputs"; + +// TODO: remove once `EventStreamCallbackHandlerInput` is exposed in core. +interface EventStreamCallbackHandlerInput + extends Omit {} + +const _SUPPORTED_PROVIDERS = [ + "openai", + "anthropic", + "azure_openai", + "cohere", + "google-vertexai", + "google-genai", + "ollama", + "together", + "fireworks", + "mistralai", + "groq", + "bedrock", +] as const; + +export type ChatModelProvider = (typeof _SUPPORTED_PROVIDERS)[number]; + +export interface ConfigurableChatModelCallOptions + extends BaseChatModelCallOptions { + tools?: ( + | StructuredToolInterface + | Record + | ToolDefinition + | RunnableToolLike + )[]; +} + +async function _initChatModelHelper( + model: string, + modelProvider?: string, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + params: Record = {} +): Promise { + const modelProviderCopy = modelProvider || _inferModelProvider(model); + if (!modelProviderCopy) { + throw new Error( + `Unable to infer model provider for { model: ${model} }, please specify modelProvider directly.` + ); + } + + try { + switch (modelProviderCopy) { + case "openai": { + const { ChatOpenAI } = await import("@langchain/openai"); + return new ChatOpenAI({ model, ...params }); + } + case "anthropic": { + const { ChatAnthropic } = await import("@langchain/anthropic"); + return new ChatAnthropic({ model, ...params }); + } + case "azure_openai": { + const { AzureChatOpenAI } = await import("@langchain/openai"); + return new AzureChatOpenAI({ model, ...params }); + } + case "cohere": { + const { ChatCohere } = await import("@langchain/cohere"); + return new ChatCohere({ model, ...params }); + } + case "google-vertexai": { + const { ChatVertexAI } = await import("@langchain/google-vertexai"); + return new ChatVertexAI({ model, ...params }); + } + case "google-genai": { + const { ChatGoogleGenerativeAI } = await import( + "@langchain/google-genai" + ); + return new ChatGoogleGenerativeAI({ model, ...params }); + } + case "ollama": { + const { ChatOllama } = await import("@langchain/ollama"); + return new ChatOllama({ model, ...params }); + } + case "mistralai": { + const { ChatMistralAI } = await import("@langchain/mistralai"); + return new ChatMistralAI({ model, ...params }); + } + case "groq": { + const { ChatGroq } = await import("@langchain/groq"); + return new ChatGroq({ model, ...params }); + } + case "bedrock": { + const { ChatBedrockConverse } = await import("@langchain/aws"); + return new ChatBedrockConverse({ model, ...params }); + } + case "fireworks": { + const { ChatFireworks } = await import( + // We can not 'expect-error' because if you explicitly build `@langchain/community` + // this import will be able to be resolved, thus there will be no error. However + // this will never be the case in CI. + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore - Can not install as a proper dependency due to circular dependency + "@langchain/community/chat_models/fireworks" + ); + return new ChatFireworks({ model, ...params }); + } + case "together": { + const { ChatTogetherAI } = await import( + // We can not 'expect-error' because if you explicitly build `@langchain/community` + // this import will be able to be resolved, thus there will be no error. However + // this will never be the case in CI. + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore - Can not install as a proper dependency due to circular dependency + "@langchain/community/chat_models/togetherai" + ); + return new ChatTogetherAI({ model, ...params }); + } + default: { + const supported = _SUPPORTED_PROVIDERS.join(", "); + throw new Error( + `Unsupported { modelProvider: ${modelProviderCopy} }.\n\nSupported model providers are: ${supported}` + ); + } + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } catch (e: any) { + if ("code" in e && e.code.includes("ERR_MODULE_NOT_FOUND")) { + const attemptedPackage = new Error(e).message + .split("Error: Cannot find package '")[1] + .split("'")[0]; + throw new Error( + `Unable to import ${attemptedPackage}. Please install with ` + + `\`npm install ${attemptedPackage}\` or \`yarn add ${attemptedPackage}\`` + ); + } + throw e; + } +} + +/** + * Attempts to infer the model provider based on the given model name. + * + * @param {string} modelName - The name of the model to infer the provider for. + * @returns {string | undefined} The inferred model provider name, or undefined if unable to infer. + * + * @example + * _inferModelProvider("gpt-4"); // returns "openai" + * _inferModelProvider("claude-2"); // returns "anthropic" + * _inferModelProvider("unknown-model"); // returns undefined + */ +export function _inferModelProvider(modelName: string): string | undefined { + if (modelName.startsWith("gpt-3") || modelName.startsWith("gpt-4")) { + return "openai"; + } else if (modelName.startsWith("claude")) { + return "anthropic"; + } else if (modelName.startsWith("command")) { + return "cohere"; + } else if (modelName.startsWith("accounts/fireworks")) { + return "fireworks"; + } else if (modelName.startsWith("gemini")) { + return "google-vertexai"; + } else if (modelName.startsWith("amazon.")) { + return "bedrock"; + } else { + return undefined; + } +} + +interface ConfigurableModelFields extends BaseChatModelParams { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + defaultConfig?: Record; + /** + * @default "any" + */ + configurableFields?: string[] | "any"; + /** + * @default "" + */ + configPrefix?: string; + /** + * Methods which should be called after the model is initialized. + * The key will be the method name, and the value will be the arguments. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + queuedMethodOperations?: Record; +} + +class _ConfigurableModel< + RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, + CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions +> extends BaseChatModel { + _llmType(): string { + return "chat_model"; + } + + lc_namespace = ["langchain", "chat_models"]; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + _defaultConfig?: Record = {}; + + /** + * @default "any" + */ + _configurableFields: string[] | "any" = "any"; + + /** + * @default "" + */ + _configPrefix: string; + + /** + * Methods which should be called after the model is initialized. + * The key will be the method name, and the value will be the arguments. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + _queuedMethodOperations: Record = {}; + + constructor(fields: ConfigurableModelFields) { + super(fields); + this._defaultConfig = fields.defaultConfig ?? {}; + + if (fields.configurableFields === "any") { + this._configurableFields = "any"; + } else { + this._configurableFields = fields.configurableFields ?? "any"; + } + + if (fields.configPrefix) { + this._configPrefix = fields.configPrefix.endsWith("_") + ? fields.configPrefix + : `${fields.configPrefix}_`; + } else { + this._configPrefix = ""; + } + + this._queuedMethodOperations = + fields.queuedMethodOperations ?? this._queuedMethodOperations; + } + + async _model(config?: RunnableConfig) { + const params = { ...this._defaultConfig, ...this._modelParams(config) }; + let initializedModel = await _initChatModelHelper( + params.model, + params.modelProvider, + params + ); + + // Apply queued method operations + const queuedMethodOperationsEntries = Object.entries( + this._queuedMethodOperations + ); + if (queuedMethodOperationsEntries.length > 0) { + for (const [method, args] of queuedMethodOperationsEntries) { + if ( + method in initializedModel && + // eslint-disable-next-line @typescript-eslint/no-explicit-any + typeof (initializedModel as any)[method] === "function" + ) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + initializedModel = await (initializedModel as any)[method](...args); + } + } + } + + return initializedModel; + } + + async _generate( + messages: BaseMessage[], + options?: this["ParsedCallOptions"], + runManager?: CallbackManagerForLLMRun + ): Promise { + const model = await this._model(options); + return model._generate(messages, options ?? {}, runManager); + } + + override bindTools( + tools: ( + | StructuredToolInterface + // eslint-disable-next-line @typescript-eslint/no-explicit-any + | Record + | ToolDefinition + | RunnableToolLike + )[], + // eslint-disable-next-line @typescript-eslint/no-explicit-any + params?: Record + ): _ConfigurableModel { + this._queuedMethodOperations.bindTools = [tools, params]; + return new _ConfigurableModel({ + defaultConfig: this._defaultConfig, + configurableFields: this._configurableFields, + configPrefix: this._configPrefix, + queuedMethodOperations: this._queuedMethodOperations, + }); + } + + // Extract the input types from the `BaseModel` class. + withStructuredOutput: BaseChatModel["withStructuredOutput"] = ( + schema, + ...args + ): ReturnType => { + this._queuedMethodOperations.withStructuredOutput = [schema, ...args]; + return new _ConfigurableModel({ + defaultConfig: this._defaultConfig, + configurableFields: this._configurableFields, + configPrefix: this._configPrefix, + queuedMethodOperations: this._queuedMethodOperations, + }) as unknown as ReturnType; + }; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + _modelParams(config?: RunnableConfig): Record { + const configurable = config?.configurable ?? {}; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let modelParams: Record = {}; + + for (const [key, value] of Object.entries(configurable)) { + if (key.startsWith(this._configPrefix)) { + const strippedKey = this._removePrefix(key, this._configPrefix); + modelParams[strippedKey] = value; + } + } + + if (this._configurableFields !== "any") { + modelParams = Object.fromEntries( + Object.entries(modelParams).filter(([key]) => + this._configurableFields.includes(key) + ) + ); + } + + return modelParams; + } + + _removePrefix(str: string, prefix: string): string { + return str.startsWith(prefix) ? str.slice(prefix.length) : str; + } + + /** + * Bind config to a Runnable, returning a new Runnable. + * @param {RunnableConfig | undefined} [config] - The config to bind. + * @returns {RunnableBinding} A new RunnableBinding with the bound config. + */ + withConfig( + config?: RunnableConfig + ): RunnableBinding { + const mergedConfig: RunnableConfig = { ...(config || {}) }; + const modelParams = this._modelParams(mergedConfig); + + const remainingConfig: RunnableConfig = Object.fromEntries( + Object.entries(mergedConfig).filter(([k]) => k !== "configurable") + ); + + remainingConfig.configurable = Object.fromEntries( + Object.entries(mergedConfig.configurable || {}).filter( + ([k]) => + this._configPrefix && + !Object.keys(modelParams).includes( + this._removePrefix(k, this._configPrefix) + ) + ) + ); + + const newConfigurableModel = new _ConfigurableModel({ + defaultConfig: { ...this._defaultConfig, ...modelParams }, + configurableFields: Array.isArray(this._configurableFields) + ? [...this._configurableFields] + : this._configurableFields, + configPrefix: this._configPrefix, + }); + + return new RunnableBinding({ + config: mergedConfig, + bound: newConfigurableModel, + }); + } + + async invoke( + input: RunInput, + options?: CallOptions + ): Promise { + const model = await this._model(options); + const config = ensureConfig(options); + return model.invoke(input, config); + } + + async stream( + input: RunInput, + options?: CallOptions + ): Promise> { + const model = await this._model(options); + const wrappedGenerator = new AsyncGeneratorWithSetup({ + generator: await model.stream(input, options), + config: options, + }); + await wrappedGenerator.setup; + return IterableReadableStream.fromAsyncGenerator(wrappedGenerator); + } + + async batch( + inputs: RunInput[], + options?: Partial | Partial[], + batchOptions?: RunnableBatchOptions & { returnExceptions?: false } + ): Promise; + + async batch( + inputs: RunInput[], + options?: Partial | Partial[], + batchOptions?: RunnableBatchOptions & { returnExceptions: true } + ): Promise<(AIMessageChunk | Error)[]>; + + async batch( + inputs: RunInput[], + options?: Partial | Partial[], + batchOptions?: RunnableBatchOptions + ): Promise<(AIMessageChunk | Error)[]>; + + async batch( + inputs: RunInput[], + options?: Partial | Partial[], + batchOptions?: RunnableBatchOptions + ): Promise<(AIMessageChunk | Error)[]> { + // We can super this since the base runnable implementation of + // `.batch` will call `.invoke` on each input. + return super.batch(inputs, options, batchOptions); + } + + async *transform( + generator: AsyncGenerator, + options: CallOptions + ): AsyncGenerator { + const model = await this._model(options); + const config = ensureConfig(options); + + yield* model.transform(generator, config); + } + + async *streamLog( + input: RunInput, + options?: Partial, + streamOptions?: Omit + ): AsyncGenerator { + const model = await this._model(options); + const config = ensureConfig(options); + + yield* model.streamLog(input, config, { + ...streamOptions, + _schemaFormat: "original", + includeNames: streamOptions?.includeNames, + includeTypes: streamOptions?.includeTypes, + includeTags: streamOptions?.includeTags, + excludeNames: streamOptions?.excludeNames, + excludeTypes: streamOptions?.excludeTypes, + excludeTags: streamOptions?.excludeTags, + }); + } + + streamEvents( + input: RunInput, + options: Partial & { version: "v1" | "v2" }, + streamOptions?: Omit + ): IterableReadableStream; + + streamEvents( + input: RunInput, + options: Partial & { + version: "v1" | "v2"; + encoding: "text/event-stream"; + }, + streamOptions?: Omit + ): IterableReadableStream; + + streamEvents( + input: RunInput, + options: Partial & { + version: "v1" | "v2"; + encoding?: "text/event-stream" | undefined; + }, + streamOptions?: Omit + ): IterableReadableStream { + // eslint-disable-next-line @typescript-eslint/no-this-alias + const outerThis = this; + async function* wrappedGenerator() { + const model = await outerThis._model(options); + const config = ensureConfig(options); + const eventStream = model.streamEvents(input, config, streamOptions); + + for await (const chunk of eventStream) { + yield chunk; + } + } + return IterableReadableStream.fromAsyncGenerator(wrappedGenerator()); + } +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export interface InitChatModelFields extends Partial> { + modelProvider?: string; + configurableFields?: string[] | "any"; + configPrefix?: string; +} + +export type ConfigurableFields = "any" | string[]; + +export async function initChatModel< + RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, + CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions +>( + model: string, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + fields?: Partial> & { + modelProvider?: string; + configurableFields?: never; + configPrefix?: string; + } +): Promise<_ConfigurableModel>; + +export async function initChatModel< + RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, + CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions +>( + model: never, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + options?: Partial> & { + modelProvider?: string; + configurableFields?: never; + configPrefix?: string; + } +): Promise<_ConfigurableModel>; + +export async function initChatModel< + RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, + CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions +>( + model?: string, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + options?: Partial> & { + modelProvider?: string; + configurableFields?: ConfigurableFields; + configPrefix?: string; + } +): Promise<_ConfigurableModel>; + +// ################################# FOR CONTRIBUTORS ################################# +// +// If adding support for a new provider, please append the provider +// name to the supported list in the docstring below. +// +// #################################################################################### + +/** + * Initialize a ChatModel from the model name and provider. + * Must have the integration package corresponding to the model provider installed. + * + * @template {extends BaseLanguageModelInput = BaseLanguageModelInput} RunInput - The input type for the model. + * @template {extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions} CallOptions - Call options for the model. + * + * @param {string | ChatModelProvider} [model] - The name of the model, e.g. "gpt-4", "claude-3-opus-20240229". + * @param {Object} [fields] - Additional configuration options. + * @param {string} [fields.modelProvider] - The model provider. Supported values include: + * - openai (@langchain/openai) + * - anthropic (@langchain/anthropic) + * - azure_openai (@langchain/openai) + * - google-vertexai (@langchain/google-vertexai) + * - google-genai (@langchain/google-genai) + * - bedrock (@langchain/aws) + * - cohere (@langchain/cohere) + * - fireworks (@langchain/community/chat_models/fireworks) + * - together (@langchain/community/chat_models/togetherai) + * - mistralai (@langchain/mistralai) + * - groq (@langchain/groq) + * - ollama (@langchain/ollama) + * @param {string[] | "any"} [fields.configurableFields] - Which model parameters are configurable: + * - undefined: No configurable fields. + * - "any": All fields are configurable. (See Security Note in description) + * - string[]: Specified fields are configurable. + * @param {string} [fields.configPrefix] - Prefix for configurable fields at runtime. + * @param {Record} [fields.params] - Additional keyword args to pass to the ChatModel constructor. + * @returns {Promise<_ConfigurableModel>} A class which extends BaseChatModel. + * @throws {Error} If modelProvider cannot be inferred or isn't supported. + * @throws {Error} If the model provider integration package is not installed. + * + * @example Initialize non-configurable models + * ```typescript + * import { initChatModel } from "langchain/chat_models/universal"; + * + * const gpt4 = await initChatModel("gpt-4", { + * modelProvider: "openai", + * temperature: 0.25, + * }); + * const gpt4Result = await gpt4.invoke("what's your name"); + * + * const claude = await initChatModel("claude-3-opus-20240229", { + * modelProvider: "anthropic", + * temperature: 0.25, + * }); + * const claudeResult = await claude.invoke("what's your name"); + * + * const gemini = await initChatModel("gemini-1.5-pro", { + * modelProvider: "google-vertexai", + * temperature: 0.25, + * }); + * const geminiResult = await gemini.invoke("what's your name"); + * ``` + * + * @example Create a partially configurable model with no default model + * ```typescript + * import { initChatModel } from "langchain/chat_models/universal"; + * + * const configurableModel = await initChatModel(undefined, { + * temperature: 0, + * configurableFields: ["model", "apiKey"], + * }); + * + * const gpt4Result = await configurableModel.invoke("what's your name", { + * configurable: { + * model: "gpt-4", + * }, + * }); + * + * const claudeResult = await configurableModel.invoke("what's your name", { + * configurable: { + * model: "claude-3-5-sonnet-20240620", + * }, + * }); + * ``` + * + * @example Create a fully configurable model with a default model and a config prefix + * ```typescript + * import { initChatModel } from "langchain/chat_models/universal"; + * + * const configurableModelWithDefault = await initChatModel("gpt-4", { + * modelProvider: "openai", + * configurableFields: "any", + * configPrefix: "foo", + * temperature: 0, + * }); + * + * const openaiResult = await configurableModelWithDefault.invoke( + * "what's your name", + * { + * configurable: { + * foo_apiKey: process.env.OPENAI_API_KEY, + * }, + * } + * ); + * + * const claudeResult = await configurableModelWithDefault.invoke( + * "what's your name", + * { + * configurable: { + * foo_model: "claude-3-5-sonnet-20240620", + * foo_modelProvider: "anthropic", + * foo_temperature: 0.6, + * foo_apiKey: process.env.ANTHROPIC_API_KEY, + * }, + * } + * ); + * ``` + * + * @example Bind tools to a configurable model: + * ```typescript + * import { initChatModel } from "langchain/chat_models/universal"; + * import { z } from "zod"; + * import { tool } from "@langchain/core/tools"; + * + * const getWeatherTool = tool( + * (input) => { + * // Do something with the input + * return JSON.stringify(input); + * }, + * { + * schema: z + * .object({ + * location: z + * .string() + * .describe("The city and state, e.g. San Francisco, CA"), + * }) + * .describe("Get the current weather in a given location"), + * name: "GetWeather", + * description: "Get the current weather in a given location", + * } + * ); + * + * const getPopulationTool = tool( + * (input) => { + * // Do something with the input + * return JSON.stringify(input); + * }, + * { + * schema: z + * .object({ + * location: z + * .string() + * .describe("The city and state, e.g. San Francisco, CA"), + * }) + * .describe("Get the current population in a given location"), + * name: "GetPopulation", + * description: "Get the current population in a given location", + * } + * ); + * + * const configurableModel = await initChatModel("gpt-4", { + * configurableFields: ["model", "modelProvider", "apiKey"], + * temperature: 0, + * }); + * + * const configurableModelWithTools = configurableModel.bind({ + * tools: [getWeatherTool, getPopulationTool], + * }); + * + * const configurableToolResult = await configurableModelWithTools.invoke( + * "Which city is hotter today and which is bigger: LA or NY?", + * { + * configurable: { + * apiKey: process.env.OPENAI_API_KEY, + * }, + * } + * ); + * + * const configurableToolResult2 = await configurableModelWithTools.invoke( + * "Which city is hotter today and which is bigger: LA or NY?", + * { + * configurable: { + * model: "claude-3-5-sonnet-20240620", + * apiKey: process.env.ANTHROPIC_API_KEY, + * }, + * } + * ); + * ``` + * + * @description + * This function initializes a ChatModel based on the provided model name and provider. + * It supports various model providers and allows for runtime configuration of model parameters. + * + * Security Note: Setting `configurableFields` to "any" means fields like api_key, base_url, etc. + * can be altered at runtime, potentially redirecting model requests to a different service/user. + * Make sure that if you're accepting untrusted configurations, you enumerate the + * `configurableFields` explicitly. + * + * The function will attempt to infer the model provider from the model name if not specified. + * Certain model name prefixes are associated with specific providers: + * - gpt-3... or gpt-4... -> openai + * - claude... -> anthropic + * - amazon.... -> bedrock + * - gemini... -> google-vertexai + * - command... -> cohere + * - accounts/fireworks... -> fireworks + * + * @since 0.2.11 + * @version 0.2.11 + */ +export async function initChatModel< + RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, + CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions +>( + model?: string, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + fields?: Partial> & { + modelProvider?: string; + configurableFields?: string[] | "any"; + configPrefix?: string; + } +): Promise<_ConfigurableModel> { + const { configurableFields, configPrefix, modelProvider, ...params } = { + configPrefix: "", + ...(fields ?? {}), + }; + let configurableFieldsCopy = configurableFields; + + if (!model && !configurableFieldsCopy) { + configurableFieldsCopy = ["model", "modelProvider"]; + } + if (configPrefix && !configurableFieldsCopy) { + console.warn( + `{ configPrefix: ${configPrefix} } has been set but no fields are configurable. Set ` + + `{ configurableFields: [...] } to specify the model params that are ` + + `configurable.` + ); + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const paramsCopy: Record = { ...params }; + + if (!configurableFieldsCopy) { + return new _ConfigurableModel({ + defaultConfig: { + ...paramsCopy, + model, + modelProvider, + }, + configPrefix, + }); + } else { + if (model) { + paramsCopy.model = model; + } + if (modelProvider) { + paramsCopy.modelProvider = modelProvider; + } + return new _ConfigurableModel({ + defaultConfig: paramsCopy, + configPrefix, + configurableFields: configurableFieldsCopy, + }); + } +} diff --git a/langchain/src/load/import_constants.ts b/langchain/src/load/import_constants.ts index 069ad6cc151c..5b8817ff234c 100644 --- a/langchain/src/load/import_constants.ts +++ b/langchain/src/load/import_constants.ts @@ -10,6 +10,7 @@ export const optionalImportEntrypoints: string[] = [ "langchain/chains/query_constructor/ir", "langchain/chains/sql_db", "langchain/chains/graph_qa/cypher", + "langchain/chat_models/universal", "langchain/document_loaders/web/apify_dataset", "langchain/document_loaders/web/assemblyai", "langchain/document_loaders/web/azure_blob_storage_container", diff --git a/libs/langchain-anthropic/package.json b/libs/langchain-anthropic/package.json index b84dc13040f7..8fa253574153 100644 --- a/libs/langchain-anthropic/package.json +++ b/libs/langchain-anthropic/package.json @@ -43,7 +43,6 @@ }, "devDependencies": { "@jest/globals": "^29.5.0", - "@langchain/community": "workspace:*", "@langchain/scripts": "~0.0.20", "@langchain/standard-tests": "0.0.0", "@swc/core": "^1.3.90", diff --git a/libs/langchain-aws/package.json b/libs/langchain-aws/package.json index 784468d10feb..216557820467 100644 --- a/libs/langchain-aws/package.json +++ b/libs/langchain-aws/package.json @@ -67,7 +67,6 @@ "eslint-plugin-prettier": "^4.2.1", "jest": "^29.5.0", "jest-environment-node": "^29.6.4", - "langchain": "workspace:*", "prettier": "^2.8.3", "release-it": "^15.10.1", "rollup": "^4.5.2", @@ -97,4 +96,4 @@ "index.d.ts", "index.d.cts" ] -} \ No newline at end of file +} diff --git a/libs/langchain-aws/src/tests/embeddings.int.test.ts b/libs/langchain-aws/src/tests/embeddings.int.test.ts index 901f757abce5..d3649bb47541 100644 --- a/libs/langchain-aws/src/tests/embeddings.int.test.ts +++ b/libs/langchain-aws/src/tests/embeddings.int.test.ts @@ -3,7 +3,7 @@ import { expect, test } from "@jest/globals"; import { BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime"; -import { MemoryVectorStore } from "langchain/vectorstores/memory"; +// import { MemoryVectorStore } from "langchain/vectorstores/memory"; import { BedrockEmbeddings } from "../embeddings.js"; const getClient = () => { @@ -58,27 +58,25 @@ test("Test BedrockEmbeddings.embedDocuments with passed region and credentials", }); }); -test("Test end to end with MemoryVectorStore", async () => { - const client = getClient(); - const vectorStore = await MemoryVectorStore.fromTexts( - ["Hello world", "Bye bye", "hello nice world"], - [{ id: 2 }, { id: 1 }, { id: 3 }], - new BedrockEmbeddings({ - maxRetries: 1, - client, - }) - ); - expect(vectorStore.memoryVectors).toHaveLength(3); - - const resultOne = await vectorStore.similaritySearch("hello world", 1); - const resultOneMetadatas = resultOne.map(({ metadata }) => metadata); - expect(resultOneMetadatas).toEqual([{ id: 2 }]); - - const resultTwo = await vectorStore.similaritySearch("hello world", 2); - const resultTwoMetadatas = resultTwo.map(({ metadata }) => metadata); - expect(resultTwoMetadatas).toEqual([{ id: 2 }, { id: 3 }]); - - const resultThree = await vectorStore.similaritySearch("hello world", 3); - const resultThreeMetadatas = resultThree.map(({ metadata }) => metadata); - expect(resultThreeMetadatas).toEqual([{ id: 2 }, { id: 3 }, { id: 1 }]); +// TODO: langchain dependency breaks CI. Should add a `FakeVectorStore` in core & import here to fix. +test.skip("Test end to end with MemoryVectorStore", async () => { + // const client = getClient(); + // const vectorStore = await MemoryVectorStore.fromTexts( + // ["Hello world", "Bye bye", "hello nice world"], + // [{ id: 2 }, { id: 1 }, { id: 3 }], + // new BedrockEmbeddings({ + // maxRetries: 1, + // client, + // }) + // ); + // expect(vectorStore.memoryVectors).toHaveLength(3); + // const resultOne = await vectorStore.similaritySearch("hello world", 1); + // const resultOneMetadatas = resultOne.map(({ metadata }) => metadata); + // expect(resultOneMetadatas).toEqual([{ id: 2 }]); + // const resultTwo = await vectorStore.similaritySearch("hello world", 2); + // const resultTwoMetadatas = resultTwo.map(({ metadata }) => metadata); + // expect(resultTwoMetadatas).toEqual([{ id: 2 }, { id: 3 }]); + // const resultThree = await vectorStore.similaritySearch("hello world", 3); + // const resultThreeMetadatas = resultThree.map(({ metadata }) => metadata); + // expect(resultThreeMetadatas).toEqual([{ id: 2 }, { id: 3 }, { id: 1 }]); }); diff --git a/libs/langchain-groq/package.json b/libs/langchain-groq/package.json index b09839b1771c..d4ee60e3c8f4 100644 --- a/libs/langchain-groq/package.json +++ b/libs/langchain-groq/package.json @@ -62,7 +62,6 @@ "eslint-plugin-prettier": "^4.2.1", "jest": "^29.5.0", "jest-environment-node": "^29.6.4", - "langchain": "workspace:*", "prettier": "^2.8.3", "release-it": "^15.10.1", "rollup": "^4.5.2", diff --git a/libs/langchain-groq/src/tests/agent.int.test.ts b/libs/langchain-groq/src/tests/agent.int.test.ts new file mode 100644 index 000000000000..0e40a382d36c --- /dev/null +++ b/libs/langchain-groq/src/tests/agent.int.test.ts @@ -0,0 +1,45 @@ +// import { AgentExecutor, createOpenAIToolsAgent } from "langchain/agents"; +// import { ChatPromptTemplate } from "@langchain/core/prompts"; +// import { DynamicStructuredTool } from "@langchain/core/tools"; +// import { z } from "zod"; +// import { ChatGroq } from "../chat_models.js"; + +// TODO: This test breaks CI build due to dependencies. Figure out a way around it. +test.skip("Model is compatible with OpenAI tools agent and Agent Executor", async () => { + // const llm = new ChatGroq({ + // temperature: 0, + // modelName: "mixtral-8x7b-32768", + // }); + // const prompt = ChatPromptTemplate.fromMessages([ + // [ + // "system", + // "You are an agent capable of retrieving current weather information.", + // ], + // ["human", "{input}"], + // ["placeholder", "{agent_scratchpad}"], + // ]); + // const currentWeatherTool = new DynamicStructuredTool({ + // name: "get_current_weather", + // description: "Get the current weather in a given location", + // schema: z.object({ + // location: z + // .string() + // .describe("The city and state, e.g. San Francisco, CA"), + // }), + // func: async () => Promise.resolve("28 °C"), + // }); + // const agent = await createOpenAIToolsAgent({ + // llm, + // tools: [currentWeatherTool], + // prompt, + // }); + // const agentExecutor = new AgentExecutor({ + // agent, + // tools: [currentWeatherTool], + // }); + // const input = "What's the weather like in Paris?"; + // const { output } = await agentExecutor.invoke({ input }); + // console.log(output); + // expect(output).toBeDefined(); + // expect(output).toContain("The current temperature in Paris is 28 °C"); +}); diff --git a/libs/langchain-groq/src/tests/chat_models.int.test.ts b/libs/langchain-groq/src/tests/chat_models.int.test.ts index 6088200ee169..c2839786a39b 100644 --- a/libs/langchain-groq/src/tests/chat_models.int.test.ts +++ b/libs/langchain-groq/src/tests/chat_models.int.test.ts @@ -1,10 +1,5 @@ -import { z } from "zod"; import { test } from "@jest/globals"; - import { AIMessage, HumanMessage, ToolMessage } from "@langchain/core/messages"; -import { ChatPromptTemplate } from "@langchain/core/prompts"; -import { DynamicStructuredTool } from "@langchain/core/tools"; -import { AgentExecutor, createOpenAIToolsAgent } from "langchain/agents"; import { ChatGroq } from "../chat_models.js"; test("invoke", async () => { @@ -114,50 +109,6 @@ test("invoke with bound tools", async () => { ).toEqual(res.tool_calls?.[0].args); }); -test.skip("Model is compatible with OpenAI tools agent and Agent Executor", async () => { - const llm = new ChatGroq({ - temperature: 0, - modelName: "mixtral-8x7b-32768", - }); - const prompt = ChatPromptTemplate.fromMessages([ - [ - "system", - "You are an agent capable of retrieving current weather information.", - ], - ["human", "{input}"], - ["placeholder", "{agent_scratchpad}"], - ]); - - const currentWeatherTool = new DynamicStructuredTool({ - name: "get_current_weather", - description: "Get the current weather in a given location", - schema: z.object({ - location: z - .string() - .describe("The city and state, e.g. San Francisco, CA"), - }), - func: async () => Promise.resolve("28 °C"), - }); - - const agent = await createOpenAIToolsAgent({ - llm, - tools: [currentWeatherTool], - prompt, - }); - - const agentExecutor = new AgentExecutor({ - agent, - tools: [currentWeatherTool], - }); - - const input = "What's the weather like in Paris?"; - const { output } = await agentExecutor.invoke({ input }); - - console.log(output); - expect(output).toBeDefined(); - expect(output).toContain("The current temperature in Paris is 28 °C"); -}); - test("stream with bound tools, yielding a single chunk", async () => { const chat = new ChatGroq({ maxRetries: 0, diff --git a/libs/langchain-mistralai/package.json b/libs/langchain-mistralai/package.json index 702c96067e32..d5c8b30e78ce 100644 --- a/libs/langchain-mistralai/package.json +++ b/libs/langchain-mistralai/package.json @@ -60,7 +60,6 @@ "eslint-plugin-prettier": "^4.2.1", "jest": "^29.5.0", "jest-environment-node": "^29.6.4", - "langchain": "workspace:*", "prettier": "^2.8.3", "release-it": "^15.10.1", "rollup": "^4.5.2", diff --git a/libs/langchain-mistralai/src/tests/agent.int.test.ts b/libs/langchain-mistralai/src/tests/agent.int.test.ts index 156b773859f1..6fcbc49be579 100644 --- a/libs/langchain-mistralai/src/tests/agent.int.test.ts +++ b/libs/langchain-mistralai/src/tests/agent.int.test.ts @@ -1,9 +1,12 @@ // import { test, expect } from "@jest/globals"; -// import { ChatPromptTemplate } from "@langchain/core/prompts"; // import { TavilySearchResults } from "@langchain/community/tools/tavily_search"; -// import { AgentExecutor, createToolCallingAgent } from "langchain/agents"; // import { Calculator } from "@langchain/community/tools/calculator"; -// import { ChatMistralAI } from "../index.js"; +// import { BaseChatModel } from "@langchain/core/language_models/chat_models"; +// import { SystemMessagePromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder, ChatPromptTemplate } from "@langchain/core/prompts"; +// import { DynamicStructuredTool } from "@langchain/core/tools"; +// import { z } from "zod"; +// import { ChatMistralAI } from "../chat_models.js"; +// import { AgentExecutor, createOpenAIToolsAgent, createToolCallingAgent } from "langchain/agents"; // const tool = new TavilySearchResults({ maxResults: 1 }); // tool.description = tool.description += " You can also use this tool to check the current weather."; @@ -41,3 +44,44 @@ test("createToolCallingAgent works", async () => { // // an investigation into why such a short generation was returned. // expect(result.output.length).toBeGreaterThan(10); }); + +test("Model is compatible with OpenAI tools agent and Agent Executor", async () => { + // const llm: BaseChatModel = new ChatMistralAI({ + // temperature: 0, + // model: "mistral-large-latest", + // }); + // const systemMessage = SystemMessagePromptTemplate.fromTemplate( + // "You are an agent capable of retrieving current weather information." + // ); + // const humanMessage = HumanMessagePromptTemplate.fromTemplate("{input}"); + // const agentScratchpad = new MessagesPlaceholder("agent_scratchpad"); + // const prompt = ChatPromptTemplate.fromMessages([ + // systemMessage, + // humanMessage, + // agentScratchpad, + // ]); + // const currentWeatherTool = new DynamicStructuredTool({ + // name: "get_current_weather", + // description: "Get the current weather in a given location", + // schema: z.object({ + // location: z + // .string() + // .describe("The city and state, e.g. San Francisco, CA"), + // }), + // func: async () => Promise.resolve("28 °C"), + // }); + // const agent = await createOpenAIToolsAgent({ + // llm, + // tools: [currentWeatherTool], + // prompt, + // }); + // const agentExecutor = new AgentExecutor({ + // agent, + // tools: [currentWeatherTool], + // }); + // const input = "What's the weather like in Paris?"; + // const { output } = await agentExecutor.invoke({ input }); + // console.log(output); + // expect(output).toBeDefined(); + // expect(output).toContain("The current temperature in Paris is 28 °C"); +}); diff --git a/libs/langchain-mistralai/src/tests/chat_models.int.test.ts b/libs/langchain-mistralai/src/tests/chat_models.int.test.ts index ab8127b17cc1..7280ceddacf4 100644 --- a/libs/langchain-mistralai/src/tests/chat_models.int.test.ts +++ b/libs/langchain-mistralai/src/tests/chat_models.int.test.ts @@ -1,13 +1,6 @@ import { test } from "@jest/globals"; -import { - ChatPromptTemplate, - HumanMessagePromptTemplate, - MessagesPlaceholder, - SystemMessagePromptTemplate, -} from "@langchain/core/prompts"; -import { AgentExecutor, createOpenAIToolsAgent } from "langchain/agents"; -import { BaseChatModel } from "@langchain/core/language_models/chat_models"; -import { DynamicStructuredTool, StructuredTool } from "@langchain/core/tools"; +import { ChatPromptTemplate } from "@langchain/core/prompts"; +import { StructuredTool } from "@langchain/core/tools"; import { z } from "zod"; import { AIMessage, @@ -639,54 +632,6 @@ describe("withStructuredOutput", () => { ) ).toBe(true); }); - - test("Model is compatible with OpenAI tools agent and Agent Executor", async () => { - const llm: BaseChatModel = new ChatMistralAI({ - temperature: 0, - model: "mistral-large-latest", - }); - - const systemMessage = SystemMessagePromptTemplate.fromTemplate( - "You are an agent capable of retrieving current weather information." - ); - const humanMessage = HumanMessagePromptTemplate.fromTemplate("{input}"); - const agentScratchpad = new MessagesPlaceholder("agent_scratchpad"); - - const prompt = ChatPromptTemplate.fromMessages([ - systemMessage, - humanMessage, - agentScratchpad, - ]); - - const currentWeatherTool = new DynamicStructuredTool({ - name: "get_current_weather", - description: "Get the current weather in a given location", - schema: z.object({ - location: z - .string() - .describe("The city and state, e.g. San Francisco, CA"), - }), - func: async () => Promise.resolve("28 °C"), - }); - - const agent = await createOpenAIToolsAgent({ - llm, - tools: [currentWeatherTool], - prompt, - }); - - const agentExecutor = new AgentExecutor({ - agent, - tools: [currentWeatherTool], - }); - - const input = "What's the weather like in Paris?"; - const { output } = await agentExecutor.invoke({ input }); - - console.log(output); - expect(output).toBeDefined(); - expect(output).toContain("The current temperature in Paris is 28 °C"); - }); }); describe("ChatMistralAI aborting", () => { diff --git a/yarn.lock b/yarn.lock index 54116cda6786..c5dcede32a3e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10657,13 +10657,12 @@ __metadata: languageName: node linkType: hard -"@langchain/anthropic@workspace:*, @langchain/anthropic@workspace:libs/langchain-anthropic": +"@langchain/anthropic@^0.2.8, @langchain/anthropic@workspace:*, @langchain/anthropic@workspace:libs/langchain-anthropic": version: 0.0.0-use.local resolution: "@langchain/anthropic@workspace:libs/langchain-anthropic" dependencies: "@anthropic-ai/sdk": ^0.22.0 "@jest/globals": ^29.5.0 - "@langchain/community": "workspace:*" "@langchain/core": ">=0.2.16 <0.3.0" "@langchain/scripts": ~0.0.20 "@langchain/standard-tests": 0.0.0 @@ -10690,7 +10689,7 @@ __metadata: languageName: unknown linkType: soft -"@langchain/aws@workspace:*, @langchain/aws@workspace:libs/langchain-aws": +"@langchain/aws@^0.0.5, @langchain/aws@workspace:*, @langchain/aws@workspace:libs/langchain-aws": version: 0.0.0-use.local resolution: "@langchain/aws@workspace:libs/langchain-aws" dependencies: @@ -10719,7 +10718,6 @@ __metadata: eslint-plugin-prettier: ^4.2.1 jest: ^29.5.0 jest-environment-node: ^29.6.4 - langchain: "workspace:*" prettier: ^2.8.3 release-it: ^15.10.1 rollup: ^4.5.2 @@ -10867,17 +10865,7 @@ __metadata: languageName: unknown linkType: soft -"@langchain/cohere@npm:^0.0.8": - version: 0.0.8 - resolution: "@langchain/cohere@npm:0.0.8" - dependencies: - "@langchain/core": ~0.1.58 - cohere-ai: ^7.9.3 - checksum: f7ba95cb4f715eb0e77c7d6f842d61663baefb4a5f164bb872945b011d3e12f5fa320e976d605d943f70cc67801fd7618e2beac99cd74666f20f2000ac26a961 - languageName: node - linkType: hard - -"@langchain/cohere@workspace:*, @langchain/cohere@workspace:libs/langchain-cohere": +"@langchain/cohere@^0.2.1, @langchain/cohere@workspace:*, @langchain/cohere@workspace:libs/langchain-cohere": version: 0.0.0-use.local resolution: "@langchain/cohere@workspace:libs/langchain-cohere" dependencies: @@ -11610,7 +11598,7 @@ __metadata: languageName: unknown linkType: soft -"@langchain/google-genai@workspace:*, @langchain/google-genai@workspace:libs/langchain-google-genai": +"@langchain/google-genai@^0.0.23, @langchain/google-genai@workspace:*, @langchain/google-genai@workspace:libs/langchain-google-genai": version: 0.0.0-use.local resolution: "@langchain/google-genai@workspace:libs/langchain-google-genai" dependencies: @@ -11677,7 +11665,7 @@ __metadata: languageName: unknown linkType: soft -"@langchain/google-vertexai@workspace:*, @langchain/google-vertexai@workspace:libs/langchain-google-vertexai": +"@langchain/google-vertexai@^0.0.20, @langchain/google-vertexai@workspace:*, @langchain/google-vertexai@workspace:libs/langchain-google-vertexai": version: 0.0.0-use.local resolution: "@langchain/google-vertexai@workspace:libs/langchain-google-vertexai" dependencies: @@ -11742,7 +11730,7 @@ __metadata: languageName: unknown linkType: soft -"@langchain/groq@workspace:*, @langchain/groq@workspace:libs/langchain-groq": +"@langchain/groq@^0.0.15, @langchain/groq@workspace:*, @langchain/groq@workspace:libs/langchain-groq": version: 0.0.0-use.local resolution: "@langchain/groq@workspace:libs/langchain-groq" dependencies: @@ -11768,7 +11756,6 @@ __metadata: groq-sdk: ^0.3.2 jest: ^29.5.0 jest-environment-node: ^29.6.4 - langchain: "workspace:*" prettier: ^2.8.3 release-it: ^15.10.1 rollup: ^4.5.2 @@ -11811,7 +11798,7 @@ __metadata: languageName: node linkType: hard -"@langchain/mistralai@workspace:*, @langchain/mistralai@workspace:libs/langchain-mistralai": +"@langchain/mistralai@^0.0.26, @langchain/mistralai@workspace:*, @langchain/mistralai@workspace:libs/langchain-mistralai": version: 0.0.0-use.local resolution: "@langchain/mistralai@workspace:libs/langchain-mistralai" dependencies: @@ -11835,7 +11822,6 @@ __metadata: eslint-plugin-prettier: ^4.2.1 jest: ^29.5.0 jest-environment-node: ^29.6.4 - langchain: "workspace:*" prettier: ^2.8.3 release-it: ^15.10.1 rollup: ^4.5.2 @@ -11947,7 +11933,7 @@ __metadata: languageName: unknown linkType: soft -"@langchain/ollama@workspace:*, @langchain/ollama@workspace:libs/langchain-ollama": +"@langchain/ollama@^0.0.2, @langchain/ollama@workspace:*, @langchain/ollama@workspace:libs/langchain-ollama": version: 0.0.0-use.local resolution: "@langchain/ollama@workspace:libs/langchain-ollama" dependencies: @@ -22088,19 +22074,6 @@ __metadata: languageName: node linkType: hard -"cohere-ai@npm:^7.9.3": - version: 7.9.3 - resolution: "cohere-ai@npm:7.9.3" - dependencies: - form-data: 4.0.0 - js-base64: 3.7.2 - node-fetch: 2.7.0 - qs: 6.11.2 - url-join: 4.0.1 - checksum: 89c7356680a484fe46b8999b05e97d5329efa96105d0f9658cdc84147ea278a53320db9b6db5af31a231ae980161b1c3341bba4f07b69e152d3a6b776e6179a9 - languageName: node - linkType: hard - "collapse-white-space@npm:^1.0.2": version: 1.0.6 resolution: "collapse-white-space@npm:1.0.6" @@ -31017,8 +30990,15 @@ __metadata: "@gomomento/sdk": ^1.51.1 "@gomomento/sdk-core": ^1.51.1 "@jest/globals": ^29.5.0 - "@langchain/cohere": ^0.0.8 + "@langchain/anthropic": ^0.2.8 + "@langchain/aws": ^0.0.5 + "@langchain/cohere": ^0.2.1 "@langchain/core": ">=0.2.11 <0.3.0" + "@langchain/google-genai": ^0.0.23 + "@langchain/google-vertexai": ^0.0.20 + "@langchain/groq": ^0.0.15 + "@langchain/mistralai": ^0.0.26 + "@langchain/ollama": ^0.0.2 "@langchain/openai": ">=0.1.0 <0.3.0" "@langchain/scripts": ~0.0.20 "@langchain/textsplitters": ~0.0.0 @@ -31117,6 +31097,15 @@ __metadata: "@gomomento/sdk": ^1.51.1 "@gomomento/sdk-core": ^1.51.1 "@gomomento/sdk-web": ^1.51.1 + "@langchain/anthropic": "*" + "@langchain/aws": "*" + "@langchain/cohere": "*" + "@langchain/community": "*" + "@langchain/google-genai": "*" + "@langchain/google-vertexai": "*" + "@langchain/groq": "*" + "@langchain/mistralai": "*" + "@langchain/ollama": "*" "@mendable/firecrawl-js": ^0.0.13 "@notionhq/client": ^2.2.10 "@pinecone-database/pinecone": "*" @@ -31176,6 +31165,26 @@ __metadata: optional: true "@gomomento/sdk-web": optional: true + "@langchain/anthropic": + optional: true + "@langchain/aws": + optional: true + "@langchain/cohere": + optional: true + "@langchain/community": + optional: true + "@langchain/google-genai": + optional: true + "@langchain/google-vertexai": + optional: true + "@langchain/google-vertexai-web": + optional: true + "@langchain/groq": + optional: true + "@langchain/mistralai": + optional: true + "@langchain/ollama": + optional: true "@mendable/firecrawl-js": optional: true "@notionhq/client": From 97c9e5ef5c853857c3a80bf40784f17435083b36 Mon Sep 17 00:00:00 2001 From: Brace Sproul Date: Wed, 24 Jul 2024 15:54:05 -0700 Subject: [PATCH 10/11] docs[patch]: Update root readme to include node v22 in supported versions (#6200) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 28e3f52205dd..bcf98e556a10 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ You can use npm, yarn, or pnpm to install LangChain.js LangChain is written in TypeScript and can be used in: -- Node.js (ESM and CommonJS) - 18.x, 19.x, 20.x +- Node.js (ESM and CommonJS) - 18.x, 19.x, 20.x, 22.x - Cloudflare Workers - Vercel / Next.js (Browser, Serverless and Edge functions) - Supabase Edge Functions From e8a94584919e38dc249dbc982ac56e127ff28265 Mon Sep 17 00:00:00 2001 From: Brace Sproul Date: Wed, 24 Jul 2024 16:04:23 -0700 Subject: [PATCH 11/11] Release 0.2.11 (#6201) --- langchain/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain/package.json b/langchain/package.json index d14c94caabfe..ebb77df1520e 100644 --- a/langchain/package.json +++ b/langchain/package.json @@ -1,6 +1,6 @@ { "name": "langchain", - "version": "0.2.10", + "version": "0.2.11", "description": "Typescript bindings for langchain", "type": "module", "engines": {