diff --git a/docs/docs/modules/agents/toolkits/sql.mdx b/docs/docs/modules/agents/toolkits/sql.mdx index 4113ab066475..49d1d19b483a 100644 --- a/docs/docs/modules/agents/toolkits/sql.mdx +++ b/docs/docs/modules/agents/toolkits/sql.mdx @@ -6,6 +6,16 @@ hide_table_of_contents: true This example shows how to load and use an agent with a SQL toolkit. +## Setup + +You'll need to first install `typeorm`: + +```bash npm2yarn +npm install typeorm +``` + +## Usage + import CodeBlock from "@theme/CodeBlock"; import Example from "@examples/agents/sql.ts"; diff --git a/docs/docs/modules/agents/tools/integrations/index.mdx b/docs/docs/modules/agents/tools/integrations/index.mdx index 46d1eab241a0..f38fbd2e06b1 100644 --- a/docs/docs/modules/agents/tools/integrations/index.mdx +++ b/docs/docs/modules/agents/tools/integrations/index.mdx @@ -19,7 +19,7 @@ LangChain provides the following tools you can use out of the box: - [`JsonListKeysTool`][JsonListKeysTool] and [`JsonGetValueTool`][JsonGetValueTool] - Useful for extracting data from JSON objects. These tools can be used collectively in a [`JsonToolkit`][JsonToolkit]. - [`RequestsGetTool`][RequestsGetTool] and [`RequestsPostTool`][RequestsPostTool] - Useful for making HTTP requests. - [`SerpAPI`][SerpAPI] - A wrapper around the SerpAPI API. Useful for when you need to answer questions about current events. Input should be a search query. -- [`QuerySqlTool`][QuerySqlTool], [`InfoSqlTool`][InfoSqlTool], [`ListTablesSqlTool`][ListTablesSqlTool], and [`QueryCheckerTool`][QueryCheckerTool] - Useful for interacting with SQL databases. Can be used together in a [`SqlToolkit`][SqlToolkit]. +- [`QuerySqlTool`][QuerySqlTool], [`InfoSqlTool`][InfoSqlTool], [`ListTablesSqlTool`][ListTablesSqlTool], and [`QueryCheckerTool`][QueryCheckerTool] - Useful for interacting with SQL databases. Can be used together in a [`SqlToolkit`][SqlToolkit]. Requires `typeorm` as a peer dependency. - [`VectorStoreQATool`][VectorStoreQATool] - Useful for retrieving relevant text data from a vector store. - [`ZapierNLARunAction`][ZapierNLARunAction] - A wrapper around the Zapier NLP API. Useful for triggering Zapier actions with a natural language input. Best when used in a [`ZapierToolkit`][ZapierToolkit]. @@ -35,10 +35,10 @@ LangChain provides the following tools you can use out of the box: [RequestsGetTool]: /docs/api/tools/classes/RequestsGetTool [RequestsPostTool]: /docs/api/tools/classes/RequestsPostTool [SerpAPI]: /docs/api/tools/classes/SerpAPI -[QuerySqlTool]: /docs/api/tools/classes/QuerySqlTool -[InfoSqlTool]: /docs/api/tools/classes/InfoSqlTool -[ListTablesSqlTool]: /docs/api/tools/classes/ListTablesSqlTool -[QueryCheckerTool]: /docs/api/tools/classes/QueryCheckerTool +[QuerySqlTool]: /docs/api/tools_sql/classes/QuerySqlTool +[InfoSqlTool]: /docs/api/tools_sql/classes/InfoSqlTool +[ListTablesSqlTool]: /docs/api/tools_sql/classes/ListTablesSqlTool +[QueryCheckerTool]: /docs/api/tools_sql/classes/QueryCheckerTool [SqlToolkit]: ../../toolkits/sql [VectorStoreQATool]: /docs/api/tools/classes/VectorStoreQATool [ZapierNLARunAction]: /docs/api/tools/classes/ZapierNLARunAction diff --git a/examples/src/agents/aws_sfn.ts b/examples/src/agents/aws_sfn.ts index 70c81bb81760..640fefd08081 100644 --- a/examples/src/agents/aws_sfn.ts +++ b/examples/src/agents/aws_sfn.ts @@ -2,7 +2,7 @@ import { OpenAI } from "langchain/llms/openai"; import { createAWSSfnAgent, AWSSfnToolkit, -} from "langchain/agents/agent_toolkits/aws_sfn"; +} from "langchain/agents/toolkits/aws_sfn"; const _EXAMPLE_STATE_MACHINE_ASL = ` { diff --git a/examples/src/agents/sql.ts b/examples/src/agents/sql.ts index ea989d817767..da6b3ea058d9 100644 --- a/examples/src/agents/sql.ts +++ b/examples/src/agents/sql.ts @@ -1,6 +1,6 @@ import { OpenAI } from "langchain/llms/openai"; import { SqlDatabase } from "langchain/sql_db"; -import { createSqlAgent, SqlToolkit } from "langchain/agents"; +import { createSqlAgent, SqlToolkit } from "langchain/agents/toolkits/sql"; import { DataSource } from "typeorm"; /** This example uses Chinook database, which is a sample database available for SQL Server, Oracle, MySQL, etc. diff --git a/examples/src/chains/sql_db.ts b/examples/src/chains/sql_db.ts index 4c66c6d341c4..00f8608e88fd 100644 --- a/examples/src/chains/sql_db.ts +++ b/examples/src/chains/sql_db.ts @@ -1,7 +1,7 @@ import { DataSource } from "typeorm"; import { OpenAI } from "langchain/llms/openai"; import { SqlDatabase } from "langchain/sql_db"; -import { SqlDatabaseChain } from "langchain/chains"; +import { SqlDatabaseChain } from "langchain/chains/sql_db"; /** * This example uses Chinook database, which is a sample database available for SQL Server, Oracle, MySQL, etc. diff --git a/examples/src/chains/sql_db_sql_output.ts b/examples/src/chains/sql_db_sql_output.ts index 6db38ef88c7c..a3a6e40a6ef4 100644 --- a/examples/src/chains/sql_db_sql_output.ts +++ b/examples/src/chains/sql_db_sql_output.ts @@ -1,7 +1,7 @@ import { DataSource } from "typeorm"; import { OpenAI } from "langchain/llms/openai"; import { SqlDatabase } from "langchain/sql_db"; -import { SqlDatabaseChain } from "langchain/chains"; +import { SqlDatabaseChain } from "langchain/chains/sql_db"; /** * This example uses Chinook database, which is a sample database available for SQL Server, Oracle, MySQL, etc. diff --git a/langchain/.gitignore b/langchain/.gitignore index 34cb080f1760..b489495e827f 100644 --- a/langchain/.gitignore +++ b/langchain/.gitignore @@ -10,9 +10,12 @@ agents.d.ts agents/load.cjs agents/load.js agents/load.d.ts -agents/agent_toolkits/aws_sfn.cjs -agents/agent_toolkits/aws_sfn.js -agents/agent_toolkits/aws_sfn.d.ts +agents/toolkits/aws_sfn.cjs +agents/toolkits/aws_sfn.js +agents/toolkits/aws_sfn.d.ts +agents/toolkits/sql.cjs +agents/toolkits/sql.js +agents/toolkits/sql.d.ts base_language.cjs base_language.js base_language.d.ts @@ -28,6 +31,9 @@ tools/aws_sfn.d.ts tools/calculator.cjs tools/calculator.js tools/calculator.d.ts +tools/sql.cjs +tools/sql.js +tools/sql.d.ts tools/webbrowser.cjs tools/webbrowser.js tools/webbrowser.d.ts @@ -43,6 +49,9 @@ chains/query_constructor.d.ts chains/query_constructor/ir.cjs chains/query_constructor/ir.js chains/query_constructor/ir.d.ts +chains/sql_db.cjs +chains/sql_db.js +chains/sql_db.d.ts embeddings.cjs embeddings.js embeddings.d.ts diff --git a/langchain/package.json b/langchain/package.json index 48b597478ea2..cac45033b760 100644 --- a/langchain/package.json +++ b/langchain/package.json @@ -22,9 +22,12 @@ "agents/load.cjs", "agents/load.js", "agents/load.d.ts", - "agents/agent_toolkits/aws_sfn.cjs", - "agents/agent_toolkits/aws_sfn.js", - "agents/agent_toolkits/aws_sfn.d.ts", + "agents/toolkits/aws_sfn.cjs", + "agents/toolkits/aws_sfn.js", + "agents/toolkits/aws_sfn.d.ts", + "agents/toolkits/sql.cjs", + "agents/toolkits/sql.js", + "agents/toolkits/sql.d.ts", "base_language.cjs", "base_language.js", "base_language.d.ts", @@ -40,6 +43,9 @@ "tools/calculator.cjs", "tools/calculator.js", "tools/calculator.d.ts", + "tools/sql.cjs", + "tools/sql.js", + "tools/sql.d.ts", "tools/webbrowser.cjs", "tools/webbrowser.js", "tools/webbrowser.d.ts", @@ -55,6 +61,9 @@ "chains/query_constructor/ir.cjs", "chains/query_constructor/ir.js", "chains/query_constructor/ir.d.ts", + "chains/sql_db.cjs", + "chains/sql_db.js", + "chains/sql_db.d.ts", "embeddings.cjs", "embeddings.js", "embeddings.d.ts", @@ -827,10 +836,15 @@ "import": "./agents/load.js", "require": "./agents/load.cjs" }, - "./agents/agent_toolkits/aws_sfn": { - "types": "./agents/agent_toolkits/aws_sfn.d.ts", - "import": "./agents/agent_toolkits/aws_sfn.js", - "require": "./agents/agent_toolkits/aws_sfn.cjs" + "./agents/toolkits/aws_sfn": { + "types": "./agents/toolkits/aws_sfn.d.ts", + "import": "./agents/toolkits/aws_sfn.js", + "require": "./agents/toolkits/aws_sfn.cjs" + }, + "./agents/toolkits/sql": { + "types": "./agents/toolkits/sql.d.ts", + "import": "./agents/toolkits/sql.js", + "require": "./agents/toolkits/sql.cjs" }, "./base_language": { "types": "./base_language.d.ts", @@ -857,6 +871,11 @@ "import": "./tools/calculator.js", "require": "./tools/calculator.cjs" }, + "./tools/sql": { + "types": "./tools/sql.d.ts", + "import": "./tools/sql.js", + "require": "./tools/sql.cjs" + }, "./tools/webbrowser": { "types": "./tools/webbrowser.d.ts", "import": "./tools/webbrowser.js", @@ -882,6 +901,11 @@ "import": "./chains/query_constructor/ir.js", "require": "./chains/query_constructor/ir.cjs" }, + "./chains/sql_db": { + "types": "./chains/sql_db.d.ts", + "import": "./chains/sql_db.js", + "require": "./chains/sql_db.cjs" + }, "./embeddings": { "node": { "types": "./embeddings.d.ts", diff --git a/langchain/scripts/create-entrypoints.js b/langchain/scripts/create-entrypoints.js index fe25cf8c29f5..c40d7c590a00 100644 --- a/langchain/scripts/create-entrypoints.js +++ b/langchain/scripts/create-entrypoints.js @@ -13,7 +13,8 @@ const entrypoints = { // agents agents: "agents/index", "agents/load": "agents/load", - "agents/agent_toolkits/aws_sfn": "agents/agent_toolkits/aws_sfn", + "agents/toolkits/aws_sfn": "agents/toolkits/aws_sfn", + "agents/toolkits/sql": "agents/toolkits/sql/index", // base language base_language: "base_language/index", // tools @@ -21,12 +22,14 @@ const entrypoints = { "tools/aws_lambda": "tools/aws_lambda", "tools/aws_sfn": "tools/aws_sfn", "tools/calculator": "tools/calculator", + "tools/sql": "tools/sql", "tools/webbrowser": "tools/webbrowser", // chains chains: "chains/index", "chains/load": "chains/load", "chains/query_constructor": "chains/query_constructor/index", "chains/query_constructor/ir": "chains/query_constructor/ir", + "chains/sql_db": "chains/sql_db/index", // embeddings embeddings: "embeddings/index", "embeddings/base": "embeddings/base", @@ -190,12 +193,15 @@ const deprecatedNodeOnly = [ // Therefore they are not tested in the generated test-exports-* packages. const requiresOptionalDependency = [ "agents/load", - "agents/agent_toolkits/aws_sfn", + "agents/toolkits/aws_sfn", + "agents/toolkits/sql", "tools/aws_lambda", "tools/aws_sfn", "tools/calculator", + "tools/sql", "tools/webbrowser", "chains/load", + "chains/sql_db", "embeddings/cohere", "embeddings/googlevertexai", "embeddings/tensorflow", diff --git a/langchain/src/agents/index.ts b/langchain/src/agents/index.ts index 9a8794facf59..e3d1896a6fd0 100644 --- a/langchain/src/agents/index.ts +++ b/langchain/src/agents/index.ts @@ -10,19 +10,16 @@ export { JsonToolkit, OpenApiToolkit, RequestsToolkit, - SqlToolkit, VectorStoreInfo, VectorStoreRouterToolkit, VectorStoreToolkit, ZapierToolKit, createJsonAgent, createOpenApiAgent, - createSqlAgent, - SqlCreatePromptArgs, createVectorStoreAgent, createVectorStoreRouterAgent, -} from "./agent_toolkits/index.js"; -export { Toolkit } from "./agent_toolkits/base.js"; +} from "./toolkits/index.js"; +export { Toolkit } from "./toolkits/base.js"; export { ChatAgent, ChatAgentInput, diff --git a/langchain/src/agents/tests/aws_sfn.int.test.ts b/langchain/src/agents/tests/aws_sfn.int.test.ts index f23a30102673..625ad10b209a 100644 --- a/langchain/src/agents/tests/aws_sfn.int.test.ts +++ b/langchain/src/agents/tests/aws_sfn.int.test.ts @@ -5,7 +5,7 @@ import { test } from "@jest/globals"; import { StartExecutionAWSSfnTool } from "../../tools/aws_sfn.js"; import { OpenAI } from "../../llms/openai.js"; -import { AWSSfnToolkit, createAWSSfnAgent } from "../agent_toolkits/aws_sfn.js"; +import { AWSSfnToolkit, createAWSSfnAgent } from "../toolkits/aws_sfn.js"; test.skip("StartExecutionAWSSfnTool invokes the correct state machine and returns the executionArn", async () => { const sfn = new StartExecutionAWSSfnTool({ diff --git a/langchain/src/agents/tests/zapier_toolkit.int.test.ts b/langchain/src/agents/tests/zapier_toolkit.int.test.ts index 720d68e2f3bb..f914529ac736 100644 --- a/langchain/src/agents/tests/zapier_toolkit.int.test.ts +++ b/langchain/src/agents/tests/zapier_toolkit.int.test.ts @@ -1,5 +1,5 @@ import { beforeEach, describe, expect, test } from "@jest/globals"; -import { ZapierToolKit } from "../agent_toolkits/zapier/zapier.js"; +import { ZapierToolKit } from "../toolkits/zapier/zapier.js"; import { ZapierNLAWrapper, ZapierValues } from "../../tools/zapier.js"; describe("ZapierNLAWrapper", () => { diff --git a/langchain/src/agents/agent_toolkits/aws_sfn.ts b/langchain/src/agents/toolkits/aws_sfn.ts similarity index 100% rename from langchain/src/agents/agent_toolkits/aws_sfn.ts rename to langchain/src/agents/toolkits/aws_sfn.ts diff --git a/langchain/src/agents/agent_toolkits/base.ts b/langchain/src/agents/toolkits/base.ts similarity index 100% rename from langchain/src/agents/agent_toolkits/base.ts rename to langchain/src/agents/toolkits/base.ts diff --git a/langchain/src/agents/agent_toolkits/index.ts b/langchain/src/agents/toolkits/index.ts similarity index 82% rename from langchain/src/agents/agent_toolkits/index.ts rename to langchain/src/agents/toolkits/index.ts index 3f119c0efec5..f9ed86db63b7 100644 --- a/langchain/src/agents/agent_toolkits/index.ts +++ b/langchain/src/agents/toolkits/index.ts @@ -1,5 +1,4 @@ export { JsonToolkit, createJsonAgent } from "./json/json.js"; -export { SqlToolkit, createSqlAgent, SqlCreatePromptArgs } from "./sql/sql.js"; export { RequestsToolkit, OpenApiToolkit, diff --git a/langchain/src/agents/agent_toolkits/json/json.ts b/langchain/src/agents/toolkits/json/json.ts similarity index 100% rename from langchain/src/agents/agent_toolkits/json/json.ts rename to langchain/src/agents/toolkits/json/json.ts diff --git a/langchain/src/agents/agent_toolkits/json/prompt.ts b/langchain/src/agents/toolkits/json/prompt.ts similarity index 100% rename from langchain/src/agents/agent_toolkits/json/prompt.ts rename to langchain/src/agents/toolkits/json/prompt.ts diff --git a/langchain/src/agents/agent_toolkits/openapi/openapi.ts b/langchain/src/agents/toolkits/openapi/openapi.ts similarity index 100% rename from langchain/src/agents/agent_toolkits/openapi/openapi.ts rename to langchain/src/agents/toolkits/openapi/openapi.ts diff --git a/langchain/src/agents/agent_toolkits/openapi/prompt.ts b/langchain/src/agents/toolkits/openapi/prompt.ts similarity index 100% rename from langchain/src/agents/agent_toolkits/openapi/prompt.ts rename to langchain/src/agents/toolkits/openapi/prompt.ts diff --git a/langchain/src/agents/toolkits/sql/index.ts b/langchain/src/agents/toolkits/sql/index.ts new file mode 100644 index 000000000000..2188cddbd606 --- /dev/null +++ b/langchain/src/agents/toolkits/sql/index.ts @@ -0,0 +1 @@ +export { SqlCreatePromptArgs, SqlToolkit, createSqlAgent } from "./sql.js"; diff --git a/langchain/src/agents/agent_toolkits/sql/prompt.ts b/langchain/src/agents/toolkits/sql/prompt.ts similarity index 100% rename from langchain/src/agents/agent_toolkits/sql/prompt.ts rename to langchain/src/agents/toolkits/sql/prompt.ts diff --git a/langchain/src/agents/agent_toolkits/sql/sql.ts b/langchain/src/agents/toolkits/sql/sql.ts similarity index 100% rename from langchain/src/agents/agent_toolkits/sql/sql.ts rename to langchain/src/agents/toolkits/sql/sql.ts diff --git a/langchain/src/agents/agent_toolkits/vectorstore/prompt.ts b/langchain/src/agents/toolkits/vectorstore/prompt.ts similarity index 100% rename from langchain/src/agents/agent_toolkits/vectorstore/prompt.ts rename to langchain/src/agents/toolkits/vectorstore/prompt.ts diff --git a/langchain/src/agents/agent_toolkits/vectorstore/vectorstore.ts b/langchain/src/agents/toolkits/vectorstore/vectorstore.ts similarity index 100% rename from langchain/src/agents/agent_toolkits/vectorstore/vectorstore.ts rename to langchain/src/agents/toolkits/vectorstore/vectorstore.ts diff --git a/langchain/src/agents/agent_toolkits/zapier/zapier.ts b/langchain/src/agents/toolkits/zapier/zapier.ts similarity index 100% rename from langchain/src/agents/agent_toolkits/zapier/zapier.ts rename to langchain/src/agents/toolkits/zapier/zapier.ts diff --git a/langchain/src/chains/constitutional_ai/constitutional_principle.ts b/langchain/src/chains/constitutional_ai/constitutional_principle.ts index 72904eba49e8..6943c5c3af3c 100644 --- a/langchain/src/chains/constitutional_ai/constitutional_principle.ts +++ b/langchain/src/chains/constitutional_ai/constitutional_principle.ts @@ -1,4 +1,4 @@ -import { SerializedConstitutionalPrinciple } from "../../chains/serde.js"; +import { SerializedConstitutionalPrinciple } from "../serde.js"; export class ConstitutionalPrinciple { critiqueRequest: string; diff --git a/langchain/src/chains/index.ts b/langchain/src/chains/index.ts index 25eb66b92451..7aecbc331edb 100644 --- a/langchain/src/chains/index.ts +++ b/langchain/src/chains/index.ts @@ -39,17 +39,6 @@ export { loadSummarizationChain, SummarizationChainParams, } from "./summarization/load.js"; -export { - SqlDatabaseChain, - SqlDatabaseChainInput, -} from "./sql_db/sql_db_chain.js"; -export { - DEFAULT_SQL_DATABASE_PROMPT, - SQL_POSTGRES_PROMPT, - SQL_SQLITE_PROMPT, - SQL_MSSQL_PROMPT, - SQL_MYSQL_PROMPT, -} from "./sql_db/sql_db_prompt.js"; export { ConversationalRetrievalQAChain, ConversationalRetrievalQAChainInput, @@ -67,7 +56,6 @@ export { SerializedLLMChain, SerializedSequentialChain, SerializedSimpleSequentialChain, - SerializedSqlDatabaseChain, SerializedAnalyzeDocumentChain, SerializedAPIChain, SerializedBaseChain, diff --git a/langchain/src/chains/serde.ts b/langchain/src/chains/serde.ts index 7c07d6395693..a83a51c6fc48 100644 --- a/langchain/src/chains/serde.ts +++ b/langchain/src/chains/serde.ts @@ -1,6 +1,5 @@ import type { SerializedLLM } from "../llms/base.js"; import type { SerializedBasePromptTemplate } from "../prompts/serde.js"; -import type { SerializedSqlDatabase } from "../util/sql_utils.js"; export type SerializedLLMChain = { _type: "llm_chain"; @@ -20,12 +19,6 @@ export type SerializedSimpleSequentialChain = { chains: Array; }; -export type SerializedSqlDatabaseChain = { - _type: "sql_database_chain"; - sql_database: SerializedSqlDatabase; - llm: SerializedLLM; -}; - export type SerializedVectorDBQAChain = { _type: "vector_db_qa"; k: number; @@ -90,7 +83,6 @@ export type SerializedBaseChain = | SerializedVectorDBQAChain | SerializedAPIChain | SerializedStuffDocumentsChain - | SerializedSqlDatabaseChain | SerializedChatVectorDBQAChain | SerializedMapReduceDocumentsChain | SerializedAnalyzeDocumentChain diff --git a/langchain/src/chains/sql_db/index.ts b/langchain/src/chains/sql_db/index.ts new file mode 100644 index 000000000000..c8a12163ac44 --- /dev/null +++ b/langchain/src/chains/sql_db/index.ts @@ -0,0 +1,8 @@ +export { SqlDatabaseChain, SqlDatabaseChainInput } from "./sql_db_chain.js"; +export { + DEFAULT_SQL_DATABASE_PROMPT, + SQL_POSTGRES_PROMPT, + SQL_SQLITE_PROMPT, + SQL_MSSQL_PROMPT, + SQL_MYSQL_PROMPT, +} from "./sql_db_prompt.js"; diff --git a/langchain/src/chains/sql_db/sql_db_chain.ts b/langchain/src/chains/sql_db/sql_db_chain.ts index a20064d1b8db..b1fafb3fe986 100644 --- a/langchain/src/chains/sql_db/sql_db_chain.ts +++ b/langchain/src/chains/sql_db/sql_db_chain.ts @@ -5,7 +5,6 @@ import type { OpenAI } from "../../llms/openai.js"; import { LLMChain } from "../llm_chain.js"; import type { SqlDatabase } from "../../sql_db.js"; import { ChainValues } from "../../schema/index.js"; -import { SerializedSqlDatabaseChain } from "../serde.js"; import { BaseLanguageModel } from "../../base_language/index.js"; import { calculateMaxTokens, @@ -137,27 +136,6 @@ export class SqlDatabaseChain extends BaseChain { return [this.outputKey]; } - static async deserialize( - data: SerializedSqlDatabaseChain, - SqlDatabaseFromOptionsParams: (typeof SqlDatabase)["fromOptionsParams"] - ) { - const llm = await BaseLanguageModel.deserialize(data.llm); - const sqlDataBase = await SqlDatabaseFromOptionsParams(data.sql_database); - - return new SqlDatabaseChain({ - llm, - database: sqlDataBase, - }); - } - - serialize(): SerializedSqlDatabaseChain { - return { - _type: this._chainType(), - llm: this.llm.serialize(), - sql_database: this.database.serialize(), - }; - } - private async verifyNumberOfTokens( inputText: string, tableinfo: string diff --git a/langchain/src/load/import_constants.ts b/langchain/src/load/import_constants.ts index fa980c32c6f8..476adfa3ad62 100644 --- a/langchain/src/load/import_constants.ts +++ b/langchain/src/load/import_constants.ts @@ -2,14 +2,17 @@ export const optionalImportEntrypoints = [ "langchain/agents/load", - "langchain/agents/agent_toolkits/aws_sfn", + "langchain/agents/toolkits/aws_sfn", + "langchain/agents/toolkits/sql", "langchain/tools/aws_lambda", "langchain/tools/aws_sfn", "langchain/tools/calculator", + "langchain/tools/sql", "langchain/tools/webbrowser", "langchain/chains/load", "langchain/chains/query_constructor", "langchain/chains/query_constructor/ir", + "langchain/chains/sql_db", "langchain/embeddings/cohere", "langchain/embeddings/tensorflow", "langchain/embeddings/hf", diff --git a/langchain/src/load/import_type.d.ts b/langchain/src/load/import_type.d.ts index 3be2fecacf1e..53e873c61c48 100644 --- a/langchain/src/load/import_type.d.ts +++ b/langchain/src/load/import_type.d.ts @@ -4,9 +4,12 @@ export interface OptionalImportMap { "langchain/agents/load"?: | typeof import("../agents/load.js") | Promise; - "langchain/agents/agent_toolkits/aws_sfn"?: - | typeof import("../agents/agent_toolkits/aws_sfn.js") - | Promise; + "langchain/agents/toolkits/aws_sfn"?: + | typeof import("../agents/toolkits/aws_sfn.js") + | Promise; + "langchain/agents/toolkits/sql"?: + | typeof import("../agents/toolkits/sql/index.js") + | Promise; "langchain/tools/aws_lambda"?: | typeof import("../tools/aws_lambda.js") | Promise; @@ -16,6 +19,9 @@ export interface OptionalImportMap { "langchain/tools/calculator"?: | typeof import("../tools/calculator.js") | Promise; + "langchain/tools/sql"?: + | typeof import("../tools/sql.js") + | Promise; "langchain/tools/webbrowser"?: | typeof import("../tools/webbrowser.js") | Promise; @@ -28,6 +34,9 @@ export interface OptionalImportMap { "langchain/chains/query_constructor/ir"?: | typeof import("../chains/query_constructor/ir.js") | Promise; + "langchain/chains/sql_db"?: + | typeof import("../chains/sql_db/index.js") + | Promise; "langchain/embeddings/cohere"?: | typeof import("../embeddings/cohere.js") | Promise; diff --git a/langchain/src/tools/index.ts b/langchain/src/tools/index.ts index 5eb8e338a821..e9d41fbe79eb 100644 --- a/langchain/src/tools/index.ts +++ b/langchain/src/tools/index.ts @@ -10,12 +10,6 @@ export { } from "./dynamic.js"; export { IFTTTWebhook } from "./IFTTTWebhook.js"; export { ChainTool, ChainToolInput } from "./chain.js"; -export { - QuerySqlTool, - InfoSqlTool, - ListTablesSqlTool, - QueryCheckerTool, -} from "./sql.js"; export { JsonSpec, JsonListKeysTool, diff --git a/langchain/tsconfig.json b/langchain/tsconfig.json index 70446ef06c9c..5d2464b8ae35 100644 --- a/langchain/tsconfig.json +++ b/langchain/tsconfig.json @@ -36,17 +36,20 @@ "src/load/serializable.ts", "src/agents/index.ts", "src/agents/load.ts", - "src/agents/agent_toolkits/aws_sfn.ts", + "src/agents/toolkits/aws_sfn.ts", + "src/agents/toolkits/sql/index.ts", "src/base_language/index.ts", "src/tools/index.ts", "src/tools/aws_lambda.ts", "src/tools/aws_sfn.ts", "src/tools/calculator.ts", + "src/tools/sql.ts", "src/tools/webbrowser.ts", "src/chains/index.ts", "src/chains/load.ts", "src/chains/query_constructor/index.ts", "src/chains/query_constructor/ir.ts", + "src/chains/sql_db/index.ts", "src/embeddings/base.ts", "src/embeddings/fake.ts", "src/embeddings/openai.ts",