Initial upload: Local AI Commit Reviewer CLI with CI/CD workflow
This commit is contained in:
45
src/llm/provider.py
Normal file
45
src/llm/provider.py
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
from abc import ABC, abstractmethod
|
||||||
|
from collections.abc import AsyncIterator
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class LLMResponse:
|
||||||
|
text: str
|
||||||
|
model: str
|
||||||
|
tokens_used: int
|
||||||
|
finish_reason: str
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ModelInfo:
|
||||||
|
name: str
|
||||||
|
size: str
|
||||||
|
modified: str
|
||||||
|
digest: str
|
||||||
|
|
||||||
|
|
||||||
|
class LLMProvider(ABC):
|
||||||
|
@abstractmethod
|
||||||
|
def is_available(self) -> bool:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def generate(self, prompt: str, **kwargs) -> LLMResponse:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def agenerate(self, prompt: str, **kwargs) -> LLMResponse:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def stream_generate(self, prompt: str, **kwargs) -> AsyncIterator[str]:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def list_models(self) -> list[ModelInfo]:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def health_check(self) -> bool:
|
||||||
|
pass
|
||||||
Reference in New Issue
Block a user