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

multivector support #45

Merged
merged 7 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion python/starpoint/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def query(
sql=sql,
collection_id=collection_id,
collection_name=collection_name,
query_embedding=query_embedding,
query_embeddings=query_embedding,
params=params,
text_search_query=text_search_query,
text_search_weight=text_search_weight,
Expand Down
4 changes: 2 additions & 2 deletions python/starpoint/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def query(
sql: Optional[str] = None,
collection_id: Optional[str] = None,
collection_name: Optional[str] = None,
query_embedding: Optional[List[float]] = None,
query_embeddings: Optional[Dict[Any, Any]] = None,
DuongTyler marked this conversation as resolved.
Show resolved Hide resolved
params: Optional[List[Any]] = None,
text_search_query: Optional[List[str]] = None,
text_search_weight: Optional[float] = None,
Expand Down Expand Up @@ -91,7 +91,7 @@ def query(
request_data = dict(
collection_id=collection_id,
collection_name=collection_name,
query_embedding=query_embedding,
query_embeddings=query_embeddings,
sql=sql,
params=params,
text_search_query=text_search_query,
Expand Down
53 changes: 4 additions & 49 deletions python/starpoint/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,51 +100,6 @@ def delete(
return {}
return response.json()

def column_delete(
self,
embeddings: List[List[float]],
document_metadatas: List[Dict[Any, Any]],
collection_id: Optional[str] = None,
collection_name: Optional[str] = None,
) -> Dict[Any, Any]:
"""Deletes documents from an existing collection by embedding and document metadata arrays.
The arrays are zipped together and updates the document in the order of the two arrays.

Args:
embeddings: A list of embeddings.
Order of the embeddings should match the document_metadatas.
document_metadatas: A list of metadata to be associated with embeddings.
Order of these metadatas should match the embeddings.
collection_id: The collection's id where the documents will be deleted.
This or the `collection_name` needs to be provided.
collection_name: The collection's name where the documents will be deleted.
This or the `collection_id` needs to be provided.

Returns:
dict: delete response json

Raises:
ValueError: If neither collection id and collection name are provided.
ValueError: If both collection id and collection name are provided.
requests.exceptions.SSLError: Failure likely due to network issues.
"""
if len(embeddings) != len(document_metadatas):
LOGGER.warning(EMBEDDING_METADATA_LENGTH_MISMATCH_WARNING)

documents = [
{
"embedding": embedding,
"metadata": document_metadata,
}
for embedding, document_metadata in zip(embeddings, document_metadatas)
]

return self.delete(
documents=documents,
collection_id=collection_id,
collection_name=collection_name,
)

def insert(
self,
documents: List[Dict[Any, Any]],
Expand Down Expand Up @@ -214,7 +169,7 @@ def insert(

def column_insert(
self,
embeddings: List[List[float]],
embeddings: List[Dict[Any, Any]],
document_metadatas: List[Dict[Any, Any]],
collection_id: Optional[str] = None,
collection_name: Optional[str] = None,
Expand Down Expand Up @@ -245,7 +200,7 @@ def column_insert(

documents = [
{
"embedding": embedding,
"embeddings": embedding,
"metadata": document_metadata,
}
for embedding, document_metadata in zip(embeddings, document_metadatas)
Expand Down Expand Up @@ -325,7 +280,7 @@ def update(

def column_update(
self,
embeddings: List[List[float]],
embeddings: List[Dict[Any, Any]],
document_metadatas: List[Dict[Any, Any]],
collection_id: Optional[str] = None,
collection_name: Optional[str] = None,
Expand Down Expand Up @@ -356,7 +311,7 @@ def column_update(

documents = [
{
"embedding": embedding,
"embeddings": embedding,
"metadata": document_metadata,
}
for embedding, document_metadata in zip(embeddings, document_metadatas)
Expand Down
Loading