Files
agent/app/modules/application.py
2026-03-01 14:21:33 +03:00

49 lines
2.0 KiB
Python

from app.modules.agent.module import AgentModule
from app.modules.agent.repository import AgentRepository
from app.modules.agent.story_context_repository import StoryContextRepository, StoryContextSchemaRepository
from app.modules.chat.repository import ChatRepository
from app.modules.chat.module import ChatModule
from app.modules.rag.persistence.repository import RagRepository
from app.modules.rag_session.module import RagModule
from app.modules.rag_repo.module import RagRepoModule
from app.modules.shared.bootstrap import bootstrap_database
from app.modules.shared.event_bus import EventBus
from app.modules.shared.retry_executor import RetryExecutor
class ModularApplication:
def __init__(self) -> None:
self.events = EventBus()
self.retry = RetryExecutor()
self.rag_repository = RagRepository()
self.chat_repository = ChatRepository()
self.agent_repository = AgentRepository()
self.story_context_schema_repository = StoryContextSchemaRepository()
self.story_context_repository = StoryContextRepository()
self.rag_session = RagModule(event_bus=self.events, retry=self.retry, repository=self.rag_repository)
self.rag_repo = RagRepoModule(
story_context_repository=self.story_context_repository,
rag_repository=self.rag_repository,
)
self.agent = AgentModule(
rag_retriever=self.rag_session.rag,
agent_repository=self.agent_repository,
story_context_repository=self.story_context_repository,
)
self.chat = ChatModule(
agent_runner=self.agent.runtime,
event_bus=self.events,
retry=self.retry,
rag_sessions=self.rag_session.sessions,
repository=self.chat_repository,
)
def startup(self) -> None:
bootstrap_database(
self.rag_repository,
self.chat_repository,
self.agent_repository,
self.story_context_schema_repository,
)