mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-03 01:12:15 +00:00
Co-authored-by: Florian <fanzhidongyzby@163.com> Co-authored-by: KingSkyLi <15566300566@163.com> Co-authored-by: aries_ckt <916701291@qq.com> Co-authored-by: Fangyin Cheng <staneyffer@gmail.com> Co-authored-by: yvonneyx <zhuyuxin0627@gmail.com>
43 lines
911 B
Python
43 lines
911 B
Python
"""Transformer base class."""
|
|
import logging
|
|
from abc import ABC, abstractmethod
|
|
from typing import List, Optional
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class TransformerBase:
|
|
"""Transformer base class."""
|
|
|
|
@abstractmethod
|
|
def truncate(self):
|
|
"""Truncate operation."""
|
|
|
|
@abstractmethod
|
|
def drop(self):
|
|
"""Clean operation."""
|
|
|
|
|
|
class EmbedderBase(TransformerBase, ABC):
|
|
"""Embedder base class."""
|
|
|
|
|
|
class SummarizerBase(TransformerBase, ABC):
|
|
"""Summarizer base class."""
|
|
|
|
@abstractmethod
|
|
async def summarize(self, **args) -> str:
|
|
"""Summarize result."""
|
|
|
|
|
|
class ExtractorBase(TransformerBase, ABC):
|
|
"""Extractor base class."""
|
|
|
|
@abstractmethod
|
|
async def extract(self, text: str, limit: Optional[int] = None) -> List:
|
|
"""Extract results from text."""
|
|
|
|
|
|
class TranslatorBase(TransformerBase, ABC):
|
|
"""Translator base class."""
|