feat(06-02): move processors and platforms to kb_workflow.pipeline
- Move all processor implementations (parse, download, asr, analyze, archive) - Move all platform adapters (base, bilibili, zhihu) - Update all internal imports to use kb_workflow.pipeline prefix Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
"""BaseProcessor - Abstract base class for all pipeline processors
|
||||
|
||||
Provides a unified interface that all processors (parse, download, asr, analyze)
|
||||
must follow, enabling consistent state management and error handling.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Optional, TYPE_CHECKING
|
||||
|
||||
from kb_workflow.pipeline.config import get_settings
|
||||
from kb_workflow.pipeline.schemas import StepInput, StepOutput
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kb_workflow.pipeline.state import WorkflowStateManager
|
||||
|
||||
|
||||
class BaseProcessor(ABC):
|
||||
"""Abstract base class for all pipeline processors.
|
||||
|
||||
All processors (ParseProcessor, DownloadProcessor, ASRProcessor, AnalyzeProcessor)
|
||||
must inherit from this class and implement the process() method.
|
||||
|
||||
Attributes:
|
||||
STEP_NAME: Class attribute identifying the processor step name.
|
||||
settings: KBSettings instance from get_settings().
|
||||
state_manager: Optional WorkflowStateManager for state recording.
|
||||
"""
|
||||
|
||||
STEP_NAME: str
|
||||
|
||||
def __init__(self, state_manager: Optional[WorkflowStateManager] = None):
|
||||
"""Initialize the processor.
|
||||
|
||||
Args:
|
||||
state_manager: Optional WorkflowStateManager for recording step state.
|
||||
"""
|
||||
self.settings = get_settings()
|
||||
self.state_manager = state_manager
|
||||
|
||||
@abstractmethod
|
||||
async def process(self, input_data: StepInput) -> StepOutput:
|
||||
"""Process the input data and return the result.
|
||||
|
||||
Args:
|
||||
input_data: Input data for the processor step.
|
||||
|
||||
Returns:
|
||||
StepOutput with processing results.
|
||||
|
||||
Raises:
|
||||
Exception: If processing fails.
|
||||
"""
|
||||
pass
|
||||
Reference in New Issue
Block a user