- **Bootstrap IoC-based architecture with modular services.**
- **Implement `MlxModelService` for local LLM backend.** - **Introduce `DatabaseService` for MySQL integration.** - **Add `HistoryService` to manage conversation context.** - **Set up CLI interface via `CliUiService`.** - **Establish EventBus for token streaming.** - **Include conversation repository for data persistence.** - **Add environment-based configuration management.** - **Draft IoC architectural plan.**
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
from container import Container
|
||||
from services.chat.chat_service import ChatService
|
||||
|
||||
|
||||
def main() -> None:
|
||||
container = Container()
|
||||
|
||||
ui = container.ui_service()
|
||||
model = container.model_service()
|
||||
bus = container.event_bus()
|
||||
db = container.db_service()
|
||||
repo = container.conversation_repository()
|
||||
|
||||
bus.subscribe(ChatService.EVENT_TOKEN, container.stream_token_handler())
|
||||
bus.subscribe(ChatService.EVENT_END, container.stream_end_handler())
|
||||
|
||||
ui.show_banner(container.config().model_id)
|
||||
model.load()
|
||||
db.connect()
|
||||
db.init_schema()
|
||||
|
||||
chat = container.chat_service()
|
||||
|
||||
while True:
|
||||
try:
|
||||
user_input = ui.prompt_user()
|
||||
except (EOFError, KeyboardInterrupt):
|
||||
print("\n대화를 종료합니다.")
|
||||
break
|
||||
|
||||
if not user_input:
|
||||
continue
|
||||
|
||||
if ui.is_exit_command(user_input):
|
||||
print("대화를 종료합니다.")
|
||||
break
|
||||
|
||||
if ui.is_reset_command(user_input):
|
||||
repo.create_conversation()
|
||||
chat = container.chat_service()
|
||||
print("\n[대화가 초기화되었습니다.]\n")
|
||||
continue
|
||||
|
||||
ui.show_assistant_prefix()
|
||||
chat.respond(user_input)
|
||||
|
||||
db.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user