diff --git a/package.json b/package.json index 2e112d3..ec51bf0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ai-agent-enterprise", "description": "AI Agent simplifies the implementation and use of generative AI with LangChain", - "version": "0.0.29", + "version": "0.0.30", "main": "./build/index.js", "types": "./build/index.d.ts", "files": [ diff --git a/src/services/chain/sql-database-chain.ts b/src/services/chain/sql-database-chain.ts index 44ba03a..d9fe48e 100644 --- a/src/services/chain/sql-database-chain.ts +++ b/src/services/chain/sql-database-chain.ts @@ -8,8 +8,6 @@ import { ChainValues } from "langchain/schema"; import { CallbackManagerForChainRun } from "langchain/callbacks"; import { PromptTemplate } from "langchain/prompts"; -const CONTEXTUAL_ERROR = 'There is no specific information in the provided SQL table schema'; - /** * Class that represents a SQL database chain in the LangChain framework. * It extends the BaseChain class and implements the functionality @@ -110,9 +108,13 @@ export default class SqlDatabaseChain extends BaseChain { question: (input) => input.question, query: (input) => input.query, response: (input) => { - if (input.query.content.includes(CONTEXTUAL_ERROR)) return null; + const sql = input.query.content.toLowerCase(); + + if (sql.includes('select') && sql.includes('from')) { + return this.database.run(input.query); + } - return this.database.run(input.query) + return null; }, }, {