Weaviate: adding auth example + fixing spelling in ReadME (#8939)

Added basic auth example to Weaviate notebook @baskaryan
This commit is contained in:
Molly Cantillon 2023-08-08 16:24:17 -07:00 committed by GitHub
parent 95cf7de112
commit 99b5a7226c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,17 +81,18 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 21,
"id": "53b7ce2d-3c09-4d1c-b66b-5769ce6746ae", "id": "53b7ce2d-3c09-4d1c-b66b-5769ce6746ae",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"os.environ[\"WEAVIATE_API_KEY\"] = getpass.getpass(\"WEAVIATE_API_KEY:\")" "os.environ[\"WEAVIATE_API_KEY\"] = getpass.getpass(\"WEAVIATE_API_KEY:\")\n",
"WEAVIATE_API_KEY = os.environ[\"WEAVIATE_API_KEY\"]"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 7,
"id": "aac9563e", "id": "aac9563e",
"metadata": { "metadata": {
"tags": [] "tags": []
@ -106,7 +107,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 12,
"id": "a3c3999a", "id": "a3c3999a",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -123,7 +124,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 14,
"id": "21e9e528", "id": "21e9e528",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -133,7 +134,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 15,
"id": "b4170176", "id": "b4170176",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -144,7 +145,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 16,
"id": "ecf3b890", "id": "ecf3b890",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -166,6 +167,53 @@
"print(docs[0].page_content)" "print(docs[0].page_content)"
] ]
}, },
{
"attachments": {},
"cell_type": "markdown",
"id": "7826d0ea",
"metadata": {},
"source": [
"## Authentication"
]
},
{
"cell_type": "markdown",
"id": "13989a7c",
"metadata": {},
"source": [
"Weaviate instances have authentication enabled by default. You can use either a username/password combination or API key. "
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "f6604f1d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<langchain.vectorstores.weaviate.Weaviate object at 0x107f46550>\n"
]
}
],
"source": [
"import weaviate\n",
"\n",
"client = weaviate.Client(url=WEAVIATE_URL, auth_client_secret=weaviate.AuthApiKey(WEAVIATE_API_KEY))\n",
"\n",
"# client = weaviate.Client(\n",
"# url=WEAVIATE_URL,\n",
"# auth_client_secret=weaviate.AuthClientPassword(\n",
"# username = \"WCS_USERNAME\", # Replace w/ your WCS username\n",
"# password = \"WCS_PASSWORD\", # Replace w/ your WCS password\n",
"# ),\n",
"# )\n",
"\n",
"vectorstore = Weaviate.from_documents(documents, embeddings, client=client, by_text=False)"
]
},
{ {
"attachments": {}, "attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
@ -187,7 +235,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": 17,
"id": "102105a1", "id": "102105a1",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -213,7 +261,7 @@
"id": "8fc3487b", "id": "8fc3487b",
"metadata": {}, "metadata": {},
"source": [ "source": [
"# Persistance" "# Persistence"
] ]
}, },
{ {
@ -249,7 +297,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": null,
"id": "8b7df7ae", "id": "8b7df7ae",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -287,7 +335,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": null,
"id": "5e824f3b", "id": "5e824f3b",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -298,7 +346,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": null,
"id": "61209cc3", "id": "61209cc3",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -311,7 +359,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": null,
"id": "4abc3d37", "id": "4abc3d37",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -327,7 +375,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": null,
"id": "c7062393", "id": "c7062393",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -339,7 +387,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": null,
"id": "7e41b773", "id": "7e41b773",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [