Chat bot Text-to-SQL using Azure AI Services

João Conceição 0 Reputation points
2025-01-09T15:57:53.5266667+00:00

Hey, im currently working on a chat bot that based on a user question it generates a query to the database and then it processes the result of that query in natural language. Im currently using Azure OpenAI and Azure AI Search to index the data source that will be used. 1.Is this possible? 2.What structure should the file that will be used by AI Search have, so that it contains information about the tables, columns and the possible distinct values for each column and also prevent necessary information to be lost when chunking. Considerations: The tables have a "Total" column that represents the amount of "X" that are defined by the combination of all the other column values. The average row count for each table is 800 000.

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
1,141 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,276 questions
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,504 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Azar 25,225 Reputation points MVP
    2025-01-09T19:04:57.39+00:00

    Hi there oão Conceição

    Thanks for using QandA platform

    Yes, it’s possible to build a chatbot that generates SQL queries from natural language inputs and then processes the query results in natural language using Azure OpenAI and Azure AI Search. to do this, the file used by Azure AI Search should be structured to include metadata about your database schema. You could structure the data to include the table name and a list of columns along with their distinct values. For chunking, you index the schema metadata separately from the data rows to avoid losing critical information, especially for large tables. The "Total" column representing aggregated values can be included in the index as well to help with generating queries involving sums

    If this helps kindly accept the answer thanks much.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.