conversation.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. from openhands.core.config import AppConfig
  2. from openhands.events.stream import EventStream
  3. from openhands.runtime import get_runtime_cls
  4. from openhands.runtime.runtime import Runtime
  5. from openhands.security import SecurityAnalyzer, options
  6. from openhands.storage.files import FileStore
  7. class Conversation:
  8. sid: str
  9. file_store: FileStore
  10. event_stream: EventStream
  11. runtime: Runtime
  12. def __init__(
  13. self,
  14. sid: str,
  15. file_store: FileStore,
  16. config: AppConfig,
  17. ):
  18. self.sid = sid
  19. self.config = config
  20. self.file_store = file_store
  21. self.event_stream = EventStream(sid, file_store)
  22. if config.security.security_analyzer:
  23. self.security_analyzer = options.SecurityAnalyzers.get(
  24. config.security.security_analyzer, SecurityAnalyzer
  25. )(self.event_stream)
  26. runtime_cls = get_runtime_cls(self.config.runtime)
  27. self.runtime = runtime_cls(
  28. config=config,
  29. event_stream=self.event_stream,
  30. sid=self.sid,
  31. attach_to_existing=True,
  32. )