Files
shell-command-generator-cli/app/shellgen/backends/base.py

53 lines
1.1 KiB
Python

"""Abstract base class for LLM backends."""
from abc import ABC, abstractmethod
from typing import Optional
class LLMBackend(ABC):
"""Abstract base class for LLM backends."""
@abstractmethod
def generate(self, prompt: str) -> str:
"""Generate a response from the LLM.
Args:
prompt: The prompt to send to the LLM.
Returns:
The generated response text.
"""
pass
@abstractmethod
def is_available(self) -> bool:
"""Check if the backend is available.
Returns:
True if the backend can be used.
"""
pass
@abstractmethod
def get_model_name(self) -> str:
"""Get the name of the currently loaded model.
Returns:
Model name string.
"""
pass
@abstractmethod
def set_model(self, model: str) -> None:
"""Set the model to use.
Args:
model: Name of the model to load.
"""
pass
@abstractmethod
def close(self) -> None:
"""Clean up resources."""
pass