|
34 | 34 | "cell_type": "code",
|
35 | 35 | "execution_count": 1,
|
36 | 36 | "metadata": {},
|
37 |
| - "outputs": [], |
38 |
| - "source": [ |
39 |
| - "import os, json\n", |
40 |
| - "from pymongo import MongoClient" |
| 37 | + "outputs": [ |
| 38 | + { |
| 39 | + "ename": "ModuleNotFoundError", |
| 40 | + "evalue": "No module named 'pymongo'", |
| 41 | + "output_type": "error", |
| 42 | + "traceback": [ |
| 43 | + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", |
| 44 | + "\u001b[31mModuleNotFoundError\u001b[39m Traceback (most recent call last)", |
| 45 | + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[1]\u001b[39m\u001b[32m, line 3\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mos\u001b[39;00m\n\u001b[32m 2\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01msys\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m3\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mpymongo\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m MongoClient\n\u001b[32m 5\u001b[39m \u001b[38;5;66;03m# Add parent directory to path to import from utils\u001b[39;00m\n\u001b[32m 6\u001b[39m sys.path.append(os.path.join(os.path.dirname(os.getcwd())))\n", |
| 46 | + "\u001b[31mModuleNotFoundError\u001b[39m: No module named 'pymongo'" |
| 47 | + ] |
| 48 | + } |
| 49 | + ], |
| 50 | + "source": [ |
| 51 | + "import os\n", |
| 52 | + "import sys\n", |
| 53 | + "from pymongo import MongoClient\n", |
| 54 | + "\n", |
| 55 | + "# Add parent directory to path to import from utils\n", |
| 56 | + "sys.path.append(os.path.join(os.path.dirname(os.getcwd())))\n", |
| 57 | + "from utils import track_progress, set_env" |
41 | 58 | ]
|
42 | 59 | },
|
43 | 60 | {
|
|
47 | 64 | "outputs": [],
|
48 | 65 | "source": [
|
49 | 66 | "# If you are using your own MongoDB Atlas cluster, use the connection string for your cluster here\n",
|
50 |
| - "MONGODB_URI = os.environ.get(\"MONGODB_URI\")\n", |
| 67 | + "MONGODB_URI = os.environ.get(\"MONGODB_URI\")\n", |
51 | 68 | "# Initialize a MongoDB Python client\n",
|
52 | 69 | "mongodb_client = MongoClient(MONGODB_URI)\n",
|
53 | 70 | "# Check the connection to the server\n",
|
54 | 71 | "mongodb_client.admin.command(\"ping\")"
|
55 | 72 | ]
|
56 | 73 | },
|
| 74 | + { |
| 75 | + "cell_type": "code", |
| 76 | + "execution_count": null, |
| 77 | + "metadata": {}, |
| 78 | + "outputs": [], |
| 79 | + "source": [ |
| 80 | + "# Set the LLM provider and passkey provided by your workshop instructor\n", |
| 81 | + "# NOTE: LLM_PROVIDER can be set to one of \"aws\"/ \"microsoft\" / \"google\"\n", |
| 82 | + "LLM_PROVIDER = \"aws\"\n", |
| 83 | + "PASSKEY = \"replace-with-passkey\"" |
| 84 | + ] |
| 85 | + }, |
| 86 | + { |
| 87 | + "cell_type": "code", |
| 88 | + "execution_count": null, |
| 89 | + "metadata": {}, |
| 90 | + "outputs": [], |
| 91 | + "source": [ |
| 92 | + "# Obtain API keys from our AI model proxy and set them as environment variables-- DO NOT CHANGE\n", |
| 93 | + "set_env([LLM_PROVIDER,\"voyageai\"], PASSKEY)" |
| 94 | + ] |
| 95 | + }, |
57 | 96 | {
|
58 | 97 | "cell_type": "markdown",
|
59 | 98 | "metadata": {},
|
|
106 | 145 | "### Pick an LLM provider of your choice below"
|
107 | 146 | ]
|
108 | 147 | },
|
109 |
| - { |
110 |
| - "cell_type": "code", |
111 |
| - "execution_count": 6, |
112 |
| - "metadata": {}, |
113 |
| - "outputs": [], |
114 |
| - "source": [ |
115 |
| - "SERVERLESS_URL = os.environ.get(\"SERVERLESS_URL\")\n", |
116 |
| - "# Can be one of \"aws\", \"google\" or \"microsoft\"\n", |
117 |
| - "LLM_PROVIDER = \"aws\"" |
118 |
| - ] |
119 |
| - }, |
120 | 148 | {
|
121 | 149 | "cell_type": "code",
|
122 | 150 | "execution_count": null,
|
123 | 151 | "metadata": {},
|
124 | 152 | "outputs": [],
|
125 | 153 | "source": [
|
126 | 154 | "from langchain_core.load import load\n",
|
127 |
| - "import requests\n", |
| 155 | + "from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder\n", |
| 156 | + "from utils import get_llm\n", |
128 | 157 | "\n",
|
129 |
| - "# Obtain the Langchain LLM object from our serverless endpoint\n", |
130 |
| - "llm_dict = requests.post(\n", |
131 |
| - " url=SERVERLESS_URL, json={\"task\": \"get_llm\", \"data\": LLM_PROVIDER}\n", |
132 |
| - ").json()\n", |
133 |
| - "llm = load(llm_dict[\"llm\"], secrets_map=llm_dict[\"secrets_map\"])" |
| 158 | + "# Obtain the Langchain LLM object using the `get_llm` function from the `utils`` module.\n", |
| 159 | + "llm = get_llm(LLM_PROVIDER)" |
134 | 160 | ]
|
135 | 161 | },
|
136 | 162 | {
|
|
1741 | 1767 | ],
|
1742 | 1768 | "metadata": {
|
1743 | 1769 | "kernelspec": {
|
1744 |
| - "display_name": "venv", |
| 1770 | + "display_name": "Python 3", |
1745 | 1771 | "language": "python",
|
1746 | 1772 | "name": "python3"
|
1747 | 1773 | },
|
|
1755 | 1781 | "name": "python",
|
1756 | 1782 | "nbconvert_exporter": "python",
|
1757 | 1783 | "pygments_lexer": "ipython3",
|
1758 |
| - "version": "3.11.11" |
| 1784 | + "version": "3.11.6" |
1759 | 1785 | }
|
1760 | 1786 | },
|
1761 | 1787 | "nbformat": 4,
|
|
0 commit comments