Skip to content

Commit

Permalink
adds easier data source downloading options for LLM course
Browse files Browse the repository at this point in the history
Morgan McGuire authored and Morgan McGuire committed Jun 29, 2023
1 parent 8efabe7 commit 89bf330
Showing 2 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions llm-apps-course/notebooks/01. Using_APIs.ipynb
Original file line number Diff line number Diff line change
@@ -71,6 +71,7 @@
" if any(['VSCODE' in x for x in os.environ.keys()]):\n",
" print('Please enter password in the VS Code prompt at the top of your VS Code window!')\n",
" os.environ[\"OPENAI_API_KEY\"] = getpass(\"Paste your OpenAI key from: https://platform.openai.com/account/api-keys\\n\")\n",
" openai.api_key = os.getenv(\"OPENAI_API_KEY\", \"\")\n",
"\n",
"assert os.getenv(\"OPENAI_API_KEY\", \"\").startswith(\"sk-\"), \"This doesn't look like a valid OpenAI API key\"\n",
"print(\"OpenAI API key configured\")"
32 changes: 30 additions & 2 deletions llm-apps-course/notebooks/02. Generation.ipynb
Original file line number Diff line number Diff line change
@@ -45,10 +45,14 @@
"source": [
"import os\n",
"import random\n",
"from pathlib import Path\n",
"\n",
"import openai\n",
"import tiktoken\n",
"\n",
"from pathlib import Path\n",
"from pprint import pprint\n",
"from getpass import getpass\n",
"\n",
"from rich.markdown import Markdown\n",
"import pandas as pd\n",
"from tenacity import (\n",
@@ -78,6 +82,7 @@
" if any(['VSCODE' in x for x in os.environ.keys()]):\n",
" print('Please enter password in the VS Code prompt at the top of your VS Code window!')\n",
" os.environ[\"OPENAI_API_KEY\"] = getpass(\"Paste your OpenAI key from: https://platform.openai.com/account/api-keys\\n\")\n",
" openai.api_key = os.getenv(\"OPENAI_API_KEY\", \"\")\n",
"\n",
"assert os.getenv(\"OPENAI_API_KEY\", \"\").startswith(\"sk-\"), \"This doesn't look like a valid OpenAI API key\"\n",
"print(\"OpenAI API key configured\")"
@@ -180,6 +185,17 @@
"Let's read some user submitted queries from the file `examples.txt`. This file contains multiline questions separated by tabs (`\\t`)."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# Test if examples.txt is present, download if not\n",
"if not Path(\"examples.txt\").exists():\n",
" !wget https://raw.githubusercontent.com/wandb/edu/main/llm-apps-course/notebooks/examples.txt"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -254,6 +270,18 @@
"Let's create a function to find all the markdown files in a directory and return it's content and path"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# check if directory exists, if not, create it and download the files, e.g if running in colab\n",
"if not os.path.exists(\"../docs_sample/\"):\n",
" !git clone https://github.com/wandb/edu.git\n",
" !cp -r edu/llm-apps-course/docs_sample ../"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -608,7 +636,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.11.2"
}
},
"nbformat": 4,

0 comments on commit 89bf330

Please sign in to comment.