AI Engineer World's Fair 2024
Hasura Launch: Realtime Data Connectivity for AI
Read the talk
Connecting AI to live data with tools, shared queries, and Python
A customer email becomes a data-access problem: find the right customer, retrieve their recent activity, enforce permissions, and give the model a way to assemble the answer.
From a talk by Tanmai Gopal
Before you start: Basic familiarity with LLM tool use, APIs, and database queries will help; the SQL and Python examples require no Hasura-specific knowledge.
Why can an LLM build a game but not answer a calendar question?
Connecting an AI to live data sounds simpler than asking it to build an application. Tanmai Gopal opens with a joke about giving the coming AI overlords enough data to do their jobs, then promises an explanation simple enough to stake his switch from GPT-4 to Sonnet on it. The practical frustration is familiar: Gopal says an LLM can make a Flappy Bird game featuring his face in 30 seconds, yet cannot intelligently answer questions about his own data. That timing is his personal anecdote, with no model or measurement conditions specified.
The questions are ordinary, but each requires more than generating plausible text:
- Calendar: How many one-on-ones happened last week? What frequency makes sense given the team’s roles, and how should future meetings be staggered?
- Salesforce: Why is the Acme deal stuck in stage three? Answering requires understanding what should happen between stages two and three and finding what is missing for this deal.
- Support and product data: Is a ticket from an enterprise customer? Which project does it concern, what is that project’s status, and where is it in the product funnel?
These requests move from retrieving records to interpreting those records through the business’s relationships and rules.
Even a shopping assistant embedded beside a product can miss the relevant connection. Gopal describes asking Amazon’s Rufus whether a product could reach his Harrison Street address with one-day delivery. The slide shows a showerhead listing and the delivery question; he reports that Rufus could not answer it in that interaction. The necessary answer depends on the product, the destination, and delivery availability together.
Connecting more systems also raises a trust problem. Gopal does not want to expose his calendar through a custom GPT without knowing what happens to the data. Useful connectivity must include controlled access, rather than merely making another source reachable.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Make live data and business logic available as a tool
The proposed interface is straightforward: expose live data and business logic as a tool the LLM can use. The model needs a way to obtain the information required for a request, including the business logic that gives that information meaning. The interesting engineering lies in making that interface work across sources while preserving access rules.
The demonstration uses a fictional Blockbuster business, introduced with a joke about services businesses surviving while movie streaming goes nowhere in the AI world. Its database and transactions support a request to draft an email thanking the top customer for their patronage and mentioning some movies they watched recently.
That short request implies a retrieval procedure:
- Identify the top customer from the available business data.
- Retrieve that customer’s recent movie history.
- Use those facts to draft a personalized thank-you email.
Gopal reports that the request works while retrieving data from two or three different places. The demonstrated task is drafting the email; it does not establish that an email was sent. The explanation that follows focuses on three design choices behind this kind of retrieval.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Give different sources the same query semantics
The first choice is a unified query language for structured data, unstructured data, and APIs. Instead of making the LLM learn a different access vocabulary for every system, give it a common way to express what it needs. Gopal’s rationale is that models already know SQL, whereas the meaning of an application’s custom API may be unclear even to its developers.
His example is a simple filter:
sql
SELECT *
FROM X
WHERE ID > 1;
The operator carries defined semantics: return rows whose ID is strictly greater than 1. With an unfamiliar URL parameter, the model must discover whether a superficially similar filter means greater than, greater than or equal to, or something that only works with Boolean values.
| Interface | What the model must interpret |
|---|---|
SQL predicate ID > 1 | A defined comparison operator |
| Custom API parameter | The application’s particular parameter contract |
A shared language reduces the number of distinct query conventions the model must navigate. It does not, by itself, define business terms such as “top customer”; those still depend on the data and business logic exposed through the tool.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Let Python carry out the retrieval plan
The third choice is to let the LLM work out the data-access plan instead of hard-coding a plan for each request. The obvious objection is reliability: if a model struggles to count the Rs in strawberry, why trust it to retrieve and assemble information from several different places?
Gopal turns the challenge back on the audience: count the Is in supercalifragilisticexpialidocious. A difficult unaided counting task is a poor way to use either a person or a model when a computational tool is available. His instruction is: “Don't be mean to the LLM. Set it up for success.”
Ask the model to write Python that solves the problem. For the audience’s counting question, the operation can be expressed directly:
python
word = "supercalifragilisticexpialidocious"
letter = "i"
count = word.casefold().count(letter.casefold())
print(count)
The same division of labor motivates the retrieval design: the LLM produces a program, and code execution performs the operations needed to fetch the data. In the Blockbuster example, that means working out how to obtain the customer and movie information required for the draft, rather than relying on the model to produce those facts unaided. Gopal says they ask their LLMs to run Python to fetch the required data; he presents no quantitative evaluation of planning reliability.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Bring the data within reach
The closing joke turns the AI singularity into a data singularity: put the data together so AI can access it. For teams building AI, data access is part of the application; for teams managing data, the opportunity is to make it usable by AI. Gopal closes by inviting attendees to the Hasura booth and describing the offering as out in the open. The launch is identified in the event’s historical schedule as Pacha DDN. The practical ambition is the one behind the customer email: let an ordinary request reach the live information and business logic needed to answer it.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Resources
Further reading
- Hasura DDN beta announcementArticle
Tanmai Gopal explains DDN's architecture and composable access to databases, business logic, and APIs.
A technical walkthrough of Hasura's Postgres streaming APIs, including authorization rules based on data and session properties.
A separate Pacha demonstration discusses generated Python and SQL, investigation of empty results, and repair of an incorrect join.
Read the complete timestamped transcript
- 0:00
[on hold music] Cool. I'd originally titled this talk, um, Connect Real-Time Data to Your AI, et cetera, et cetera.
- 0:20
But really, it's more existential, right? The AI overlords are coming for us, and to help them be good rulers, to help us, let's just give them the data they need so that, you know, they can, they can do a good job, right?
- 0:32
Um, hopefully, this talk is gonna be the simplest talk that you hear at this conference. Um, if it's not, I'll go back to using GPT-4 for coding instead of Sonnet.
- 0:41
Um, but the real pain that I have as I work with LLMs is that they can write a Flappy Bird for me with my face going up and down in 30 seconds, but they can't talk to my data intelligently.
- 0:59
It's, uh... It's really stupid. Um, if I wanna connect it to my calendar, and I just wanna say, "How many one-on-ones did I have last week?
- 1:11
What's a good number to have with my team given their roles? Help me stagger them better and plan it out." I wanna connect it to my Salesforce and say, "Why is this deal with Acme stuck in stage three?"
- 1:25
And I need it to do the right thing. I need it to figure out the things between stage two and stage three in my sales pipeline, and tell me why that particular deal is blocked.
- 1:34
I want it to connect to my tickets and my product data and say, "Is this ticket from an enterprise customer? What's the name of their project? Can you tell me, like, what the status of that project is, and what part of the product funnel this project is in?"
- 1:47
Um, I went to Amazon today in the morning, and they have this Rufus thing, and I was like, "Okay, cool. Um, is this product..." I'm gonna tell you what that product is in a second.
- 1:58
Uh, "But is this product available for one-day delivery at my [REDACTED:location] Street address?" Right? And just, just doesn't... Like, what is this, right? Like, it's right here. Just do it.
- 2:11
And it doesn't work. And you, you, you all know why it doesn't work, right? There's, like, a death by a thousand cuts, and it's not secure, and I don't wanna connect my calendar and make it into a GPT.
- 2:20
Who even knows what the GPT is doing with this, right? Like, it's- it's- it's- it's- it's scary. Um, and it doesn't work. Um,
- 2:28
so we solved this with a pretty simple idea, which is that you take your live data and business logic, and you make that available as a tool to your LLM.
- 2:38
Um, no shit. It's not, it's not surprising, right? It's easy. Um, because ... And we did a bunch of things that makes it work really, really well, right? Um, see if we have time for a quick live demo here.
- 2:54
Let me see if I'm connected to the internet, which I am.
- 2:58
All right. I wanna zoom this up. All right. So,
- 3:09
um, I am a Blockbuster because obviously services business are the most important businesses now, and, like, um, movie streaming businesses are gonna go nowhere in the AI world that is to come.
- 3:20
And so in my Blockbuster database and transactions and all of this stuff that I have going on, I wanna ask my data a question and say, "What... Help me
- 3:32
write an email to my top customer thanking them for their patronage.
- 3:40
Um, quote, mention some recent movies they watched."
- 3:50
Right? A straightforward request. Um, I have all this data. I just need it to do the right things, and I need it to write an email for me, right?
- 3:59
And it works, and it works despite the fact that it's going to two or three different places and getting data from them. And it works pretty well. Mm, it handles all kinds of situations, and I'm gonna talk to you about three key ideas about how it works, and hopefully, that's gonna be useful to you as well.
- 4:15
So, the first is this idea of a unified query language. Whether you're talking to structured data or unstructured data or APIs, what if your LLM could talk to everything the same way, right?
- 4:34
LLMs don't know what your API is. If you're a little honest with yourselves, you probably don't know what your API does, right? Um, but, but LLMs know what SQL is, right?
- 4:42
Because when you say select star from X where ID greater than one, greater than has a semantic meaning that is embedded in the language that in your API, that URL param, who knows what it means.
- 4:54
Is this greater? Is it greater than equal to? Is it greater than, but actually only works with Boolean? I don't know, right? But it works with, um, SQL because LLMs know what that SQL is, right?
- 5:03
So the first part of this is let's just make everything one query language and deal with that. The second is an object model for authorization, right? Which is again, kind of blows my mind of why it's so complicated.
- 5:14
Look, I don't care where the data is coming from. The data has a schema, right? It's a property of the data, and it's a property of the session, and then just run the rule.
- 5:22
And maybe there's 100 rules, but it should just work. And then however it gets accessed, it's fine, right? I should be able to use this wherever it's used, however it's accessed, the same authorization should be applied.
- 5:33
So that's idea number two, and that's kind of embedded there as well. The third, and this is kind of interesting, is to get the LLM to figure out the plan to access data by itself.
- 5:43
We don't have to hard code it, and we don't have to do the work. And then you're like, "Tanmai, listen. What are you smoking, man? LLMs can't even reason.
- 5:50
I can't even get it to count the number of Rs in strawberry. What are you gonna do with... How are you gonna make me fetch all of this data from three or four different places and disassemble it and whatnot?"
- 5:58
And we're like, you know what? There's a really simple fix to this problem, but let me ask you a live question. How many of you can count the number of Is in supercalifragilisticexpialidocious?
- 6:06
Can you? You can't, right? You're being mean to the LLM by asking it such questions. Don't be mean to the LLM. Set it up for success.
- 6:16
Ask it to write Python code to solve the problem, and it works. And that's it. So when you're asking, and when we're asking our LLMs to figure out how to retrieve data, we just ask it to run Python code to fetch the data that we want.
- 6:31
So if [on hold music] if the AI singularity is coming, get ready for the data singularity. Put everything together. If you're doing AI, you need access to data. If you're doing data and you wish that it could talk to your AI, if you have AI and data and you need to get it to talk to each other, come visit us
- 6:48
at our booth. Everything's in the open at Hasura/Pacha DDN. Talk to you folks soon. Thank you for your time. [on hold music]