27 lines
669 B
Python
27 lines
669 B
Python
"""Base LLM provider class."""
|
|
from abc import ABC, abstractmethod
|
|
from typing import Dict, Any
|
|
from src.config.llm_config import LLMConfig
|
|
|
|
class BaseLLMProvider(ABC):
|
|
"""Base class for LLM providers."""
|
|
|
|
def __init__(self, config: LLMConfig):
|
|
self.config = config
|
|
|
|
@abstractmethod
|
|
async def generate_text(self, prompt: str) -> str:
|
|
"""Generate text from a prompt."""
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def close(self):
|
|
"""Close any resources."""
|
|
pass
|
|
|
|
async def __aenter__(self):
|
|
return self
|
|
|
|
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
await self.close()
|