Query system using multiple AI agents for text-to-SQL and text-to-Python
Abstract
Systems and methods are provided for enabling search and query functions. A query system having a framework, executed on one or more processors, includes a plurality of Artificial Intelligence (AI) agents working to support one of text-to-Structured Query Language (SQL) or text-to-Python, wherein the plurality of AI agents include a first AI agent prompted to act as a research analyst for performing a task of interpreting a natural language query from a user, wherein the natural language query relates to natural language to the one of text-to-SQL or text-to-Python; a second AI agent prompted to act as a search data engineer for performing a task of executing a search based on the natural language query; and a third AI agent prompted to act as a code developer for performing a task of writing code based on the search, wherein the plurality of AI agents act autonomously yet collaboratively.
Interactive Citation Constellation Global Citation Ranking
Interactive SVG Citation Constellation renders in Rust/WebAssembly. Prior art cited: 13 · Forward citations: 1.
Claims (8)
- Claim 1Independent Claim
A query system having a framework, the query system comprising: a plurality of Artificial Intelligence (AI) agents working to support one of text-to-Structured Query Language (SQL) or text-to-Python, wherein the plurality of AI agents are each executable on one or more processing devices, and wherein the plurality of AI agents include a first AI agent prompted to act as a research analyst for performing a task of interpreting a natural language query from a user, wherein the natural language query relates to natural language to the one of text-to-SQL or text-to-Python, wherein the first AI agent performs retrieval-augmented generation (RAG) to extract semantic information comprising column descriptions, table schemas, sample values, and data types necessary to accurately interpret the natural language query; a second AI agent prompted to act as a search data engineer for performing a task of executing a search based on the natural language query, wherein the second AI agent executes a
- Claim 2Depends on #1
The query system of claim 1, further comprising a fourth AI agent prompted to act as a manager to a) manage interactions among the plurality of AI agents, b) determine which the plurality of AI agents perform their respective tasks, and c) broadcast results obtained by one AI agent upon performing its respective task to other AI agents.
- Claim 3Depends on #1
The query system of claim 1, further comprising a fourth AI agent prompted to act as a search evaluator for performing a task of evaluating whether data obtained by the second AI agent prompted to act as the search data engineer when executing the search is relevant.
- Claim 4Depends on #3
The query system of claim 3, wherein, in response to determining that results of executing the search are not relevant, the fourth AI agent prompted to act as the search evaluator is configured to provide feedback to the second AI agent prompted to act as the search data engineer.
- Claim 5Depends on #1
The query system of claim 1, wherein the third AI agent prompted to act as the code developer is a text-to-SQL developer and is configured to write SQL code for assisting the second AI agent prompted to act as the search data engineer with queries related to general data and customer health.
- Claim 6Depends on #1
The query system of claim 1, wherein the third AI agent prompted to act as the code developer is a text-to-visualization developer and is configured to write Python code for assisting the second AI agent prompted to act as the search data engineer with queries related to visualization of data.
- Claim 7Depends on #1
The query system of claim 1, further comprising a fourth AI agent prompted to act as a code evaluator for performing a task of evaluating the code written by the third AI agent prompted to act as code developer.
- Claim 8Depends on #1
The query system of claim 1, wherein the fourth AI agent prompted to act as the code evaluator is further configured to provide feedback to the third AI agent prompted to act as the code developer for improving SQL queries and Python queries that do not meet validation criteria.
Technical Overview & Description
TECHNICAL FIELD The present disclosure generally relates to data analysis, Business Intelligence (BI), and query/search systems. More particularly, the present disclosure relates to systems and methods for converting natural language queries to Structured Query Language (SQL) queries and Python queries using a multi-agent framework and Large Language Models (LLMs). BACKGROUND In the realm of data analysis, the user task of querying databases typically requires knowledge of SQL, which can be a barrier for non-technical users. Existing solutions, such as Business Intelligence (BI) tools and pre-built dashboards, offer limited permutations for data exploration and require significant manual setup and maintenance. Single Large Language Model (LLM) approaches and chain-based LLM methods often lack mechanisms to ensure the correctness of generated SQL queries, leading to potential inaccuracies in query results. BRIEF SUMMARY The present disclosure is directed to systems and methods for establishing query systems for receiving user queries and replying with appropriate answers. According to one implementation, a query system may have a framework with a plurality of AI agents. For example, the query system may include one AI agent prompted to act as the research analyst for performing a task of interpreting a natural language query from a user. Another AI agent may be prompted to act as the search data engineer for performing a task of executing a search based on the natural language query. Also, another AI agent may be prompted to act as the chat manager for performing a task of enabling the plurality of AI agents to act autonomously yet collaboratively in a group chat environment. A further AI agent as a project manager for planning, such as to decompose tasks into sub-tasks and assign to other AI agents. In some embodiments, the chat manager may be further configured to a) manage interactions among the AI agents, b) determine which the AI agents perform their respective
Cited By — Indexed Forward Citations (1 of 1 total)
| Patent | Title | Year | Citations |
|---|---|---|---|
| US 12,754,821 B1 | Dual-capacity machine learning based validation framework | 2026 | 0 |
References Cited — Backward Prior Art (13)
Non-Patent Literature (3)
- Wang, MAC-SQL: A Multi-Agent Collaborative Framework for Text-to-SQL, pp. 1-18, Jun. 17, 2024.
- Qian, ChatDev: Communicative Agents for Software Development, pp. 1-13, Jun. 5, 2024.
- Dibia, LIDA: A Tool for Automatic Generation of Grammar-Agnostic Visualizations and Infographics using Large Language Models, pp. 1-14, Jun. 6, 2023.