first commit
This commit is contained in:
52
src/daemon_boyfriend/services/providers/base.py
Normal file
52
src/daemon_boyfriend/services/providers/base.py
Normal file
@@ -0,0 +1,52 @@
|
||||
"""Abstract base class for AI providers."""
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class Message:
|
||||
"""A chat message."""
|
||||
|
||||
role: str # "user", "assistant", "system"
|
||||
content: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class AIResponse:
|
||||
"""Response from an AI provider."""
|
||||
|
||||
content: str
|
||||
model: str
|
||||
usage: dict[str, int] # Token usage info
|
||||
|
||||
|
||||
class AIProvider(ABC):
|
||||
"""Abstract base class for AI providers."""
|
||||
|
||||
@abstractmethod
|
||||
async def generate(
|
||||
self,
|
||||
messages: list[Message],
|
||||
system_prompt: str | None = None,
|
||||
max_tokens: int = 1024,
|
||||
temperature: float = 0.7,
|
||||
) -> AIResponse:
|
||||
"""Generate a response from the AI model.
|
||||
|
||||
Args:
|
||||
messages: List of conversation messages
|
||||
system_prompt: Optional system prompt
|
||||
max_tokens: Maximum tokens in response
|
||||
temperature: Sampling temperature
|
||||
|
||||
Returns:
|
||||
AIResponse with the generated content
|
||||
"""
|
||||
pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def provider_name(self) -> str:
|
||||
"""Return the name of this provider."""
|
||||
pass
|
||||
Reference in New Issue
Block a user