← All AI Engineer talks

AI Engineer World's Fair 2024

Hasura Launch: Realtime Data Connectivity for AI

Tanmai Gopal· CEO, Hasura7:14

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.

Slide showing a showerhead product and Rufus conversation beside the question, “Is this product available for 1 day delivery at my Harrison St address?”
Rufus cannot answer a question about one-day delivery to a Harrison St address.

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.

0:200:32
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

0:20 · section reference included

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.

Full-screen slide reading, “We solved this. Make your data & business logic available as a tool for your LLM.”
Make data and business logic available as a tool for an LLM.

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:

  1. Identify the top customer from the available business data.
  2. Retrieve that customer’s recent movie history.
  3. 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.

2:282:38
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

2:28 · section reference included

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.

InterfaceWhat the model must interpret
SQL predicate ID > 1A defined comparison operator
Custom API parameterThe 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.

4:154:34
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

4:15 · section reference included

Evaluate permissions from the data and the session

The second choice is an object model for authorization. The source’s location should not determine the permission rule. Start with the data’s schema and properties, combine them with properties of the requesting session, and evaluate the applicable rule. The authorization diagram places databases, APIs, and vector data beneath that same data-and-session framing.

Diagram connecting a user to a user record and Databases, APIs, and Vector boxes, above text reading “Property of the data, property of the session.”
Data and session properties frame the authorization problem.

The intended invariant is that the same authorization applies wherever and however the data is accessed through the system. Gopal imagines even a hundred rules to emphasize consistent evaluation, not to give a capacity measurement. For the customer-email task, choosing a different retrieval route should not change which customer records the session is allowed to read. That requires the access route to pass through the authorization layer; the proposal is not a claim that rules automatically protect paths that bypass it.

5:035:14
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

5:03 · section reference included

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.

Full-screen slide reading, “Write a python program to figure out a plan to retrieve multiple pieces of data required.”
Use a Python program to plan retrieval of multiple pieces of data.
5:335:43
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

5:33 · section reference included

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.

6:316:48
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

6:31 · section reference included

Resources

Read the complete timestamped transcript
  1. 0:00

    [on hold music] Cool. I'd originally titled this talk, um, Connect Real-Time Data to Your AI, et cetera, et cetera.

  2. 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?

  3. 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.

  4. 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.

  5. 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?

  6. 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?"

  7. 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.

  8. 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?"

  9. 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.

  10. 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.

  11. 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.

  12. 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,

  13. 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.

  14. 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.

  15. 2:54

    Let me see if I'm connected to the internet, which I am.

  16. 2:58

    All right. I wanna zoom this up. All right. So,

  17. 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.

  18. 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

  19. 3:32

    write an email to my top customer thanking them for their patronage.

  20. 3:40

    Um, quote, mention some recent movies they watched."

  21. 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?

  22. 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.

  23. 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?

  24. 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?

  25. 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.

  26. 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?

  27. 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.

  28. 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.

  29. 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.

  30. 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.

  31. 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.

  32. 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?"

  33. 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?

  34. 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.

  35. 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.

  36. 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

  37. 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]