easyreadDemo / src /libs /llm.py
system's picture
system HF Staff
Deploy 53c0813 from hugging_face
1c57e18 verified
Raw History Blame Contribute Delete
790 Bytes
# 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