From 1bb3a4ccba0808b9c4c96d177887acb444b8c949 Mon Sep 17 00:00:00 2001 From: "shanhaikang.shk" Date: Mon, 6 Jan 2025 10:52:37 +0800 Subject: [PATCH] update example notebook Signed-off-by: shanhaikang.shk --- docs/vectorstores.ipynb | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/docs/vectorstores.ipynb b/docs/vectorstores.ipynb index 460d186..bb2db82 100644 --- a/docs/vectorstores.ipynb +++ b/docs/vectorstores.ipynb @@ -31,9 +31,11 @@ ] }, { - "cell_type": "raw", + "cell_type": "code", + "execution_count": null, "id": "a7b92118", "metadata": {}, + "outputs": [], "source": [ "%docker run --name=ob433 -e MODE=mini -e OB_SERVER_IP=127.0.0.1 -p 2881:2881 -d quay.io/oceanbase/oceanbase-ce:4.3.3.1-101000012024102216" ] @@ -47,13 +49,11 @@ ] }, { - "cell_type": "raw", + "cell_type": "code", + "execution_count": null, "id": "64e28aa6", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, + "metadata": {}, + "outputs": [], "source": [ "%pip install -qU \"langchain-oceanbase\"" ] @@ -118,7 +118,9 @@ "outputs": [], "source": [ "import os\n", + "\n", "from langchain_community.embeddings import DashScopeEmbeddings\n", + "\n", "from langchain_oceanbase.vectorstores import OceanbaseVectorStore\n", "\n", "DASHSCOPE_API = os.environ.get(\"DASHSCOPE_API_KEY\", \"\")\n", @@ -276,9 +278,7 @@ } ], "source": [ - "results = vector_store.similarity_search(query=\"thud\",k=1,filter={\"source\":\"https://another-example.com\"})\n", - "for doc in results:\n", - " print(f\"* {doc.page_content} [{doc.metadata}]\")" + "results = vector_store.similarity_search(query=\"thud\",k=1,filter={\"source\":\"https://another-example.com\"})" ] }, { @@ -304,9 +304,7 @@ } ], "source": [ - "results = vector_store.similarity_search_with_score(query=\"thud\",k=1,filter={\"source\":\"https://example.com\"})\n", - "for doc, score in results:\n", - " print(f\"* [SIM={score:3f}] {doc.page_content} [{doc.metadata}]\")" + "results = vector_store.similarity_search_with_score(query=\"thud\",k=1,filter={\"source\":\"https://example.com\"})" ] }, {