Connecting GPT4 with SQL data

Innoimagine 0 Reputation points
2023-12-18T09:36:34.7766667+00:00

Hello!

I want to create a model using OpenAI that can take queries from a user in plain english language and retrieve the data from an SQL database and answer it in plain language. Is there a way to achieve this? The model should be able to create SQL queries from the text, fire them and return the result back to the user. We are okay if we need to convert the database data into json or txt files. But the data is huge (millions of lines).

Azure SQL Database
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
4,080 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AshokPeddakotla-MSFT 35,971 Reputation points Moderator
    2023-12-18T11:23:03.8766667+00:00

    Innoimagine Greetings & Welcome to Microsoft Q&A forum!

    I want to create a model using OpenAI that can take queries from a user in plain english language and retrieve the data from an SQL database and answer it in plain language. Is there a way to achieve this?

    Did you check this Revolutionizing SQL Queries with Azure Open AI and Semantic Kernel already?

    User's image

    This architecture diagram shows how a user can interact with a SQL server using natural language and receive the output as speech. It uses Azure Speech Services and an NLP system to convert the user’s speech into an SQL query and then fetches data from the SQL server based on that query. Finally, the result is converted back into speech using Azure Text to Speech Service and played back to the user

    The blog post provides a step-by-step guide on how to create a semantic search model using Azure OpenAI and integrate it with your SQL database. It also includes sample code and screenshots to help you get started.

    I would recommend reading through the blog post and following the instructions to create your own semantic search model.

    Do let me know if that helps or have any further queries.


    If the response helped, please do click Accept Answer and Yes for was this answer helpful.

    Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.


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.