Skip to content

Commit

Permalink
Update dependencies in pyproject.toml (#214)
Browse files Browse the repository at this point in the history
This pull request updates the dependencies in the `pyproject.toml` file.
Specifically, it adds the `simsimd` package with a version constraint of
`>=6.2.1,<7.0.0`.

---------

Signed-off-by: hsm207 <[email protected]>
  • Loading branch information
hsm207 authored Dec 9, 2024
1 parent 4c1cafa commit 170e4d9
Show file tree
Hide file tree
Showing 7 changed files with 2,094 additions and 1,800 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
.vscode
__pycache__
.coverage
dist
dist
.mypy_cache
.mypy_cache_test
2 changes: 1 addition & 1 deletion libs/weaviate/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TEST_FILE ?= tests/unit_tests/

integration_test integration_tests: TEST_FILE=tests/integration_tests/

test tests: update-weaviate-image
test tests:
poetry run pytest $(TEST_FILE) --cov=langchain_weaviate --cov-report term-missing --cov-fail-under=96.44

integration_test integration_tests: update-weaviate-image
Expand Down
10 changes: 4 additions & 6 deletions libs/weaviate/langchain_weaviate/vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ def __init__(
):
"""Initialize with Weaviate client."""

if not isinstance(client, weaviate.WeaviateClient):
raise ValueError(
"client should be an instance of"
f" weaviate.WeaviateClient, got {type(client)}"
)
self._client = client
self._index_name = index_name or f"LangChain_{uuid4().hex}"
self._embedding = embedding
Expand Down Expand Up @@ -428,7 +423,7 @@ def from_texts(
metadatas: Optional[List[dict]] = None,
*,
tenant: Optional[str] = None,
client: weaviate.WeaviateClient = None,
client: Optional[weaviate.WeaviateClient] = None,
index_name: Optional[str] = None,
text_key: str = "text",
relevance_score_fn: Optional[
Expand Down Expand Up @@ -474,6 +469,9 @@ def from_texts(

attributes = list(metadatas[0].keys()) if metadatas else None

if client is None:
raise ValueError("client must be an instance of WeaviateClient")

weaviate_vector_store = cls(
client,
index_name,
Expand Down
3,848 changes: 2,075 additions & 1,773 deletions libs/weaviate/poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libs/weaviate/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ python = ">=3.9,<4.0"
langchain-core = ">=0.1.33,<0.4"
weaviate-client = "^4.0.0"
numpy = "^1.26.2"
simsimd = ">=3.6.1,<5.0.0"
simsimd = ">=6.2.1,<7.0.0"

[tool.poetry.group.test]
optional = true
Expand Down
18 changes: 0 additions & 18 deletions libs/weaviate/tests/unit_tests/test_vectorstores_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,24 +611,6 @@ def test_search_with_multi_tenancy(
docsearch.similarity_search("foo", k=1)


def test_invalid_client_type() -> None:
with pytest.raises(ValueError) as excinfo:
invalid_client = "invalid_client"
index_name = "test_index"
text_key = "text"

WeaviateVectorStore(
client=invalid_client,
index_name=index_name,
text_key=text_key,
)

assert (
str(excinfo.value)
== "client should be an instance of weaviate.WeaviateClient, got <class 'str'>"
)


def test_embedding_property(
weaviate_client: Any, consistent_embedding: ConsistentFakeEmbeddings
) -> None:
Expand Down
10 changes: 10 additions & 0 deletions libs/weaviate/tests/unit_tests/test_vectorstores_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

from langchain_weaviate.vectorstores import (
WeaviateVectorStore,
_default_score_normalizer,
_json_serializable,
)
Expand All @@ -29,3 +30,12 @@ def test_json_serializable(
expected_result: Union[str, int, None],
) -> None:
assert _json_serializable(value) == expected_result


def test_from_texts_raises_value_error_when_client_is_none() -> None:
with pytest.raises(
ValueError, match="client must be an instance of WeaviateClient"
):
WeaviateVectorStore.from_texts(
texts=["sample text"], embedding=None, client=None
)

0 comments on commit 170e4d9

Please sign in to comment.