| 238 | |
| 239 | |
| 240 | def config_from_env() -> AppServerConfig: |
| 241 | # Import defaults... |
| 242 | from openhands.app_server.app_conversation.live_status_app_conversation_service import ( # noqa: E501 |
| 243 | LiveStatusAppConversationServiceInjector, |
| 244 | ) |
| 245 | from openhands.app_server.app_conversation.sql_app_conversation_info_service import ( # noqa: E501 |
| 246 | SQLAppConversationInfoServiceInjector, |
| 247 | ) |
| 248 | from openhands.app_server.app_conversation.sql_app_conversation_start_task_service import ( # noqa: E501 |
| 249 | SQLAppConversationStartTaskServiceInjector, |
| 250 | ) |
| 251 | from openhands.app_server.event.aws_event_service import ( |
| 252 | AwsEventServiceInjector, |
| 253 | ) |
| 254 | from openhands.app_server.event.filesystem_event_service import ( |
| 255 | FilesystemEventServiceInjector, |
| 256 | ) |
| 257 | from openhands.app_server.event.google_cloud_event_service import ( |
| 258 | GoogleCloudEventServiceInjector, |
| 259 | ) |
| 260 | from openhands.app_server.event_callback.sql_event_callback_service import ( |
| 261 | SQLEventCallbackServiceInjector, |
| 262 | ) |
| 263 | from openhands.app_server.sandbox.docker_sandbox_service import ( |
| 264 | DockerSandboxServiceInjector, |
| 265 | ) |
| 266 | from openhands.app_server.sandbox.docker_sandbox_spec_service import ( |
| 267 | DockerSandboxSpecServiceInjector, |
| 268 | ) |
| 269 | from openhands.app_server.sandbox.process_sandbox_service import ( |
| 270 | ProcessSandboxServiceInjector, |
| 271 | ) |
| 272 | from openhands.app_server.sandbox.process_sandbox_spec_service import ( |
| 273 | ProcessSandboxSpecServiceInjector, |
| 274 | ) |
| 275 | from openhands.app_server.sandbox.remote_sandbox_service import ( |
| 276 | RemoteSandboxServiceInjector, |
| 277 | ) |
| 278 | from openhands.app_server.sandbox.remote_sandbox_spec_service import ( |
| 279 | RemoteSandboxSpecServiceInjector, |
| 280 | ) |
| 281 | from openhands.app_server.user.auth_user_context import ( |
| 282 | AuthUserContextInjector, |
| 283 | ) |
| 284 | |
| 285 | config: AppServerConfig = from_env(AppServerConfig, 'OH') # type: ignore |
| 286 | |
| 287 | if config.llm_model is None: |
| 288 | from openhands.app_server.config_api.default_llm_model_service import ( |
| 289 | DefaultLLMModelServiceInjector, |
| 290 | ) |
| 291 | |
| 292 | llm_model_kwargs: dict = {} |
| 293 | aws_region = os.getenv('AWS_REGION_NAME') |
| 294 | aws_key = os.getenv('AWS_ACCESS_KEY_ID') |
| 295 | aws_secret = os.getenv('AWS_SECRET_ACCESS_KEY') |
| 296 | if aws_region and aws_key and aws_secret: |
| 297 | llm_model_kwargs['aws_region_name'] = aws_region |