Files
OpenHands/openhands/server/types.py
Rohit Malhotra 4adef574c0 Refactor: Github Service (#6580)
Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
2025-02-03 17:21:36 +00:00

57 lines
1.2 KiB
Python

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 ServerConfigInterface(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 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
class GhAuthenticationError(ValueError):
"""Raised when there is an issue with LLM authentication."""
pass
class GHUnknownException(ValueError):
"""Raised when there is an issue with LLM authentication."""
pass