Spaces:
Sleeping
Sleeping
File size: 1,056 Bytes
1061354 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | from abc import ABC, abstractmethod
from typing import AsyncIterator
class BaseLLMClient(ABC):
"""Abstract base class for LLM clients"""
@abstractmethod
async def generate_text(
self,
prompt: str,
max_tokens: int = 1000,
temperature: float = 1,
**kwargs
) -> str:
"""Generate text response"""
pass
@abstractmethod
async def generate_text_streaming(
self,
prompt: str,
max_tokens: int = 1000,
temperature: float = 1,
stream: bool = True,
**kwargs
) -> AsyncIterator[str]:
"""Generate text with streaming response"""
pass
@abstractmethod
async def health_check(self) -> bool:
"""Check if the LLM service is healthy"""
pass
@abstractmethod
async def generate_image(
self,
prompt: str,
max_tokens: int = 1000,
temperature: float = 1,
**kwargs
) -> str:
"""Generate image based on the prompt"""
pass |