RSCE / src /llm /base.py
LP1205's picture
Deploy RSCE backend to Hugging Face Space
5e952bb
Raw
History Blame Contribute Delete
606 Bytes
from abc import ABC, abstractmethod
from typing import TypeVar, Type
from pydantic import BaseModel
T = TypeVar('T', bound=BaseModel)
class LLMProvider(ABC):
@abstractmethod
async def generate_structured(
self,
prompt: str,
response_schema: Type[T],
temperature: float = 0.1,
) -> T:
"""Generate structured output validated against a Pydantic schema."""
pass
@abstractmethod
async def generate_text(
self,
prompt: str,
temperature: float = 0.3,
) -> str:
"""Generate free-form text."""
pass