Implementation:1Panel dev MaxKB BaseSearchDatasetStep
| Knowledge Sources | |
|---|---|
| Domains | Chat_Pipeline, RAG |
| Last Updated | 2026-10-10 00:00 GMT |
Overview
Concrete pipeline step for knowledge base vector search in the legacy chat pipeline, provided by MaxKB.
Description
The BaseSearchDatasetStep class implements ISearchDatasetStep for the legacy chat pipeline. It embeds the user question (or the optimized question from the previous step), queries the VectorStore (PGVector) across configured knowledge bases, fetches matching paragraphs via SQL, and returns them as ParagraphPipelineModel instances. It supports workspace authorization, directly-return paragraphs (bypassing the LLM if a paragraph's similarity exceeds the threshold), and handles dirty vector data cleanup.
Usage
Import this class when you need to:
- Execute knowledge search as a step in the legacy chat pipeline
- Retrieve paragraph results for downstream prompt construction
Code Reference
Source Location
- Repository: MaxKB
- File: apps/application/chat_pipeline/step/search_dataset_step/impl/base_search_dataset_step.py
Signature
class BaseSearchDatasetStep(ISearchDatasetStep):
def execute(
self,
problem_text: str,
knowledge_id_list: list[str],
exclude_document_id_list: list[str],
exclude_paragraph_id_list: list[str],
top_n: int,
similarity: float,
padding_problem_text: str = None,
search_mode: str = None,
workspace_id: str = None,
manage: PipelineManage = None,
**kwargs,
) -> List[ParagraphPipelineModel]:
"""Search knowledge bases and return matching paragraphs."""
Import
from application.chat_pipeline.step.search_dataset_step.impl.base_search_dataset_step import BaseSearchDatasetStep
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| problem_text | str | Yes | User question (or optimized version) |
| knowledge_id_list | list[str] | Yes | Knowledge base IDs to search |
| top_n | int | Yes | Maximum results to return |
| similarity | float | Yes | Similarity threshold |
| search_mode | str | No | Search mode: embedding, keywords, blend |
| padding_problem_text | str | No | Optimized question (from ResetProblemStep) |
Outputs
| Name | Type | Description |
|---|---|---|
| returns | List[ParagraphPipelineModel] | Matching paragraphs with content, similarity, metadata |
Usage Examples
Searching Knowledge Bases
step = BaseSearchDatasetStep()
paragraphs = step.execute(
problem_text="What is RAG?",
knowledge_id_list=["kb-uuid-1", "kb-uuid-2"],
exclude_document_id_list=[],
exclude_paragraph_id_list=[],
top_n=5,
similarity=0.6,
search_mode="embedding",
workspace_id="ws-uuid",
manage=pipeline_manage,
)
# paragraphs: [ParagraphPipelineModel(content="...", similarity=0.92, ...), ...]