Skip to content
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
4 changes: 2 additions & 2 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,10 @@ The JSON configuration file may hold the following values:
queries. **It's recommended to re-vectorise the collection after modifying these
options, because some of the options can only be set during collection
creation.** Example:
```json
```json5
// the following is the default value.
"hnsw": {
"hnsw:M": 64,
"hnsw:construction_ef": 100
}
```
- `filetype_map`: `dict[str, list[str]]`, a dictionary where keys are
Expand Down
1 change: 1 addition & 0 deletions src/vectorcode/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ async def get_collection(
"USER", os.environ.get("USERNAME", "DEFAULT_USER")
),
"embedding_function": configs.embedding_function,
"hnsw:M": 64,
}
if configs.hnsw:
for key in configs.hnsw.keys():
Expand Down
21 changes: 17 additions & 4 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,19 @@ async def test_get_collection():
),
"created-by": "VectorCode",
}
mock_client.get_or_create_collection.return_value = mock_collection

async def mock_get_or_create_collection(
self,
name=None,
configuration=None,
metadata=None,
embedding_function=None,
data_loader=None,
):
mock_collection.metadata.update(metadata or {})
return mock_collection

mock_client.get_or_create_collection.side_effect = mock_get_or_create_collection
MockAsyncHttpClient.return_value = mock_client

collection = await get_collection(mock_client, config, make_if_missing=True)
Expand All @@ -336,6 +348,7 @@ async def test_get_collection():
"USER", os.environ.get("USERNAME", "DEFAULT_USER")
)
assert collection.metadata["created-by"] == "VectorCode"
assert collection.metadata["hnsw:M"] == 64
mock_client.get_or_create_collection.assert_called_once()
mock_client.get_collection.side_effect = None

Expand All @@ -361,7 +374,7 @@ async def test_get_collection_hnsw():
embedding_function="SentenceTransformerEmbeddingFunction",
embedding_params={},
project_root="/test_project",
hnsw={"ef_construction": 200, "m": 32},
hnsw={"ef_construction": 200, "M": 32},
)

with patch("chromadb.AsyncHttpClient") as MockAsyncHttpClient:
Expand All @@ -374,7 +387,7 @@ async def test_get_collection_hnsw():
),
"created-by": "VectorCode",
"hnsw:ef_construction": 200,
"hnsw:m": 32,
"hnsw:M": 32,
"embedding_function": "SentenceTransformerEmbeddingFunction",
"path": "/test_project",
}
Expand All @@ -394,7 +407,7 @@ async def test_get_collection_hnsw():
)
assert collection.metadata["created-by"] == "VectorCode"
assert collection.metadata["hnsw:ef_construction"] == 200
assert collection.metadata["hnsw:m"] == 32
assert collection.metadata["hnsw:M"] == 32
mock_client.get_or_create_collection.assert_called_once()
assert (
mock_client.get_or_create_collection.call_args.kwargs["metadata"]
Expand Down