Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:1Panel dev MaxKB BaseResetProblemStep

From Leeroopedia
Knowledge Sources
Domains Chat_Pipeline, NLP
Last Updated 2026-10-10 00:00 GMT

Overview

Concrete pipeline step for question optimization using an LLM to rewrite ambiguous user questions, provided by MaxKB.

Description

The BaseResetProblemStep class implements IResetProblemStep for the legacy chat pipeline. It takes the user's original question and recent chat history (last 3 messages), sends them to an LLM with a prompt instructing it to produce a complete, context-aware reformulation, and extracts the result from `` tags in the LLM response. If no model is configured, the original question is returned unchanged.

Usage

Import this class when you need to:

  • Optimize user questions using LLM-based rewriting
  • Understand the first step of the legacy chat pipeline

Code Reference

Source Location

  • Repository: MaxKB
  • File: apps/application/chat_pipeline/step/reset_problem_step/impl/base_reset_problem_step.py

Signature

class BaseResetProblemStep(IResetProblemStep):
    def execute(
        self,
        problem_text: str,
        history_chat_record: List[ChatRecord] = None,
        model_id: str = None,
        problem_optimization_prompt: str = None,
        workspace_id: str = None,
        **kwargs,
    ) -> str:
        """
        Rewrite the user question using an LLM for clarity.

        Args:
            problem_text: Original user question
            history_chat_record: Recent chat records (last 3 used)
            model_id: LLM model ID for optimization
            problem_optimization_prompt: Custom prompt (default: built-in)
            workspace_id: Workspace ID for model authorization
        Returns:
            Optimized question string (extracted from <data></data> tags)
        """

Import

from application.chat_pipeline.step.reset_problem_step.impl.base_reset_problem_step import BaseResetProblemStep

I/O Contract

Inputs

Name Type Required Description
problem_text str Yes Original user question
history_chat_record List[ChatRecord] No Chat history (last 3 used for context)
model_id str No LLM model ID for question optimization
problem_optimization_prompt str No Custom prompt template (default: built-in)

Outputs

Name Type Description
returns str Optimized question (from tags, or original if no model)
context['message_tokens'] int Request token count
context['answer_tokens'] int Response token count

Usage Examples

Optimizing a Question

# Step is executed within PipelineManage.run() with context:
step = BaseResetProblemStep()
optimized = step.execute(
    problem_text="How does it work?",
    history_chat_record=chat_records,  # List[ChatRecord]
    model_id="model-uuid",
    workspace_id="ws-uuid",
)
# optimized: "How does retrieval-augmented generation (RAG) work?"

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment