Update the milvus example (#4706)

# Fix issue when running example

- add the query content
- update the `user` parameter with Zilliz

Signed-off-by: shiyu22 <shiyu.chen@zilliz.com>
This commit is contained in:
shiyu22 2023-05-16 07:16:57 +08:00 committed by GitHub
parent 7d15669b41
commit 21b9397342
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 70 additions and 22 deletions

View File

@ -43,10 +43,10 @@
},
"outputs": [
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"OpenAI API Key: ········\n"
"OpenAI API Key:········\n"
]
}
],
@ -59,7 +59,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"id": "aac9563e",
"metadata": {
"tags": []
@ -74,7 +74,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"id": "a3c3999a",
"metadata": {
"tags": []
@ -92,7 +92,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "dcf88bdf",
"metadata": {
"tags": []
@ -108,23 +108,43 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"id": "a8c513ab",
"metadata": {},
"outputs": [],
"source": [
"query = \"What did the president say about Ketanji Brown Jackson\"\n",
"docs = vector_db.similarity_search(query)"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"id": "fc516993",
"metadata": {},
"outputs": [],
"source": [
"docs[0]"
"outputs": [
{
"data": {
"text/plain": [
"'Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while youre at it, pass the Disclose Act so Americans can know who is funding our elections. \\n\\nTonight, Id like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer—an Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your service. \\n\\nOne of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court. \\n\\nAnd I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nations top legal minds, who will continue Justice Breyers legacy of excellence.'"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"docs[0].page_content"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e40d558b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
@ -143,7 +163,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
"version": "3.9.12"
}
},
"nbformat": 4,

View File

@ -36,10 +36,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "d6691489-1ebc-40fa-bc09-b0916903a24d",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"OpenAI API Key:········\n"
]
}
],
"source": [
"import os\n",
"import getpass\n",
@ -49,7 +57,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "19a71422",
"metadata": {},
"outputs": [],
@ -62,7 +70,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"id": "aac9563e",
"metadata": {},
"outputs": [],
@ -75,7 +83,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "a3c3999a",
"metadata": {},
"outputs": [],
@ -91,7 +99,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"id": "dcf88bdf",
"metadata": {},
"outputs": [],
@ -101,7 +109,7 @@
" embeddings,\n",
" connection_args={\n",
" \"uri\": ZILLIZ_CLOUD_URI,\n",
" \"username\": ZILLIZ_CLOUD_USERNAME,\n",
" \"user\": ZILLIZ_CLOUD_USERNAME,\n",
" \"password\": ZILLIZ_CLOUD_PASSWORD,\n",
" \"secure\": True\n",
" }\n",
@ -110,23 +118,43 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"id": "a8c513ab",
"metadata": {},
"outputs": [],
"source": [
"query = \"What did the president say about Ketanji Brown Jackson\"\n",
"docs = vector_db.similarity_search(query)"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"id": "fc516993",
"metadata": {},
"outputs": [],
"source": [
"docs[0]"
"outputs": [
{
"data": {
"text/plain": [
"'Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while youre at it, pass the Disclose Act so Americans can know who is funding our elections. \\n\\nTonight, Id like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer—an Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your service. \\n\\nOne of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court. \\n\\nAnd I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nations top legal minds, who will continue Justice Breyers legacy of excellence.'"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"docs[0].page_content"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dc85398b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
@ -145,7 +173,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.6"
"version": "3.9.12"
}
},
"nbformat": 4,