Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

langchain_community: Checking text property first in neo4j to avoid duplicate nodes #17381

Closed
wants to merge 9 commits into from
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
from __future__ import annotations

import enum
import logging
import os
import uuid
import hashlib
from typing import (
Any,
Callable,
Dict,
Iterable,
List,
Optional,
Tuple,
Type,
)

from langchain_core.documents import Document
from langchain_core.embeddings import Embeddings
from langchain_core.utils import get_from_env
from langchain_core.vectorstores import VectorStore

from langchain_community.vectorstores.utils import DistanceStrategy

DEFAULT_DISTANCE_STRATEGY = DistanceStrategy.COSINE

Check failure on line 26 in libs/community/langchain_community/vectorstores/neo4j_vector.py

View workflow job for this annotation

GitHub Actions / cd libs/community / - / make lint #3.8

Ruff (I001)

langchain_community/vectorstores/neo4j_vector.py:1:1: I001 Import block is un-sorted or un-formatted

Check failure on line 26 in libs/community/langchain_community/vectorstores/neo4j_vector.py

View workflow job for this annotation

GitHub Actions / cd libs/community / - / make lint #3.11

Ruff (I001)

langchain_community/vectorstores/neo4j_vector.py:1:1: I001 Import block is un-sorted or un-formatted
DISTANCE_MAPPING = {
DistanceStrategy.EUCLIDEAN_DISTANCE: "euclidean",
DistanceStrategy.COSINE: "cosine",
Expand Down Expand Up @@ -493,7 +494,8 @@
kwargs: vectorstore specific parameters
"""
if ids is None:
ids = [str(uuid.uuid1()) for _ in texts]
ids = [hashlib.sha256(text.encode('utf-8')).hexdigest()
for text in texts]

if not metadatas:
metadatas = [{} for _ in texts]
Expand Down
Loading