Spaces:
Sleeping
Sleeping
Download src/libs/llm.py from easyreadtogether/easyreadDemo: direct link, hf CLI and curl.
- Browser
- Download file 790 Bytes
-
https://huggingface.co/spaces/easyreadtogether/easyreadDemo/resolve/main/src/libs/llm.py
- Command line
-
hf download hf://spaces/easyreadtogether/easyreadDemo/src/libs/llm.py
-
curl -L -o llm.py https://huggingface.co/spaces/easyreadtogether/easyreadDemo/resolve/main/src/libs/llm.py
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") | |
| def __init__(self, config): | |
| pass | |
| def simplify_one(self, text) -> str: | |
| # Simplify a single text input and return the simplified text | |
| pass | |
| 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 |