28 lines
587 B
Python
28 lines
587 B
Python
import asyncio
|
|
import os
|
|
import traceback
|
|
import signal
|
|
from typing import Callable
|
|
|
|
import bot
|
|
import config
|
|
import ai
|
|
from ai import Message, Role
|
|
|
|
async def main() -> None:
|
|
"""Application entry point"""
|
|
stop_event = asyncio.Event()
|
|
loop = asyncio.get_running_loop()
|
|
def shutdown_handler():
|
|
stop_event.set()
|
|
|
|
for sig in (signal.SIGINT, signal.SIGTERM):
|
|
loop.add_signal_handler(sig, shutdown_handler)
|
|
# get available tools
|
|
await bot.start()
|
|
await stop_event.wait()
|
|
await bot.stop()
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|