Implementation:1Panel dev MaxKB BaseGenerateHumanMessageStep
| Knowledge Sources | |
|---|---|
| Domains | Chat_Pipeline, Prompt_Engineering |
| Last Updated | 2026-10-10 00:00 GMT |
Overview
Concrete pipeline step for constructing LangChain message lists with knowledge context and prompt templates, provided by MaxKB.
Description
The BaseGenerateHumanMessageStep class implements IGenerateHumanMessageStep for the legacy chat pipeline. It assembles a list of BaseMessage objects for the LLM: an optional SystemMessage (if system prompt is configured), recent chat history messages (limited by `dialogue_number`), and a final HumanMessage containing the prompt template with retrieved paragraph data inserted into `{data}` and the question into `{question}`. If no paragraphs were found, it uses the `no_references_setting` fallback behavior (ai_questioning or designated_answer).
Usage
Import this class when you need to:
- Build the LLM message list with knowledge context for the legacy pipeline
- Format prompt templates with paragraph data and question substitution
- Handle the no-references fallback scenario
Code Reference
Source Location
- Repository: MaxKB
- File: apps/application/chat_pipeline/step/generate_human_message_step/impl/base_generate_human_message_step.py
Signature
class BaseGenerateHumanMessageStep(IGenerateHumanMessageStep):
def execute(
self,
problem_text: str,
paragraph_list: List[ParagraphPipelineModel],
history_chat_record: List[ChatRecord],
dialogue_number: int,
max_paragraph_char_number: int,
prompt: str,
padding_problem_text: str = None,
no_references_setting: Dict = None,
system: str = None,
**kwargs,
) -> List[BaseMessage]:
"""Build the message list with knowledge context for the LLM."""
Import
from application.chat_pipeline.step.generate_human_message_step.impl.base_generate_human_message_step import BaseGenerateHumanMessageStep
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| problem_text | str | Yes | User question |
| paragraph_list | List[ParagraphPipelineModel] | Yes | Search results from previous step |
| history_chat_record | List[ChatRecord] | Yes | Chat history for context |
| dialogue_number | int | Yes | Number of history messages to include |
| max_paragraph_char_number | int | Yes | Max chars for knowledge data |
| prompt | str | Yes | Prompt template with {data} and {question} placeholders |
| no_references_setting | Dict | No | Fallback when no paragraphs found |
| system | str | No | System prompt (optional) |
Outputs
| Name | Type | Description |
|---|---|---|
| returns | List[BaseMessage] | Message list: optional SystemMessage + history + HumanMessage |
Usage Examples
Building the Message List
step = BaseGenerateHumanMessageStep()
messages = step.execute(
problem_text="What is RAG?",
paragraph_list=paragraphs, # From BaseSearchDatasetStep
history_chat_record=chat_records,
dialogue_number=3,
max_paragraph_char_number=5000,
prompt="Based on: {data}\n\nQuestion: {question}",
no_references_setting={"status": "ai_questioning", "value": "I don't know about {question}"},
system="You are a helpful assistant.",
)
# messages: [SystemMessage(...), HumanMessage(...), AIMessage(...), HumanMessage(...)]