Skip to content

Commit baec626

Browse files
authored
Chatbot: Fix a few details in telemetry diagnostics assistant (#916)
1 parent 2ad5786 commit baec626

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

topic/chatbot/table-augmented-generation/workshop/telemetry-diagnostics-assistant.ipynb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@
709709
"load_dotenv()\n",
710710
"\n",
711711
"# Create OpenAI client using environment variable\n",
712-
"client = OpenAI(api_key=os.getenv(\"OPENAI_API_KEY\"))\n",
712+
"openai_client = OpenAI(api_key=os.getenv(\"OPENAI_API_KEY\"))\n",
713713
"\n",
714714
"# Create a natural language → SQL prompt with real schema\n",
715715
"def nl_to_sql_prompt(question, table_name=\"motor_readings\"):\n",
@@ -747,7 +747,7 @@
747747
"def get_sql_from_llm(question, table_name=\"motor_readings\"):\n",
748748
" prompt = nl_to_sql_prompt(question, table_name)\n",
749749
"\n",
750-
" response = client.chat.completions.create(\n",
750+
" response = openai_client.chat.completions.create(\n",
751751
" model=\"gpt-3.5-turbo\",\n",
752752
" messages=[\n",
753753
" {\"role\": \"system\", \"content\": \"You are a helpful assistant that only outputs SQL queries compatible with CrateDB.\"},\n",
@@ -1064,7 +1064,8 @@
10641064
"\n",
10651065
"# Store in CrateDB\n",
10661066
"df_manuals.to_sql(\"machine_manuals\", con=engine, if_exists=\"replace\", index=False)\n",
1067-
"print(f\"✅ Stored manuals for {len(df_manuals)} machines in 'machine_manuals'.\")"
1067+
"print(f\"✅ Stored manuals for {len(df_manuals)} machines in 'machine_manuals'.\")\n",
1068+
"connection.execute(sa.text(\"REFRESH TABLE machine_manuals;\"))"
10681069
]
10691070
},
10701071
{

0 commit comments

Comments
 (0)