Skip to content
Merged
Show file tree
Hide file tree
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
43 changes: 41 additions & 2 deletions docs/vector_store.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,49 @@
"all_texts = [\"Apples and oranges\", \"Cars and airplanes\", \"Pineapple\", \"Train\", \"Banana\"]\n",
"metadatas = [{\"len\": len(t)} for t in all_texts]\n",
"ids = [str(uuid.uuid4()) for _ in all_texts]\n",
"await custom_store.aadd_texts(all_texts, metadatas=metadatas, ids=ids)\n",
"await custom_store.aadd_texts(all_texts, metadatas=metadatas, ids=ids)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### For v0.15.0+\n",
"\n",
"**Important Update:** Support for string filters has been deprecated. Please use dictionaries to add filters."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Use filter on search\n",
"docs = await custom_store.asimilarity_search_by_vector(\n",
" query_vector, filter={\"len\": {\"$gte\": 6}}\n",
")\n",
"\n",
"print(docs)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### For v0.14 and under\n",
"\n",
"You can make use of the string filters to filter on metadata"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Use filter on search\n",
"docs = await custom_store.asimilarity_search_by_vector(query_vector, filter=\"len >= 6\")\n",
"docs = await custom_store.asimilarity_search(query, filter=\"len >= 6\")\n",
"\n",
"print(docs)"
]
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ authors = [

dependencies = [
"cloud-sql-python-connector[asyncpg] >= 1.10.0, <2.0.0",
"langchain-core>=0.2.36, <1.0.0 ",
"numpy>=1.24.4, <3.0.0; python_version >= '3.11'",
"numpy>=1.24.4, <=2.2.6; python_version == '3.10'",
"numpy>=1.24.4, <=2.0.2; python_version <= '3.9'",
"SQLAlchemy[asyncio]>=2.0.25, <3.0.0",
"langchain-postgres>=0.0.15",
]

Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
cloud-sql-python-connector[asyncpg]==1.18.2
langchain-core==0.3.68
numpy==2.3.1; python_version >= "3.11"
numpy==2.2.6; python_version == "3.10"
numpy==2.0.2; python_version <= "3.9"
SQLAlchemy[asyncio]==2.0.41
langgraph==0.6.0
langchain-postgres==0.0.15
8 changes: 8 additions & 0 deletions src/langchain_google_cloud_sql_pg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
# limitations under the License.

from langchain_postgres import Column
from langchain_postgres.v2.hybrid_search_config import (
HybridSearchConfig,
reciprocal_rank_fusion,
weighted_sum_ranking,
)

from . import indexes
from .chat_message_history import PostgresChatMessageHistory
Expand All @@ -31,5 +36,8 @@
"PostgresLoader",
"PostgresDocumentSaver",
"PostgresSaver",
"HybridSearchConfig",
"reciprocal_rank_fusion",
"weighted_sum_ranking",
"__version__",
]
Loading