Skip to content

Commit 6b9cb8a

Browse files
committed
docs(kb): document retrieve() payload contract and kb_id precedence
The method had no docstring, so the precedence between `kb_names` and the `kb_id` path parameter was only discoverable by reading the body. Spell out that an explicit `kb_names` wins, which is what keeps the legacy multi-base `POST /api/kb/retrieve` endpoint working.
1 parent 555ac39 commit 6b9cb8a

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎astrbot/dashboard/services/knowledge_base_service.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,26 @@ async def list_chunks_from_dashboard_query(
761761
)
762762

763763
async def retrieve(self, data: object) -> dict[str, Any]:
764+
"""Retrieve chunks from one or more knowledge bases.
765+
766+
Args:
767+
data: Request payload. ``query`` is required. The knowledge bases
768+
are taken from ``kb_names`` when present, which is how the
769+
legacy ``POST /api/kb/retrieve`` endpoint targets several bases
770+
at once; otherwise the ``kb_id`` that the REST route reads from
771+
its path is resolved to the matching name. ``top_k`` defaults
772+
to 5, and ``debug`` additionally renders a t-SNE plot.
773+
774+
Returns:
775+
A dict with the ``results`` list, its ``total`` and the ``query``
776+
that produced it, plus ``visualization`` (or ``visualization_error``)
777+
when ``debug`` is set.
778+
779+
Raises:
780+
KnowledgeBaseServiceError: If ``query`` is missing, the given
781+
``kb_id`` does not exist, or neither ``kb_names`` nor ``kb_id``
782+
identifies a knowledge base.
783+
"""
764784
payload = self._payload(data)
765785
query = payload.get("query")
766786
kb_names = payload.get("kb_names")

0 commit comments

Comments
 (0)