----------------------
Yes, there are examples and resources available that can help you build an agent based on Text-to-SQL.
The LlamaIndex project provides a way to build a "text-to-SQL assistant" that can interact with a structured database. This assistant can handle complex queries that may require data from multiple tables. However, the specific example of handling date-related queries like "what are bugs raised in the last 1 month?" is not explicitly mentioned in the provided knowledge sources.
Here is an example of setting up a simple text-to-SQL tool using LlamaIndex:
from llama_index.core.query_engine import NLSQLTableQueryEngine
from llama_index.core.tools import QueryEngineTool
sql_query_engine = NLSQLTableQueryEngine(
sql_database=sql_database,
tables=["albums", "tracks", "artists"],
verbose=True,
)
sql_tool = QueryEngineTool.from_defaults(
query_engine=sql_query_engine,
name="sql_tool",
description=(
"Useful for translating a natural language query into a SQL query"
),
)
(Source:
Jerryjliu > Llama_index > Blob > Main > Docs > Docs > Examples > Agent > Agent_runner > Building an Agent around a Query Pipeline > Setup Text-to-SQL Query Engine / Tool ())
This example sets up a simple text-to-SQL tool that can translate a natural language query into a SQL query and execute it against a database. The tables parameter in the
NLSQLTableQueryEngine
can be a list of multiple tables.