Skip to content

Commit d134ae2

Browse files
author
Zhe Yu
committed
docs(database): Document helper methods and error handling in the database API
1 parent 18e7b0c commit d134ae2

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/vectorcode/database/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ When implementing the abstract methods from `DatabaseConnectorBase`, you should:
4545
- Perform the corresponding operation against the database.
4646
- Return data in the format specified by the method's type hints (e.g., `QueryResult`, `CollectionInfo`).
4747

48-
**Please refer to the docstrings in `DatabaseConnectorBase` for the specific API contract of each method.** They contain detailed information about what each method is expected to do and what parameters it uses from the `Config` object.
48+
**Please refer to the docstrings in `DatabaseConnectorBase` for the specific API contract of each method.**
49+
They contain detailed information about what each method is expected to do and what parameters it uses from the `Config` object.
50+
51+
There are also some helper methods (non-abstract methods) in `DatabaseConnectorBase` that may be
52+
helpful.
53+
For example, `self.get_embedding(texts)` provides a convenient way to get the embeddings of some strings that takes all config parameters into account (embedding function, embedding dimension, etc.).
54+
Using these methods helps keeping your implementation consistent with the overall design.
4955

5056
## Error Handling
5157

src/vectorcode/database/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
2828
You should also try to wrap the exceptions with the ones in
2929
`src/vectorcode/database/errors.py` where appropriate, because this helps the
30-
CLI/LSP/MCP interfaces to handle some common edge cases. To do this, you should do the following in a try-except block:
30+
CLI/LSP/MCP interfaces to handle some common edge cases (for example, querying
31+
from an unindexed project). To do this, you should do the following in a
32+
try-except block:
3133
```python
3234
from vectorcode.database.errors import CollectionNotFoundError
3335

0 commit comments

Comments
 (0)