Azure-Samples / azure-search-openai-demo

A sample app for the Retrieval-Augmented Generation pattern running in Azure, using Azure AI Search for retrieval and Azure OpenAI large language models to power ChatGPT-style and Q&A experiences.
https://azure.microsoft.com/products/search
MIT License
5.94k stars 4.08k forks source link

Integrating Azure SQL Database #1467

Open Yasser-Essafi opened 6 months ago

Yasser-Essafi commented 6 months ago

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Any log messages given by the failure

Expected/desired behavior

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

azd version?

run azd version and copy paste here.

Versions

Mention any other details that might be useful

I am currently utilizing your application from this repository, which has been instrumental in facilitating conversations with data. The application, as it stands, supports certain data formats, but I am looking to expand its capabilities to interact directly with an Azure SQL Database.

Currently, my understanding is that the application primarily interacts with data in formats like JSON. However, my requirement involves querying data housed in an Azure SQL Database. I am reaching out to inquire about the feasibility and existing support for this integration.

Specifically, I am interested in knowing:

Is there an existing method or feature within the application that allows querying Azure SQL Databases? If not directly supported, would you recommend any specific approach to enable this functionality? For instance, would transforming the SQL data into JSON or another supported format be a viable pathway? Are there any plans to include direct Azure SQL Database integration in future updates of the application?

Any guidance or suggestions you could provide on this matter would be immensely helpful.


Thanks! We'll be in touch soon.

pamelafox commented 6 months ago

Are you looking for it to support both Azure AI Search or just Azure SQL database? I am working on some guidance around the latter, see my tweet at https://twitter.com/pamelafox/status/1773385817156988985

Yasser-Essafi commented 6 months ago

I want it to support both Azure AI Search and Azure SQL database. the problem i had with FASTAPI is that i can create one indexr for a single table while my database contains many. It's somehow related to the issue here: https://stackoverflow.com/questions/77365306/azure-cognitive-search-multiple-sql-tables

pamelafox commented 6 months ago

Are you looking to use Azure AI search to ingest the rows from your Azure SQL database, or are you planning to query both Azure AI search and Azure SQL database concurrently with the same query? And are you saying you want to query multiple Azure SQL database columns with the same user query?

Yasser-Essafi commented 6 months ago

My primary goal is to enable the chatbot to directly query an Azure SQL Database. I am looking to enable the chatbot to query multiple columns within an Azure SQL Database with a single user query. The idea is to allow users to retrieve diverse pieces of information from different columns or tables based on their query.

pamelafox commented 6 months ago

Okay, then my recommendation is to add an additional call in chatreadretrieveread.py to query the desired database columns using the user query and/or it's embedding. You can use asyncio.gather() to send both the AI search call and Azure SQL call concurrently, which should save some time.

We don't currently have plans to add support for querying a SQL database to this repo. As I mentioned earlier in the thread, I'm working on a RAG-on-PostgreSQL sample as well, but that will be in a different repo. However, you should be able to do what you want in this repo. Let me know if you have additional follow-up questions.

vlasvlasvlas commented 5 months ago

Okay, then my recommendation is to add an additional call in chatreadretrieveread.py to query the desired database columns using the user query and/or it's embedding. You can use asyncio.gather() to send both the AI search call and Azure SQL call concurrently, which should save some time.

We don't currently have plans to add support for querying a SQL database to this repo. As I mentioned earlier in the thread, I'm working on a RAG-on-PostgreSQL sample as well, but that will be in a different repo. However, you should be able to do what you want in this repo. Let me know if you have additional follow-up questions.

Hi Pamela, this is great. where can i find the RAG-on-PostgreSQL git sample?

Also, kind of offtopic, but i still dunno if azure ai search could help me ask structured data with filtering questions (example, getting kind of answers where data must be filtered, or i imagine like sql where's order by's group by's answers)

pamelafox commented 5 months ago

@vlasvlasvlas I will present the rag-on-postgres at tomorrow's VS Code Day event (and publish the repo then - it's still WIP!) https://developer.microsoft.com/en-us/reactor/events/22078/

You should be able to use a similar approach to do filtered queries on Azure AI Search as well, using the Azure AI Search operators available. See my blog post here: https://blog.pamelafox.org/2024/03/rag-techniques-using-function-calling.html