Skip to content

Commit

Permalink
run pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Huaixinww committed Sep 19, 2024
1 parent 1b1ac85 commit ba57b11
Showing 1 changed file with 20 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@
"\n",
"ELASTIC_PASSWORD = getpass(\"ELASTIC PASSWORD: \")\n",
"\n",
"# e.g. \n",
"# e.g.\n",
"# hosts = \"http://es-xxx.elasticsearch.aliyuncs.com:9200\"\n",
"hosts=getpass(\"Host: \")\n",
"hosts = getpass(\"Host: \")\n",
"\n",
"# Create the client instance\n",
"client = Elasticsearch(\n",
" # For local development\n",
" # hosts=[\"http://localhost:9200\"]\n",
" hosts,\n",
" basic_auth=(ELASTIC_USER, ELASTIC_PASSWORD)\n",
" basic_auth=(ELASTIC_USER, ELASTIC_PASSWORD),\n",
")"
]
},
Expand Down Expand Up @@ -146,12 +146,12 @@
"API_KEY = getpass(\"Enter AlibabaCloud AI Search API key: \")\n",
"\n",
"# Please enter your AlibabaCloud AI Search host here\n",
"# e.g. \n",
"# e.g.\n",
"# HOST = \"default-xxx.opensearch.aliyuncs.com\"\n",
"HOST = \"\"\n",
"\n",
"# Please enter your AlibabaCloud AI Search workspace name here\n",
"# e.g. \n",
"# e.g.\n",
"# WORKSPACE = \"default\"\n",
"WORKSPACE = \"\"\n",
"\n",
Expand All @@ -163,9 +163,9 @@
" \"service_settings\": {\n",
" \"api_key\": API_KEY,\n",
" \"service_id\": \"ops-text-embedding-001\",\n",
" \"host\" : HOST,\n",
" \"workspace\" : WORKSPACE\n",
" }\n",
" \"host\": HOST,\n",
" \"workspace\": WORKSPACE,\n",
" },\n",
" },\n",
")\n",
"\n",
Expand All @@ -177,9 +177,9 @@
" \"service_settings\": {\n",
" \"api_key\": API_KEY,\n",
" \"service_id\": \"ops-text-sparse-embedding-001\",\n",
" \"host\" : HOST,\n",
" \"workspace\" : WORKSPACE\n",
" }\n",
" \"host\": HOST,\n",
" \"workspace\": WORKSPACE,\n",
" },\n",
" },\n",
")"
]
Expand Down Expand Up @@ -231,7 +231,7 @@
" \"output_field\": \"plot_sparse_embedding\",\n",
" },\n",
" }\n",
" }\n",
" },\n",
" ],\n",
")"
]
Expand Down Expand Up @@ -277,21 +277,17 @@
}
],
"source": [
"client.indices.delete(index=\"alibaba-text-embeddings-notebook-test\", ignore_unavailable=True)\n",
"client.indices.delete(\n",
" index=\"alibaba-text-embeddings-notebook-test\", ignore_unavailable=True\n",
")\n",
"client.indices.create(\n",
" index=\"alibaba-text-embeddings-notebook-test\",\n",
" settings={\"index\": {\"default_pipeline\": \"alibaba-embeddings-notebook-test\"}},\n",
" mappings={\n",
" \"properties\": {\n",
" \"plot\": {\"type\": \"text\"},\n",
" \"plot_embedding\": {\n",
" \"type\": \"dense_vector\",\n",
" \"dims\": 1536,\n",
" \"index\": \"true\"\n",
" },\n",
" \"plot_sparse_embedding\": {\n",
" \"type\":\"sparse_vector\"\n",
" }\n",
" \"plot_embedding\": {\"type\": \"dense_vector\", \"dims\": 1536, \"index\": \"true\"},\n",
" \"plot_sparse_embedding\": {\"type\": \"sparse_vector\"},\n",
" }\n",
" },\n",
")"
Expand Down Expand Up @@ -437,10 +433,10 @@
" query={\n",
" \"sparse_vector\": {\n",
" \"field\": \"plot_sparse_embedding\",\n",
" \"inference_id\":\"os-sparse-embeddings-notebook-test\",\n",
" \"query\":\"crime dynasty\"\n",
" \"inference_id\": \"os-sparse-embeddings-notebook-test\",\n",
" \"query\": \"crime dynasty\",\n",
" }\n",
" }\n",
" },\n",
")\n",
"\n",
"for hit in response[\"hits\"][\"hits\"]:\n",
Expand Down

0 comments on commit ba57b11

Please sign in to comment.