Skip to content

Commit 3c23112

Browse files
committed
fixing github web rendering of the notebook
1 parent 7b508ec commit 3c23112

2 files changed

Lines changed: 19 additions & 354 deletions

File tree

end-to-end-use-cases/coding/text2sql/quickstart/quickstart.ipynb

Lines changed: 19 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
"id": "e8cba0b6",
66
"metadata": {},
77
"source": [
8-
"<a href=\"https://colab.research.google.com/github/meta-llama/llama-cookbook/blob/main/end-to-end-use-cases/coding/text2sql/quickstart/quickstart.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a> \n",
9-
"\n",
108
"## Quick Demo of Text2SQL Using Llama 3.3\n",
119
"\n",
1210
"This demo shows how to use Llama 3.3 to answer questions about a SQLite DB. \n",
@@ -26,7 +24,7 @@
2624
},
2725
{
2826
"cell_type": "code",
29-
"execution_count": 2,
27+
"execution_count": null,
3028
"id": "fa4562d3",
3129
"metadata": {},
3230
"outputs": [],
@@ -65,7 +63,7 @@
6563
},
6664
{
6765
"cell_type": "code",
68-
"execution_count": 4,
66+
"execution_count": null,
6967
"id": "3bb99f39-cd7a-4db6-91dd-02f3bf80347c",
7068
"metadata": {},
7169
"outputs": [],
@@ -81,36 +79,10 @@
8179
},
8280
{
8381
"cell_type": "code",
84-
"execution_count": 5,
82+
"execution_count": null,
8583
"id": "8d793ce7-324b-4861-926c-54973d7c9b43",
8684
"metadata": {},
87-
"outputs": [
88-
{
89-
"name": "stdout",
90-
"output_type": "stream",
91-
"text": [
92-
"Based on the table schema below, write a SQL query that would answer the user's question; just return the SQL query and nothing else.\n",
93-
"\n",
94-
"Scheme:\n",
95-
"\n",
96-
"CREATE TABLE nba_roster (\n",
97-
"\t\"Team\" TEXT, \n",
98-
"\t\"NAME\" TEXT, \n",
99-
"\t\"Jersey\" TEXT, \n",
100-
"\t\"POS\" TEXT, \n",
101-
"\t\"AGE\" INTEGER, \n",
102-
"\t\"HT\" TEXT, \n",
103-
"\t\"WT\" TEXT, \n",
104-
"\t\"COLLEGE\" TEXT, \n",
105-
"\t\"SALARY\" TEXT\n",
106-
")\n",
107-
"\n",
108-
"Question: What team is Stephen Curry on?\n",
109-
"\n",
110-
"SQL Query:\n"
111-
]
112-
}
113-
],
85+
"outputs": [],
11486
"source": [
11587
"question = \"What team is Stephen Curry on?\"\n",
11688
"prompt = f\"\"\"Based on the table schema below, write a SQL query that would answer the user's question; just return the SQL query and nothing else.\n",
@@ -127,18 +99,10 @@
12799
},
128100
{
129101
"cell_type": "code",
130-
"execution_count": 6,
102+
"execution_count": null,
131103
"id": "70776558",
132104
"metadata": {},
133-
"outputs": [
134-
{
135-
"name": "stdout",
136-
"output_type": "stream",
137-
"text": [
138-
"SELECT Team FROM nba_roster WHERE NAME = 'Stephen Curry'\n"
139-
]
140-
}
141-
],
105+
"outputs": [],
142106
"source": [
143107
"answer = llm.invoke(prompt).content\n",
144108
"print(answer)"
@@ -154,21 +118,10 @@
154118
},
155119
{
156120
"cell_type": "code",
157-
"execution_count": 7,
121+
"execution_count": null,
158122
"id": "62472ce6-794b-4a61-b88c-a1e031e28e4e",
159123
"metadata": {},
160-
"outputs": [
161-
{
162-
"data": {
163-
"text/plain": [
164-
"\"[('Golden State Warriors',)]\""
165-
]
166-
},
167-
"execution_count": 7,
168-
"metadata": {},
169-
"output_type": "execute_result"
170-
}
171-
],
124+
"outputs": [],
172125
"source": [
173126
"# note this is a dangerous operation and for demo purpose only; in production app you'll need to safe-guard any DB operation\n",
174127
"result = db.run(answer)\n",
@@ -177,18 +130,10 @@
177130
},
178131
{
179132
"cell_type": "code",
180-
"execution_count": 8,
133+
"execution_count": null,
181134
"id": "39ed4bc3",
182135
"metadata": {},
183-
"outputs": [
184-
{
185-
"name": "stdout",
186-
"output_type": "stream",
187-
"text": [
188-
"I don't have enough information to determine whose salary you are referring to. Could you please provide more context or specify the person you are asking about?\n"
189-
]
190-
}
191-
],
136+
"outputs": [],
192137
"source": [
193138
"# how about a follow up question\n",
194139
"follow_up = \"What's his salary?\"\n",
@@ -205,39 +150,10 @@
205150
},
206151
{
207152
"cell_type": "code",
208-
"execution_count": 9,
153+
"execution_count": null,
209154
"id": "0c305278-29d2-4e88-9b3d-ad67c94ce0f2",
210155
"metadata": {},
211-
"outputs": [
212-
{
213-
"name": "stdout",
214-
"output_type": "stream",
215-
"text": [
216-
"Based on the table schema, question, SQL query, and SQL response below, write a new SQL response; be concise, just output the SQL response.\n",
217-
"\n",
218-
"Scheme:\n",
219-
"\n",
220-
"CREATE TABLE nba_roster (\n",
221-
"\t\"Team\" TEXT, \n",
222-
"\t\"NAME\" TEXT, \n",
223-
"\t\"Jersey\" TEXT, \n",
224-
"\t\"POS\" TEXT, \n",
225-
"\t\"AGE\" INTEGER, \n",
226-
"\t\"HT\" TEXT, \n",
227-
"\t\"WT\" TEXT, \n",
228-
"\t\"COLLEGE\" TEXT, \n",
229-
"\t\"SALARY\" TEXT\n",
230-
")\n",
231-
"\n",
232-
"Question: What's his salary?\n",
233-
"SQL Query: What team is Stephen Curry on?\n",
234-
"SQL Result: [('Golden State Warriors',)]\n",
235-
"\n",
236-
"New SQL Response:\n",
237-
"\n"
238-
]
239-
}
240-
],
156+
"outputs": [],
241157
"source": [
242158
"prompt = f\"\"\"Based on the table schema, question, SQL query, and SQL response below, write a new SQL response; be concise, just output the SQL response.\n",
243159
"\n",
@@ -255,18 +171,10 @@
255171
},
256172
{
257173
"cell_type": "code",
258-
"execution_count": 10,
174+
"execution_count": null,
259175
"id": "03739b96-e607-4fa9-bc5c-df118198dc7f",
260176
"metadata": {},
261-
"outputs": [
262-
{
263-
"name": "stdout",
264-
"output_type": "stream",
265-
"text": [
266-
"SELECT SALARY FROM nba_roster WHERE NAME = \"Stephen Curry\"\n"
267-
]
268-
}
269-
],
177+
"outputs": [],
270178
"source": [
271179
"new_answer = llm.invoke(prompt).content\n",
272180
"print(new_answer)"
@@ -282,32 +190,13 @@
282190
},
283191
{
284192
"cell_type": "code",
285-
"execution_count": 11,
193+
"execution_count": null,
286194
"id": "6ecfca53-be7e-4668-bad1-5ca7571817d7",
287195
"metadata": {},
288-
"outputs": [
289-
{
290-
"data": {
291-
"text/plain": [
292-
"\"[('$51,915,615',)]\""
293-
]
294-
},
295-
"execution_count": 11,
296-
"metadata": {},
297-
"output_type": "execute_result"
298-
}
299-
],
196+
"outputs": [],
300197
"source": [
301198
"db.run(new_answer)"
302199
]
303-
},
304-
{
305-
"cell_type": "code",
306-
"execution_count": null,
307-
"id": "9d79bbb1-e91d-4b56-b6ef-98c94ff414d0",
308-
"metadata": {},
309-
"outputs": [],
310-
"source": []
311200
}
312201
],
313202
"metadata": {
@@ -331,5 +220,7 @@
331220
"pygments_lexer": "ipython3",
332221
"version": "3.10.14"
333222
}
334-
}
223+
},
224+
"nbformat": 4,
225+
"nbformat_minor": 5
335226
}

0 commit comments

Comments
 (0)