Skip to content

Commit f7adf58

Browse files
docs: Add documentation on how to contribute a Vector DB provider and update testing documentation (#3093)
# What does this PR do? - Adds documentation on how to contribute a Vector DB provider. - Updates the testing section to be a little friendlier to navigate. - Also added new shortcut for search so that `/` and `⌘ K` or `ctrl+K` trigger search <img width="1903" height="1346" alt="Screenshot 2025-08-11 at 10 10 12 AM" src="https://github.com/user-attachments/assets/6995b3b8-a2ab-4200-be72-c5b03a784a29" /> <img width="1915" height="1438" alt="Screenshot 2025-08-11 at 10 10 25 AM" src="https://github.com/user-attachments/assets/1f54d30e-5be1-4f27-b1e9-3c3537dcb8e9" /> <!-- If resolving an issue, uncomment and update the line below --> <!-- Closes #[issue-number] --> ## Test Plan <!-- Describe the tests you ran to verify your changes with result summaries. *Provide clear instructions so the plan can be easily re-executed.* --> Signed-off-by: Francisco Javier Arceo <[email protected]>
1 parent b5b5f5b commit f7adf58

File tree

5 files changed

+113
-7
lines changed

5 files changed

+113
-7
lines changed

docs/_static/js/keyboard_shortcuts.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
document.addEventListener('keydown', function(event) {
2+
// command+K or ctrl+K
3+
if ((event.metaKey || event.ctrlKey) && event.key === 'k') {
4+
event.preventDefault();
5+
document.querySelector('.search-input, .search-field, input[name="q"]').focus();
6+
}
7+
8+
// forward slash
9+
if (event.key === '/' &&
10+
!event.target.matches('input, textarea, select')) {
11+
event.preventDefault();
12+
document.querySelector('.search-input, .search-field, input[name="q"]').focus();
13+
}
14+
});

docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
def setup(app):
132132
app.add_css_file("css/my_theme.css")
133133
app.add_js_file("js/detect_theme.js")
134+
app.add_js_file("js/keyboard_shortcuts.js")
134135

135136
def dockerhub_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
136137
url = f"https://hub.docker.com/r/llamastack/{text}"

docs/source/contributing/index.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,28 @@
22
```{include} ../../../CONTRIBUTING.md
33
```
44

5-
See the [Adding a New API Provider](new_api_provider.md) which describes how to add new API providers to the Stack.
5+
## Testing
66

7+
See the [Test Page](testing.md) which describes how to test your changes.
8+
```{toctree}
9+
:maxdepth: 1
10+
:hidden:
11+
:caption: Testing
712
13+
testing
14+
```
815

16+
## Adding a New Provider
17+
18+
See the [Adding a New API Provider Page](new_api_provider.md) which describes how to add new API providers to the Stack.
19+
20+
See the [Vector Database Page](new_vector_database.md) which describes how to add a new vector databases with Llama Stack.
21+
22+
See the [External Provider Page](../providers/external/index.md) which describes how to add external providers to the Stack.
923
```{toctree}
1024
:maxdepth: 1
1125
:hidden:
1226
1327
new_api_provider
14-
testing
28+
new_vector_database
1529
```
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Adding a New Vector Database
2+
3+
This guide will walk you through the process of adding a new vector database to Llama Stack.
4+
5+
> **_NOTE:_** Here's an example Pull Request of the [Milvus Vector Database Provider](https://github.com/meta-llama/llama-stack/pull/1467).
6+
7+
Vector Database providers are used to store and retrieve vector embeddings. Vector databases are not limited to vector
8+
search but can support keyword and hybrid search. Additionally, vector database can also support operations like
9+
filtering, sorting, and aggregating vectors.
10+
11+
## Steps to Add a New Vector Database Provider
12+
1. **Choose the Database Type**: Determine if your vector database is a remote service, inline, or both.
13+
- Remote databases make requests to external services, while inline databases execute locally. Some providers support both.
14+
2. **Implement the Provider**: Create a new provider class that inherits from `VectorDatabaseProvider` and implements the required methods.
15+
- Implement methods for vector storage, retrieval, search, and any additional features your database supports.
16+
- You will need to implement the following methods for `YourVectorIndex`:
17+
- `YourVectorIndex.create()`
18+
- `YourVectorIndex.initialize()`
19+
- `YourVectorIndex.add_chunks()`
20+
- `YourVectorIndex.delete_chunk()`
21+
- `YourVectorIndex.query_vector()`
22+
- `YourVectorIndex.query_keyword()`
23+
- `YourVectorIndex.query_hybrid()`
24+
- You will need to implement the following methods for `YourVectorIOAdapter`:
25+
- `YourVectorIOAdapter.initialize()`
26+
- `YourVectorIOAdapter.shutdown()`
27+
- `YourVectorIOAdapter.list_vector_dbs()`
28+
- `YourVectorIOAdapter.register_vector_db()`
29+
- `YourVectorIOAdapter.unregister_vector_db()`
30+
- `YourVectorIOAdapter.insert_chunks()`
31+
- `YourVectorIOAdapter.query_chunks()`
32+
- `YourVectorIOAdapter.delete_chunks()`
33+
3. **Add to Registry**: Register your provider in the appropriate registry file.
34+
- Update {repopath}`llama_stack/providers/registry/vector_io.py` to include your new provider.
35+
```python
36+
from llama_stack.providers.registry.specs import InlineProviderSpec
37+
from llama_stack.providers.registry.api import Api
38+
39+
InlineProviderSpec(
40+
api=Api.vector_io,
41+
provider_type="inline::milvus",
42+
pip_packages=["pymilvus>=2.4.10"],
43+
module="llama_stack.providers.inline.vector_io.milvus",
44+
config_class="llama_stack.providers.inline.vector_io.milvus.MilvusVectorIOConfig",
45+
api_dependencies=[Api.inference],
46+
optional_api_dependencies=[Api.files],
47+
description="",
48+
),
49+
```
50+
4. **Add Tests**: Create unit tests and integration tests for your provider in the `tests/` directory.
51+
- Unit Tests
52+
- By following the structure of the class methods, you will be able to easily run unit and integration tests for your database.
53+
1. You have to configure the tests for your provide in `/tests/unit/providers/vector_io/conftest.py`.
54+
2. Update the `vector_provider` fixture to include your provider if they are an inline provider.
55+
3. Create a `your_vectorprovider_index` fixture that initializes your vector index.
56+
4. Create a `your_vectorprovider_adapter` fixture that initializes your vector adapter.
57+
5. Add your provider to the `vector_io_providers` fixture dictionary.
58+
- Please follow the naming convention of `your_vectorprovider_index` and `your_vectorprovider_adapter` as the tests require this to execute properly.
59+
- Integration Tests
60+
- Integration tests are located in {repopath}`tests/integration`. These tests use the python client-SDK APIs (from the `llama_stack_client` package) to test functionality.
61+
- The two set of integration tests are:
62+
- `tests/integration/vector_io/test_vector_io.py`: This file tests registration, insertion, and retrieval.
63+
- `tests/integration/vector_io/test_openai_vector_stores.py`: These tests are for OpenAI-compatible vector stores and test the OpenAI API compatibility.
64+
- You will need to update `skip_if_provider_doesnt_support_openai_vector_stores` to include your provider as well as `skip_if_provider_doesnt_support_openai_vector_stores_search` to test the appropriate search functionality.
65+
- Running the tests in the GitHub CI
66+
- You will need to update the `.github/workflows/integration-vector-io-tests.yml` file to include your provider.
67+
- If your provider is a remote provider, you will also have to add a container to spin up and run it in the action.
68+
- Updating the pyproject.yml
69+
- If you are adding tests for the `inline` provider you will have to update the `unit` group.
70+
- `uv add new_pip_package --group unit`
71+
- If you are adding tests for the `remote` provider you will have to update the `test` group, which is used in the GitHub CI for integration tests.
72+
- `uv add new_pip_package --group test`
73+
5. **Update Documentation**: Please update the documentation for end users
74+
- Generate the provider documentation by running {repopath}`./scripts/provider_codegen.py`.
75+
- Update the autogenerated content in the registry/vector_io.py file with information about your provider. Please see other providers for examples.

docs/source/contributing/testing.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# Testing Llama Stack
1+
```{include} ../../../tests/README.md
2+
```
23

3-
Tests are of three different kinds:
4-
- Unit tests
5-
- Provider focused integration tests
6-
- Client SDK tests
4+
```{include} ../../../tests/unit/README.md
5+
```
6+
7+
```{include} ../../../tests/integration/README.md
8+
```

0 commit comments

Comments
 (0)