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

Vec 308 0.10.0 #4

Merged
merged 21 commits into from
Sep 11, 2024
Merged
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
2 changes: 1 addition & 1 deletion docs/docs/integrations/vectorstores/aerospike.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
},
"outputs": [],
"source": [
"!pip install --upgrade --quiet aerospike-vector-search==1.0.0 langchain-community sentence-transformers langchain"
"!pip install --upgrade --quiet aerospike-vector-search==2.0.0 langchain-community sentence-transformers langchain"
]
},
{
Expand Down
20 changes: 10 additions & 10 deletions libs/community/langchain_community/vectorstores/aerospike.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def convert_distance_strategy(
def add_texts(
self,
texts: Iterable[str],
labels: Optional[List[dict[str, str]]] = None,
metadatas: Optional[List[dict]] = None,
ids: Optional[List[str]] = None,
set_name: Optional[str] = None,
embedding_chunk_size: int = 1000,
Expand All @@ -168,7 +168,7 @@ def add_texts(

Args:
texts: Iterable of strings to add to the vectorstore.
labels: Optional list of labels associated with the texts.
metadatas: Optional list of metadata associated with the texts.
ids: Optional list of ids to associate with the texts.
set_name: Optional aerospike set name to add the texts to.
batch_size: Batch size to use when adding the texts to the vectorstore.
Expand Down Expand Up @@ -197,24 +197,24 @@ def add_texts(
ids = ids or [str(uuid.uuid4()) for _ in texts]

# We need to shallow copy so that we can add the vector and text keys
if labels:
labels = [m.copy() for m in labels]
if metadatas:
metadatas = [m.copy() for m in metadatas]
else:
labels = labels or [{} for _ in texts]
metadatas = metadatas or [{} for _ in texts]

for i in range(0, len(texts), embedding_chunk_size):
chunk_texts = texts[i : i + embedding_chunk_size]
chunk_ids = ids[i : i + embedding_chunk_size]
chunk_labels = labels[i : i + embedding_chunk_size]
chunk_metadatas = metadatas[i : i + embedding_chunk_size]
embeddings = self._embed_documents(chunk_texts)

for metadata, embedding, text in zip(
chunk_labels, embeddings, chunk_texts
chunk_metadatas, embeddings, chunk_texts
):
metadata[self._vector_key] = embedding
metadata[self._text_key] = text

for id, metadata in zip(chunk_ids, chunk_labels):
for id, metadata in zip(chunk_ids, chunk_metadatas):
metadata[self._id_key] = id
self._client.upsert(
namespace=self._namespace,
Expand Down Expand Up @@ -545,7 +545,7 @@ def from_texts(
cls,
texts: List[str],
embedding: Embeddings,
labels: Optional[List[dict]] = None,
metadatas: Optional[List[dict]] = None,
client: Client = None,
namespace: str = "test",
index_name: Optional[str] = None,
Expand Down Expand Up @@ -589,7 +589,7 @@ def from_texts(

aerospike.add_texts(
texts,
labels=labels,
metadatas=metadatas,
ids=ids,
index_name=index_name,
embedding_chunk_size=embeddings_chunk_size,
Expand Down
3 changes: 2 additions & 1 deletion libs/community/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ select = [ "E", "F", "I", "T201",]
omit = [ "tests/*",]

[tool.pytest.ini_options]
addopts = "--strict-markers --strict-config --durations=5 -vv"
addopts = "--strict-markers --strict-config --durations=5 --snapshot-warn-unused -vv"
markers = [ "requires: mark tests as requiring a specific library", "scheduled: mark tests to run in scheduled testing", "compile: mark placeholder test used to compile integration tests without running them",]
asyncio_mode = "auto"

[tool.poetry.group.test]
optional = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
- "--config-file"
- "/opt/aerospike/etc/aerospike/aerospike.conf"
avs:
image: aerospike/aerospike-vector-search:0.9.0
image: aerospike/aerospike-vector-search:0.10.0
ports:
- "5002:5002"
networks:
Expand Down
Loading