Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update udf to function in notebooks and docs #1047

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 99 additions & 94 deletions tutorials/01-mnist.ipynb

Large diffs are not rendered by default.

319 changes: 56 additions & 263 deletions tutorials/02-object-detection.ipynb

Large diffs are not rendered by default.

372 changes: 70 additions & 302 deletions tutorials/03-emotion-analysis.ipynb

Large diffs are not rendered by default.

213 changes: 59 additions & 154 deletions tutorials/05-asl-action-recognition.ipynb

Large diffs are not rendered by default.

257 changes: 153 additions & 104 deletions tutorials/06-loading-structured-data.ipynb

Large diffs are not rendered by default.

229 changes: 56 additions & 173 deletions tutorials/07-object-segmentation-huggingface.ipynb

Large diffs are not rendered by default.

112 changes: 23 additions & 89 deletions tutorials/08-chatgpt.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -191,71 +191,6 @@
"open_ai_key = os.environ.get('OPENAI_KEY')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"execution": {
"iopub.execute_input": "2023-06-25T21:02:05.208971Z",
"iopub.status.busy": "2023-06-25T21:02:05.208713Z",
"iopub.status.idle": "2023-06-25T21:02:05.368416Z",
"shell.execute_reply": "2023-06-25T21:02:05.367640Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>0</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>UDF ChatGPT successfully added to the database.</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0\n",
"0 UDF ChatGPT successfully added to the database."
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Drop the UDF if it already exists\n",
"cursor.query(\"DROP UDF IF EXISTS ChatGPT;\").df()\n",
"\n",
"# Register the ChatGPT UDF in EvaDB\n",
"create_udf_query = f\"\"\"CREATE UDF ChatGPT\n",
" IMPL 'chatgpt.py' \"\"\"\n",
"cursor.query(create_udf_query).df()\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
Expand Down Expand Up @@ -328,9 +263,9 @@
}
],
"source": [
"#load the video\n",
"cursor.drop_table(\"VIDEOS\", if_exists=True).df()\n",
"cursor.query(\"LOAD VIDEO 'russia_ukraine.mp4' INTO VIDEOS;\").df()"
"# Load the video\n",
"cursor.query(\"DROP TABLE IF EXISTS VIDEOS\").df()\n",
"cursor.query(\"LOAD VIDEO 'russia_ukraine.mp4' INTO VIDEOS\").df()"
]
},
{
Expand Down Expand Up @@ -398,15 +333,15 @@
],
"source": [
"# Drop the Text Summarization UDF if needed\n",
"cursor.query(\"DROP UDF IF EXISTS SpeechRecognizer;\").df()\n",
"cursor.query(\"DROP FUNCTION IF EXISTS SpeechRecognizer;\").df()\n",
"\n",
"# Create a Text Summarization UDF using Hugging Face\n",
"text_summarizer_udf_creation = \"\"\"\n",
" CREATE UDF SpeechRecognizer \n",
" TYPE HuggingFace \n",
" 'task' 'automatic-speech-recognition' \n",
" 'model' 'openai/whisper-base';\n",
" \"\"\"\n",
" CREATE FUNCTION SpeechRecognizer \n",
" TYPE HuggingFace \n",
" TASK 'automatic-speech-recognition' \n",
" MODEL 'openai/whisper-base';\n",
"\"\"\"\n",
"cursor.query(text_summarizer_udf_creation).df()"
]
},
Expand Down Expand Up @@ -504,7 +439,7 @@
" CREATE TABLE\n",
" TEXT_SUMMARY AS \n",
" SELECT SpeechRecognizer(audio) FROM VIDEOS; \n",
" \"\"\"\n",
"\"\"\"\n",
"cursor.query(text_summarization_query).df()"
]
},
Expand Down Expand Up @@ -566,9 +501,9 @@
"source": [
"# Run ChatGPT over the Text Summary extracted by Whisper\n",
"chatgpt_udf = \"\"\"\n",
" SELECT ChatGPT('Is this video summary related to Ukraine russia war',text) \n",
" FROM TEXT_SUMMARY;\n",
" \"\"\"\n",
" SELECT ChatGPT('Is this video summary related to Ukraine russia war',text) \n",
" FROM TEXT_SUMMARY;\n",
"\"\"\"\n",
"cursor.query(chatgpt_udf).df()"
]
},
Expand Down Expand Up @@ -747,7 +682,7 @@
" CREATE TABLE\n",
" SNL_TEXT_SUMMARY AS \n",
" SELECT SpeechRecognizer(audio) FROM SNL_VIDEO;\n",
" \"\"\"\n",
"\"\"\"\n",
"cursor.query(text_summarization_query).df()"
]
},
Expand Down Expand Up @@ -817,9 +752,9 @@
"source": [
"# Run ChatGPT over the Text Summary extracted by Whisper\n",
"chatgpt_udf = \"\"\"\n",
" SELECT ChatGPT('Is this video summary related to Ukraine russia war',text) \n",
" FROM SNL_TEXT_SUMMARY;\n",
" \"\"\"\n",
" SELECT ChatGPT('Is this video summary related to Ukraine russia war',text) \n",
" FROM SNL_TEXT_SUMMARY;\n",
"\"\"\"\n",
"cursor.query(chatgpt_udf).df()"
]
},
Expand Down Expand Up @@ -889,17 +824,16 @@
"source": [
"# Run ChatGPT over the Text Summary extracted by Whisper\n",
"chatgpt_udf = \"\"\"\n",
" SELECT ChatGPT('Is this video summary related to a hospital',text) \n",
" FROM SNL_TEXT_SUMMARY;\n",
" \"\"\"\n",
"\n",
" SELECT ChatGPT('Is this video summary related to a hospital',text) \n",
" FROM SNL_TEXT_SUMMARY;\n",
"\"\"\"\n",
"cursor.query(chatgpt_udf).df()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "env_ish_py3.8",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -913,9 +847,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
Loading