Skip to content

Commit

Permalink
Vec 229 aerospike 1.0 (#2)
Browse files Browse the repository at this point in the history
* feat: Update aerospike-vector-search client to 1.0.0

* fix: Remove unsupported options from ini_options

* rename metadatas to labels

---------

Co-authored-by: Jesse Schumacher <[email protected]>
  • Loading branch information
2 people authored and dwelch-spike committed Aug 23, 2024
1 parent 8170bd6 commit 8c2bc77
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions 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==0.6.1 langchain-community sentence-transformers langchain"
"!pip install --upgrade --quiet aerospike-vector-search==1.0.0 langchain-community sentence-transformers langchain"
]
},
{
Expand Down Expand Up @@ -401,7 +401,7 @@
" vector_field=VECTOR_KEY,\n",
" vector_distance_metric=MODEL_DISTANCE_CALC,\n",
" dimensions=MODEL_DIM,\n",
" index_meta_data={\n",
" index_labels={\n",
" \"model\": \"miniLM-L6-v2\",\n",
" \"date\": \"05/04/2024\",\n",
" \"dim\": str(MODEL_DIM),\n",
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],
metadatas: Optional[List[dict]] = None,
labels: Optional[List[dict[str, str]]] = 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.
metadatas: Optional list of metadatas associated with the texts.
labels: Optional list of labels 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 metadatas:
metadatas = [m.copy() for m in metadatas]
if labels:
labels = [m.copy() for m in labels]
else:
metadatas = metadatas or [{} for _ in texts]
labels = labels 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_metadatas = metadatas[i : i + embedding_chunk_size]
chunk_labels = labels[i : i + embedding_chunk_size]
embeddings = self._embed_documents(chunk_texts)

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

for id, metadata in zip(chunk_ids, chunk_metadatas):
for id, metadata in zip(chunk_ids, chunk_labels):
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,
metadatas: Optional[List[dict]] = None,
labels: 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,
metadatas=metadatas,
labels=labels,
ids=ids,
index_name=index_name,
embedding_chunk_size=embeddings_chunk_size,
Expand Down
3 changes: 1 addition & 2 deletions libs/community/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ select = [ "E", "F", "I", "T201",]
omit = [ "tests/*",]

[tool.pytest.ini_options]
addopts = "--strict-markers --strict-config --durations=5 --snapshot-warn-unused -vv"
addopts = "--strict-markers --strict-config --durations=5 -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
@@ -0,0 +1 @@
features.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ cluster:
# The Proximus service listening ports, TLS and network interface.
service:
ports:
5002: {}
# Uncomment for local debugging
advertised-listeners:
default:
address: 127.0.0.1
port: 5002
5002:
advertised-listeners:
default:
address: 127.0.0.1
port: 5002

# Management API listening ports, TLS and network interface.
manage:
Expand All @@ -24,13 +23,14 @@ interconnect:
5001: {}

# Target Aerospike cluster
aerospike:
storage:
seeds:
- aerospike:
port: 3000

# The logging properties.
logging:
enable-console-logging: true
file: "/etc/aerospike-vector-search/avs.log"
levels:
metrics-ticker: off
metrics-ticker: info
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace test {
}
}

namespace proximus-meta {
namespace avs-meta {
replication-factor 1
nsup-period 100

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ services:
command:
- "--config-file"
- "/opt/aerospike/etc/aerospike/aerospike.conf"
proximus:
image: aerospike/aerospike-proximus:0.4.0
avs:
image: aerospike/aerospike-vector-search:0.9.0
ports:
- "5002:5002"
networks:
- aerospike-test
volumes:
- .:/etc/aerospike-proximus
- .:/etc/aerospike-vector-search

networks:
aerospike-test: {}

0 comments on commit 8c2bc77

Please sign in to comment.