Skip to content

Commit

Permalink
Improved the configuration for the TiDB connection URL to help users …
Browse files Browse the repository at this point in the history
…avoid errors. (#15580)
  • Loading branch information
IANTHEREAL authored Aug 23, 2024
1 parent 46d3c16 commit 68b90a3
Showing 1 changed file with 32 additions and 26 deletions.
58 changes: 32 additions & 26 deletions docs/docs/examples/vector_stores/TiDBVector.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Configure both the OpenAI and TiDB host settings that you will need"
"Configuring your OpenAI Key"
]
},
{
Expand All @@ -54,13 +54,36 @@
"metadata": {},
"outputs": [],
"source": [
"# Here we useimport getpass\n",
"import getpass\n",
"import os\n",
"\n",
"os.environ[\"OPENAI_API_KEY\"] = getpass.getpass(\"OpenAI API Key:\")\n",
"tidb_connection_url = getpass.getpass(\n",
" \"TiDB connection URL (format - mysql+pymysql://[email protected]:4000/test): \"\n",
"os.environ[\"OPENAI_API_KEY\"] = getpass.getpass(\"Input your OpenAI API key:\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Configure TiDB connection setting that you will need. To connect to your TiDB Cloud Cluster, follow these steps:\n",
"\n",
"- Go to your TiDB Cloud cluster Console and navigate to the `Connect` page.\n",
"- Select the option to connect using `SQLAlchemy` with `PyMySQL`, and copy the provided connection URL (without password).\n",
"- Paste the connection URL into your code, replacing the `tidb_connection_string_template` variable.\n",
"- Type your password."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# replace with your tidb connect string from tidb cloud console\n",
"tidb_connection_string_template = \"mysql+pymysql://<USER>:<PASSWORD>@<HOST>:4000/<DB>?ssl_ca=/etc/ssl/cert.pem&ssl_verify_cert=true&ssl_verify_identity=true\"\n",
"# type your tidb password\n",
"tidb_password = getpass.getpass(\"Input your TiDB password:\")\n",
"tidb_connection_url = tidb_connection_string_template.replace(\n",
" \"<PASSWORD>\", tidb_password\n",
")"
]
},
Expand Down Expand Up @@ -90,7 +113,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Document ID: d970e919-4469-414b-967e-24dd9b2eb014\n"
"Document ID: 86e12675-2e9a-4097-847c-8b981dd41806\n"
]
}
],
Expand Down Expand Up @@ -137,18 +160,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/ianz/Work/miniconda3/envs/llama_index/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from .autonotebook import tqdm as notebook_tqdm\n",
"Parsing nodes: 100%|██████████| 1/1 [00:00<00:00, 8.76it/s]\n",
"Generating embeddings: 100%|██████████| 21/21 [00:02<00:00, 8.22it/s]\n"
]
}
],
"outputs": [],
"source": [
"storage_context = StorageContext.from_defaults(vector_store=tidbvec)\n",
"index = VectorStoreIndex.from_documents(\n",
Expand Down Expand Up @@ -188,9 +200,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"The author worked on writing, programming, building microcomputers, giving talks at conferences,\n",
"publishing essays online, developing spam filters, painting, hosting dinner parties, and purchasing\n",
"a building for office use.\n"
"The author wrote a book.\n"
]
}
],
Expand Down Expand Up @@ -256,11 +266,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"The author learned programming on an IBM 1401 using an early version of Fortran in 9th grade, then\n",
"later transitioned to working with microcomputers like the TRS-80 and Apple II. Additionally, the\n",
"author studied philosophy in college but found it unfulfilling, leading to a switch to studying AI.\n",
"Later on, the author attended art school in both the US and Italy, where they observed a lack of\n",
"substantial teaching in the painting department.\n"
"The author learned valuable lessons from his experiences.\n"
]
}
],
Expand Down

0 comments on commit 68b90a3

Please sign in to comment.