Add shellgen core and backends modules
This commit is contained in:
52
app/shellgen/backends/base.py
Normal file
52
app/shellgen/backends/base.py
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
"""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
|
||||||
Reference in New Issue
Block a user