File size: 790 Bytes
1c57e18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Abstract Base Class for LLM Simplification Engines
from abc import ABC, abstractmethod
from pathlib import Path
import yaml

    

class BaseSimplify(ABC):
    PROMPTS_DIR = Path("src/prompts")

    @abstractmethod
    def __init__(self, config):
        pass

    @abstractmethod
    def simplify_one(self, text) -> str:
        # Simplify a single text input and return the simplified text
        pass

    @abstractmethod
    def simplify_batch(self, texts) -> list[str]:
        # Simplify a batch of text inputs and return a list of simplified texts
        pass


    def load_prompts(self, name: str) -> dict:
        with open(self.PROMPTS_DIR / f"{name}.yaml") as f:
            return yaml.safe_load(f)
        

# Afther Base comes the the specific implementations of the LLM