Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 24 additions & 25 deletions examples/pg_vectorstore.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "irl7eMFnSPZr",
"metadata": {
"id": "irl7eMFnSPZr"
Expand All @@ -90,7 +90,7 @@
"POSTGRES_PORT = \"6024\" # @param {type: \"string\"}\n",
"POSTGRES_DB = \"langchain\" # @param {type: \"string\"}\n",
"TABLE_NAME = \"vectorstore\" # @param {type: \"string\"}\n",
"VECTOR_SIZE = 768 # @param {type: \"int\"}"
"VECTOR_SIZE = 1024 # @param {type: \"int\"}"
]
},
{
Expand Down Expand Up @@ -118,7 +118,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -132,13 +132,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"from langchain_postgres import PGEngine\n",
"\n",
"engine = PGEngine.from_connection_string(url=CONNECTION_STRING)"
"pg_engine = PGEngine.from_connection_string(url=CONNECTION_STRING)"
]
},
{
Expand All @@ -152,7 +152,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -178,13 +178,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {
"id": "avlyHEMn6gzU"
},
"outputs": [],
"source": [
"await engine.ainit_vectorstore_table(\n",
"await pg_engine.ainit_vectorstore_table(\n",
" table_name=TABLE_NAME,\n",
" vector_size=VECTOR_SIZE,\n",
")"
Expand All @@ -200,7 +200,7 @@
"```python\n",
"SCHEMA_NAME=\"my_schema\"\n",
"\n",
"await engine.ainit_vectorstore_table(\n",
"await pg_engine.ainit_vectorstore_table(\n",
" table_name=TABLE_NAME,\n",
" vector_size=768,\n",
" schema_name=SCHEMA_NAME, # Default: \"public\"\n",
Expand All @@ -219,7 +219,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
Expand All @@ -231,7 +231,7 @@
"source": [
"from langchain_cohere import CohereEmbeddings\n",
"\n",
"embedding = CohereEmbeddings()"
"embedding = CohereEmbeddings(model=\"embed-english-v3.0\")"
]
},
{
Expand All @@ -245,7 +245,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {
"id": "z-AZyzAQ7bsf"
},
Expand All @@ -254,7 +254,7 @@
"from langchain_postgres import PGVectorStore\n",
"\n",
"store = await PGVectorStore.create(\n",
" engine=engine,\n",
" engine=pg_engine,\n",
" table_name=TABLE_NAME,\n",
" # schema_name=SCHEMA_NAME,\n",
" embedding_service=embedding,\n",
Expand All @@ -272,7 +272,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -298,10 +298,9 @@
"store_with_documents = await PGVectorStore.afrom_documents(\n",
" documents=docs,\n",
" ids=ids,\n",
" engine=engine,\n",
" engine=pg_engine,\n",
" table_name=TABLE_NAME,\n",
" # schema_name=SCHEMA_NAME,\n",
" embedding_service=embedding,\n",
" embedding=embedding,\n",
")"
]
},
Expand Down Expand Up @@ -389,7 +388,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -408,7 +407,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -424,7 +423,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -444,7 +443,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -454,7 +453,7 @@
"TABLE_NAME = \"vectorstore_custom\"\n",
"# SCHEMA_NAME = \"my_schema\"\n",
"\n",
"await engine.ainit_vectorstore_table(\n",
"await pg_engine.ainit_vectorstore_table(\n",
" table_name=TABLE_NAME,\n",
" # schema_name=SCHEMA_NAME,\n",
" vector_size=VECTOR_SIZE,\n",
Expand All @@ -464,7 +463,7 @@
"\n",
"# Initialize PGVectorStore\n",
"custom_store = await PGVectorStore.create(\n",
" engine=engine,\n",
" engine=pg_engine,\n",
" table_name=TABLE_NAME,\n",
" # schema_name=SCHEMA_NAME,\n",
" embedding_service=embedding,\n",
Expand Down Expand Up @@ -578,7 +577,7 @@
"\n",
"# Initialize PGVectorStore\n",
"custom_store = await PGVectorStore.create(\n",
" engine=engine,\n",
" engine=pg_engine,\n",
" table_name=TABLE_NAME,\n",
" # schema_name=SCHEMA_NAME,\n",
" embedding_service=embedding,\n",
Expand Down Expand Up @@ -685,7 +684,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
"version": "3.12.8"
}
},
"nbformat": 4,
Expand Down