Skip to content

The agent engineering platform.

Update chat prompt structure in LLaMA SQL cookbook (#12364)

Lance Martin33810126bd19
diff --git a/cookbook/LLaMA2_sql_chat.ipynb b/cookbook/LLaMA2_sql_chat.ipynb
index 7c086c9322..cc9a21c5f3 100644
--- a/cookbook/LLaMA2_sql_chat.ipynb
+++ b/cookbook/LLaMA2_sql_chat.ipynb
@@ -47,7 +47,7 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 1,
"id": "6a75a5c6-34ee-4ab9-a664-d9b432d812ee",
"metadata": {},
"outputs": [
@@ -80,7 +80,7 @@
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": 2,
"id": "ce96f7ea-b3d5-44e1-9fa5-a79e04a9e1fb",
"metadata": {},
"outputs": [],
@@ -103,7 +103,7 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 3,
"id": "025bdd82-3bb1-4948-bc7c-c3ccd94fd05c",
"metadata": {},
"outputs": [],
@@ -133,7 +133,7 @@
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": 4,
"id": "5a4933ea-d9c0-4b0a-8177-ba4490c6532b",
"metadata": {},
"outputs": [
@@ -143,7 +143,7 @@
"' SELECT \"Team\" FROM nba_roster WHERE \"NAME\" = \\'Klay Thompson\\';'"
]
},
- "execution_count": 14,
+ "execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
@@ -260,8 +260,8 @@
},
{
"cell_type": "code",
- "execution_count": 19,
- "id": "1985aa1c-eb8f-4fb1-a54f-c8aa10744687",
+ "execution_count": 7,
+ "id": "022868f2-128e-42f5-8d90-d3bb2f11d994",
"metadata": {},
"outputs": [
{
@@ -270,7 +270,7 @@
"' SELECT \"Team\" FROM nba_roster WHERE \"NAME\" = \\'Klay Thompson\\';'"
]
},
- "execution_count": 19,
+ "execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
@@ -280,16 +280,14 @@
"from langchain.memory import ConversationBufferMemory\n",
"from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder\n",
"\n",
- "template = \"\"\"Based on the table schema below, write a SQL query that would answer the user's question:\n",
+ "template = \"\"\"Given an input question, convert it to a SQL query. No pre-amble. Based on the table schema below, write a SQL query that would answer the user's question:\n",
"{schema}\n",
- "\n",
- "Question: {question}\n",
- "SQL Query:\"\"\"\n",
+ "\"\"\"\n",
"prompt = ChatPromptTemplate.from_messages(\n",
" [\n",
- " (\"system\", \"Given an input question, convert it to a SQL query. No pre-amble.\"),\n",
+ " (\"system\", template),\n",
" MessagesPlaceholder(variable_name=\"history\"),\n",
- " (\"human\", template),\n",
+ " (\"human\", \"{question}\"),\n",
" ]\n",
")\n",
"\n",
@@ -319,27 +317,6 @@
"sql_response_memory.invoke({\"question\": \"What team is Klay Thompson on?\"})"
]
},
- {
- "cell_type": "code",
- "execution_count": 20,
- "id": "0b45818a-1498-441d-b82d-23c29428c2bb",
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "' SELECT \"SALARY\" FROM nba_roster WHERE \"NAME\" = \\'Klay Thompson\\';'"
- ]
- },
- "execution_count": 20,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "sql_response_memory.invoke({\"question\": \"What is his salary?\"})"
- ]
- },
{
"cell_type": "code",
"execution_count": 21,