Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
duwenxin99 committed Sep 9, 2024
1 parent c14c60e commit ba607a2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test = [
"mypy==1.11.2",
"pytest-asyncio==0.24.0",
"pytest==8.3.2",
"pytest-cov==5.0.0"
"pytest-cov==5.0.0",
"Pillow==10.4.0"
]

Expand Down
23 changes: 12 additions & 11 deletions src/langchain_google_alloydb_pg/vectorstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ def _embedding_helper(
)
return embedding

def similarity_search(
def similarity_search( # type: ignore[override]
self,
query: Optional[str] = None,
image_uri: Optional[str] = None,
Expand All @@ -727,7 +727,7 @@ def similarity_search(
self.asimilarity_search(query, image_uri, k=k, filter=filter, **kwargs)
)

async def asimilarity_search(
async def asimilarity_search( # type: ignore[override]
self,
query: Optional[str] = None,
image_uri: Optional[str] = None,
Expand All @@ -752,7 +752,7 @@ def _select_relevance_score_fn(self) -> Callable[[float], float]:
elif self.distance_strategy == DistanceStrategy.EUCLIDEAN:
return self._euclidean_relevance_score_fn

async def asimilarity_search_with_score(
async def asimilarity_search_with_score( # type: ignore[override]
self,
query: Optional[str] = None,
image_uri: Optional[str] = None,
Expand Down Expand Up @@ -814,7 +814,7 @@ async def asimilarity_search_with_score_by_vector(

return documents_with_scores

async def _asimilarity_search_with_relevance_scores(
async def _asimilarity_search_with_relevance_scores( # type: ignore[override]
self,
query: Optional[str] = None,
image_uri: Optional[str] = None,
Expand All @@ -831,18 +831,19 @@ async def _asimilarity_search_with_relevance_scores(
k: Number of Documents to return. Defaults to 4.
**kwargs: kwargs to be passed to similarity search. Should include:
score_threshold: Optional, a floating point value between 0 to 1 to
filter the resulting set of retrieved docs
filter the resulting set of retrieved docs.
Returns:
List of Tuples of (doc, similarity_score)
"""
relevance_score_fn = self._select_relevance_score_fn()
docs_and_scores = await self.asimilarity_search_with_score(
query=query, image_uri=image_uri, k=k, **kwargs
)
return [(doc, relevance_score_fn(score)) for doc, score in docs_and_scores]

def _similarity_search_with_relevance_scores(
def _similarity_search_with_relevance_scores( # type: ignore[override]
self,
query: Optional[str] = None,
image_uri: Optional[str] = None,
Expand Down Expand Up @@ -870,7 +871,7 @@ def _similarity_search_with_relevance_scores(
)
return [(doc, relevance_score_fn(score)) for doc, score in docs_and_scores]

def similarity_search_with_relevance_scores(
def similarity_search_with_relevance_scores( # type: ignore[override]
self,
query: Optional[str] = None,
image_uri: Optional[str] = None,
Expand Down Expand Up @@ -918,7 +919,7 @@ def similarity_search_with_relevance_scores(
)
return docs_and_similarities

async def asimilarity_search_with_relevance_scores(
async def asimilarity_search_with_relevance_scores( # type: ignore[override]
self,
query: Optional[str] = None,
image_uri: Optional[str] = None,
Expand Down Expand Up @@ -966,7 +967,7 @@ async def asimilarity_search_with_relevance_scores(
)
return docs_and_similarities

async def amax_marginal_relevance_search(
async def amax_marginal_relevance_search( # type: ignore[override]
self,
query: Optional[str] = None,
image_uri: Optional[str] = None,
Expand Down Expand Up @@ -1057,7 +1058,7 @@ async def amax_marginal_relevance_search_with_score_by_vector(

return [r for i, r in enumerate(documents_with_scores) if i in mmr_selected]

def similarity_search_with_score(
def similarity_search_with_score( # type: ignore[override]
self,
query: Optional[str] = None,
image_uri: Optional[str] = None,
Expand Down Expand Up @@ -1095,7 +1096,7 @@ def similarity_search_with_score_by_vector(
)
return self.engine._run_as_sync(coro)

def max_marginal_relevance_search(
def max_marginal_relevance_search( # type: ignore[override]
self,
query: Optional[str] = None,
image_uri: Optional[str] = None,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_alloydb_vectorstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_env_var(key: str, desc: str) -> str:

class FakeImageEmbedding(DeterministicFakeEmbedding):

def embed_image(self, image_paths: List[str]):
def embed_image(self, image_paths: List[str]) -> List[List[float]]:
return [self.embed_query(path) for path in image_paths]


Expand Down
2 changes: 1 addition & 1 deletion tests/test_alloydb_vectorstore_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_env_var(key: str, desc: str) -> str:

class FakeImageEmbedding(DeterministicFakeEmbedding):

def embed_image(self, image_paths: List[str]):
def embed_image(self, image_paths: List[str]) -> List[List[float]]:
return [self.embed_query(path) for path in image_paths]


Expand Down

0 comments on commit ba607a2

Please sign in to comment.