Abstract base for prompt refinement, supports pipeline composition.
# Source: https://github.com/JacobHuang91/prompt-refiner | License: MIT | Copyright 2024 Xinghao Huang
# Provided via justclaw.it.com; keep this notice with the code.
"""Base refiner class for prompt processing."""
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .pipeline import Pipeline
class Refiner(ABC):
"""Base class for all prompt refining operations."""
@abstractmethod
def process(self, text: str) -> str:
"""
Process the input text.
Args:
text: The input text to process
Returns:
The processed text
"""
pass
def __or__(self, other: "Refiner") -> "Pipeline":
"""
Support pipe operator syntax for composing refiners.
Enable
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key