Skip to content
Snippets Groups Projects
Commit da1ff80e authored by hananel's avatar hananel
Browse files

make all type hints lowercase

parent df4a3a8b
No related branches found
No related tags found
No related merge requests found
from typing import Any, List, Optional from typing import Any, Optional
import numpy as np import numpy as np
from pydantic import PrivateAttr from pydantic import PrivateAttr
...@@ -44,8 +44,8 @@ class FastEmbedEncoder(BaseEncoder): ...@@ -44,8 +44,8 @@ class FastEmbedEncoder(BaseEncoder):
def __call__(self, docs: list[str]) -> list[list[float]]: def __call__(self, docs: list[str]) -> list[list[float]]:
try: try:
embeds: List[np.ndarray] = list(self._client.embed(docs)) embeds: list[np.ndarray] = list(self._client.embed(docs))
embeddings: List[List[float]] = [e.tolist() for e in embeds] embeddings: list[list[float]] = [e.tolist() for e in embeds]
return embeddings return embeddings
except Exception as e: except Exception as e:
raise ValueError(f"FastEmbed embed failed. Error: {e}") raise ValueError(f"FastEmbed embed failed. Error: {e}")
from typing import Tuple
import numpy as np import numpy as np
from numpy.linalg import norm from numpy.linalg import norm
...@@ -21,7 +19,7 @@ def similarity_matrix(xq: np.ndarray, index: np.ndarray) -> np.ndarray: ...@@ -21,7 +19,7 @@ def similarity_matrix(xq: np.ndarray, index: np.ndarray) -> np.ndarray:
return sim return sim
def top_scores(sim: np.ndarray, top_k: int = 5) -> Tuple[np.ndarray, np.ndarray]: def top_scores(sim: np.ndarray, top_k: int = 5) -> tuple[np.ndarray, np.ndarray]:
# get indices of top_k records # get indices of top_k records
top_k = min(top_k, sim.shape[0]) top_k = min(top_k, sim.shape[0])
idx = np.argpartition(sim, -top_k)[-top_k:] idx = np.argpartition(sim, -top_k)[-top_k:]
......
...@@ -26,7 +26,7 @@ def semantic_splitter( ...@@ -26,7 +26,7 @@ def semantic_splitter(
split_method (str): The method to use for splitting. split_method (str): The method to use for splitting.
Returns: Returns:
Dict[str, list[str]]: Splits with corresponding documents. dict[str, list[str]]: Splits with corresponding documents.
""" """
total_docs = len(docs) total_docs = len(docs)
splits = {} splits = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment