File size: 1,297 Bytes
246d201 |
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 45 46 47 48 49 50 |
from abc import ABC, abstractmethod
from enum import Enum
from typing import ClassVar, Protocol
class AppMode(Enum):
OSS = 'oss'
SAAS = 'saas'
class SessionMiddlewareInterface(Protocol):
"""Protocol for session middleware classes."""
pass
class OpenhandsConfigInterface(ABC):
CONFIG_PATH: ClassVar[str | None]
APP_MODE: ClassVar[AppMode]
POSTHOG_CLIENT_KEY: ClassVar[str]
GITHUB_CLIENT_ID: ClassVar[str]
ATTACH_SESSION_MIDDLEWARE_PATH: ClassVar[str]
@abstractmethod
def verify_config(self) -> None:
"""Verify configuration settings."""
raise NotImplementedError
@abstractmethod
async def verify_github_repo_list(self, installation_id: int | None) -> None:
"""Verify that repo list is being called via user's profile or Github App installations."""
raise NotImplementedError
@abstractmethod
async def get_config(self) -> dict[str, str]:
"""Configure attributes for frontend"""
raise NotImplementedError
class MissingSettingsError(ValueError):
"""Raised when settings are missing or not found."""
pass
class LLMAuthenticationError(ValueError):
"""Raised when there is an issue with LLM authentication."""
pass
|