Microsoft Dev Blogs

Make data more human with Azure OpenAI and Azure SQL

thumbnail

Title: Make data more human with Azure OpenAI and Azure SQL

Introduction

In this post, we will explore how we can use Azure OpenAI models to query SQL tables and make data more human. We will use the LangChain Python library to combine the power of Large Language Models with the logic of an application.

Requirements

To follow along, you'll need:

  • Access to Azure OpenAI: you can apply for access by completing a form
  • An Azure OpenAI resource with a model deployed
  • An Azure SQL Database
  • Python and the LangChain library installed

Initializing Azure OpenAI model

We'll use LangChain to initialize our Azure OpenAI model. This requires providing your keys and endpoint, as well as the name of your deployment and model. We'll use the text-davinci-003 model for this demonstration.

Querying SQL tables

With the Azure OpenAI model initialized, we can use the pandas DataFrame agent in LangChain to ask questions against our SQL table. The agent is able to provide the right output and show the thought process behind the query.

Conclusion

By combining the power of Azure OpenAI models and Azure SQL, we can make data more accessible and human-like. LangChain allows for better interaction with context and data stored in Azure SQL tables.