Skip to content

Commit 8839a81

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 9822b18 commit 8839a81

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
@@ -810,6 +810,26 @@ async def list_chunks_from_dashboard_query(
810810
)
811811

812812
async def retrieve(self, data: object) -> dict[str, Any]:
813+
"""Retrieve chunks from one or more knowledge bases.
814+
815+
Args:
816+
data: Request payload. ``query`` is required. The knowledge bases
817+
are taken from ``kb_names`` when present, which is how the
818+
legacy ``POST /api/kb/retrieve`` endpoint targets several bases
819+
at once; otherwise the ``kb_id`` that the REST route reads from
820+
its path is resolved to the matching name. ``top_k`` defaults
821+
to 5, and ``debug`` additionally renders a t-SNE plot.
822+
823+
Returns:
824+
A dict with the ``results`` list, its ``total`` and the ``query``
825+
that produced it, plus ``visualization`` (or ``visualization_error``)
826+
when ``debug`` is set.
827+
828+
Raises:
829+
KnowledgeBaseServiceError: If ``query`` is missing, the given
830+
``kb_id`` does not exist, or neither ``kb_names`` nor ``kb_id``
831+
identifies a knowledge base.
832+
"""
813833
payload = self._payload(data)
814834
query = payload.get("query")
815835
kb_names = payload.get("kb_names")

0 commit comments

Comments
 (0)