Build JSONAlyzeQueryEngine using Workflows
Key Takeaways
The video demonstrates how to build a JSONAlyzeQueryEngine using workflows, allowing users to analyze JSON objects from APIs by converting them into SQL queries and executing them on an in-memory SQLite database.
Full Transcript
hello everyone Ravi here from Lama index welcome to another video on uh implementing a quiry engine using workflows so previously we have seen uh citation query engine and uh subc quy Engine implementations with the uh workflows uh here we'll see Json alyze query engine implementation using workflows so what is the use of Json alyze query engine basically so often um you might receive uh uh responses from apas uh by calling some apis in the form of edes an object right uh like let's say for example uh if you go down so here is some uh example like yeah there is name age major email address City and various other details in a single Json object and then uh you have multiple of these outputs so you have all these uh uh outputs or the responses coming from several apas and then now you want to analyze on top of this uh Json list right so uh how can you do that so uh Json Aly query engine will help you to do that um so how is the process so what we essentially do is uh we'll dump this Json list into a sqlite uh table uh and then on top of that um you pass the query whatever the query is there that you need to to perform on this Json list you pass the query to the um sqli table and then generate a response under the hood uh you basically create an sqli table and uh you then convert this whatever the query the user asks into a SQL query based on the schema of the table and uh once you pass uh the query to the SQL table get a response you then uh pass it to llm again to uh make a uh proper response uh that can be sent to the user right so this is how a Json allies quy engine works uh let's give a quick walk through of it how you can implement the same with the workflow right so here there are two events uh JS analyzer and then synth siiz so basically JS analyzer what it uh does is it a start event so it basically sets up an inmemory SQ database uh loads whatever Json data is there and then generates a SQL query based on the user query uh using llm and then executes the uh generated SQL query on the SQL database and whatever the result is there uh along with the SQL query and the table schema it will be sent to the Sy size event in the syze event it will take all these results and uh then generate a human readable answer so these are the two events present um and then so we'll Define a Json analyzer event here uh it has the output as SQL query table schema and the results right so let's uh get through it uh we Define we'll Define a default response inor prom template as well so given a query since a response based on the SQL query results so here is the SQL query table sqa and SQL response and um normal query and then you generate a response accordingly right so we'll keep a default table name as items as well another promt that is used during Json Aly event is the default Json Aly promp template so given a user query based on the table schema and the query it will generate a SQL query this you'll use an llm to generate the SQL query right so here is the workflow so you have Json analyzer uh query engine workflow and then you get the input uh the query the llm and the table the table name is the default uh table name items and then list object which is the Json list and then the prompt is default JS analyze prompt okay you create an inmemory esal database then you send the prompt which is default uh J analyze prompt and then table name schema and the query to get the uh the default SQL query right and then um so this is what like you have SQL query table uh schema and the results right um and then you get it to synthesize uh part which has llm and then uh query and the default synthesiz prompt uh send it to the SQL query table schem and the results and generate a response accordingly right so here is an example uh with the different Json list and some saries uh accordingly to um experiment so let's let me quickly uh run this uh notebook here so uh here we will uh run through the notebook uh we'll need to set up the API key and then uh uh Define the event and then uh set up the prompt templates and then default table name and create the workflow and get the Json list Define the llm which is 3.5 and run the workflow and we have this uh simple question what is the maximum age among the individuals okay so yeah and gave answer the maximum age among the individuals is 35 and similarly yeah how many individuals have an occupation related to uh science or engineering and it say zero um let's have how many individuals have a phone number starting with yeah plus one 2 3 4 there are two individuals it seems right so this way you can uh run through all the examples and get response internally it will uh use the SQL light uh in memory database and then U go through the all the event processes that I have explained and get an answer accordingly so uh go through this notebook uh that's all I have for this video uh see you in the next video with a new implementation new query engine implementation with workflows thank you
Original Description
In this video, we will demonstrate how to construct a JSONAlyzeQueryEngine on list of JSON objects using workflows.
Notebook: https://github.com/run-llama/llama_index/blob/main/docs/docs/examples/workflow/JSONalyze_query_engine.ipynb
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from LlamaIndex · LlamaIndex · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
LlamaIndex Virtual Meetup (May 4th, 2023)
LlamaIndex
LlamaIndex + MongoDB Workshop/Fireside Chat
LlamaIndex
Discover LlamaIndex: Ask Complex Queries over Multiple Documents
LlamaIndex
Discover LlamaIndex: Document Management
LlamaIndex
Discover LlamaIndex: Joint Text to SQL and Semantic Search
LlamaIndex
Discover LlamaIndex: JSON Query Engine
LlamaIndex
LlamaIndex Webinar: Active Retrieval Augmented Generation
LlamaIndex
LlamaIndex Webinar: Demonstrate-Search-Predict (DSP) with Omar Khattab
LlamaIndex
LlamaIndex Sessions: Practical challenges of building a Legal Chatbot over your PDFs
LlamaIndex
LlamaIndex Webinar: Graph Databases, Knowledge Graphs, and RAG with Wey (NebulaGraph)
LlamaIndex
LlamaIndex Webinar: Community Project Showcase (07/07/2023)
LlamaIndex
LlamaIndex Webinar: LLMs for Investment Research (with Didier Lopes, co-founder/CEO at OpenBB)
LlamaIndex
Discover LlamaIndex: Bottoms-Up Development With LLMs (Part 1, LLMs and Prompts)
LlamaIndex
Discover LlamaIndex: Bottoms-Up Development With LLMs (Part 2, Documents and Metadata)
LlamaIndex
Discover LlamaIndex: Key Components to build QA Systems
LlamaIndex
Discover LlamaIndex: Bottoms-Up Development with LLMs (Part 3, Evaluation)
LlamaIndex
LlamaIndex Webinar: From Prompt to Schema Engineering with Pydantic (with @jxnlco)
LlamaIndex
Discover LlamaIndex: Bottoms-Up Development with LLMs (Part 4, Embeddings)
LlamaIndex
Discover LlamaIndex: Custom Retrievers + Hybrid Search
LlamaIndex
LlamaIndex Webinar: Document Metadata and Local Models for Better, Faster Retrieval
LlamaIndex
LlamaIndex Webinar: Build Personalized AI Characters with RealChar
LlamaIndex
LlamaIndex Webinar: Make RAG Production-Ready
LlamaIndex
LlamaIndex Workshop: Building RAG with Knowledge Graphs
LlamaIndex
Discover LlamaIndex: Introduction to Data Agents for Developers
LlamaIndex
LlamaIndex Webinar: Finetuning + RAG
LlamaIndex
Discover LlamaIndex: SEC Insights, End-to-End Guide
LlamaIndex
Discover LlamaIndex: Custom Tools for Data Agents
LlamaIndex
LlamaIndex Sessions: Building a Lending Criteria Chatbot in Production
LlamaIndex
Discover LlamaIndex: Bottoms-Up Development with LLMs (Part 5, Retrievers + Node Postprocessors)
LlamaIndex
LlamaIndex Webinar: How to Win a LLM Hackathon
LlamaIndex
LlamaIndex Webinar: LLM Challenges in Production (w/ Mayo Oshin, AI Jason, Dylan from Starmorph)
LlamaIndex
LlamaIndex Webinar: Agents Showcase!
LlamaIndex
LlamaIndex Webinar: Learn about DSPy
LlamaIndex
LlamaIndex Webinar: Time-based retrieval for RAG (with Timescale)
LlamaIndex
LlamaIndex Webinar: Build/Break/Test LLM Apps Showcase (co-hosted with TrueEra, Pinecone)
LlamaIndex
LlamaIndex Workshop: Evaluation-Driven Development (EDD)
LlamaIndex
LlamaIndex Webinar: Building LLM Apps for Production, Part 1 (co-hosted with Anyscale)
LlamaIndex
LlamaIndex Webinar: Learn about Fine-tuning + RAG (w/ Victoria Lin, author of RA-DIT)
LlamaIndex
LlamaIndex Webinar: What's next for AI after OpenAI Dev Day?
LlamaIndex
Introducing create-llama
LlamaIndex
LlamaIndex Webinar: PrivateGPT - Production RAG with Local Models
LlamaIndex
Multi-modal Retrieval Augmented Generation with LlamaIndex
LlamaIndex
LlamaIndex Webinar: LLaVa Deep Dive
LlamaIndex
A deep dive into Retrieval-Augmented Generation with Llamaindex
LlamaIndex
LlamaIndex Workshop: Multimodal + Advanced RAG Workhop with Gemini
LlamaIndex
LlamaIndex Webinar: Efficient Parallel Function Calling Agents with LLMCompiler
LlamaIndex
Introduction to Query Pipelines (Building Advanced RAG, Part 1)
LlamaIndex
LLMs for Advanced Question-Answering over Tabular/CSV/SQL Data (Building Advanced RAG, Part 2)
LlamaIndex
LlamaIndex Webinar: Advanced Tabular Data Understanding with LLMs
LlamaIndex
Ollama X LlamaIndex Multi-Modal
LlamaIndex
Build Agents from Scratch (Building Advanced RAG, Part 3)
LlamaIndex
LlamaIndex Webinar: Build No-Code RAG with Flowise
LlamaIndex
LlamaIndex Sessions: Practical Tips and Tricks for Productionizing RAG (feat. Sisil @ Jasper)
LlamaIndex
Introduction to LlamaIndex v0.10
LlamaIndex
Build SELF-DISCOVER from Scratch with LlamaIndex
LlamaIndex
Introducing LlamaCloud (and LlamaParse)
LlamaIndex
LlamaIndex Sessions: 12 RAG Pain Points and Solutions
LlamaIndex
LlamaIndex Webinar: RAG Beyond Basic Chatbots
LlamaIndex
A Comprehensive Cookbook for Claude 3
LlamaIndex
LlamaIndex Webinar: RAPTOR - Tree-Structured Indexing and Retrieval
LlamaIndex
More on: LLM Foundations
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
Embeddings Simplified
Medium · RAG
Building LSTMs with PyTorch and Lightning AI Part 7: Resuming Training with Checkpoints
Dev.to · Rijul Rajesh
How AI Learns with Less Labeled Data
Medium · AI
Comparing Sarvam-30B and Qwen2.5–14B on Spider Text-to-SQL: An Active-Parameter Perspective
Medium · LLM
🎓
Tutor Explanation
DeepCamp AI