8000 Fix list[] -> List[] type hint for Python < 3.9 compatibility by bddppq · Pull Request #7 · jiggy-ai/hnsqlite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix list[] -> List[] type hint for Python < 3.9 compatibility #7

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions hnsqlite/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def vector_as_array(self) -> np.array:
"""
return np.frombuffer(self.vector, dtype=np.float32)

def vector_as_list(self) -> list[float]:
def vector_as_list(self) -> List[float]:
"""
return the stored vector as a numpy array
"""
Expand Down Expand Up @@ -126,7 +126,7 @@ class Embedding(BaseModel):
"""
An Embedding as sent to/from the Collection API
"""
vector: list[float] = Field(description='The user-supplied vector element as stored as a list of floats. Can be sent in as a numpy array and will be converted to a list of floats.')
vector: List[float] = Field(description='The user-supplied vector element as stored as a list of floats. Can be sent in as a numpy array and will be converted to a list of floats.')
text: str = Field(description="The text that was input to the model to generate this embedding.")
doc_id: Optional[str] = Field(description="An optional document_id associated with the embedding.")
metadata: Optional[dict] = Field(description="An optional dictionary of metadata associated with the text")
Expand Down Expand Up @@ -319,7 +319,7 @@ def make_index(self, M = 16, ef_construction = 200, delete_previous_index=True)
count = 0
BATCH_SIZE = CPU_COUNT*16
# batches process of embeddings for efficiency
def process_batch(batch : list[dbEmbedding]):
def process_batch(batch : List[dbEmbedding]):
# add batch of document embeddings to index
hnsw_ix.add_items([e.vector_as_array() for e in batch], [e.id for e in batch])
logger.info(f"hnsw_index.add_items vectors/sec: {count/(time() - t0):.1f} ; total vectors: {count}")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ authors = [
dependencies=['sqlmodel', 'hnswlib', 'psutil', 'numpy', 'loguru']
description = "A minimalist integration of sqlite and hnswlib focused on providing simple embedding persistence and search for text applications."
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
Expand Down
0