feat(04-02): integrate AI client into bot lifecycle
Import init_ai_client and call it during post_init callback alongside database initialization. Logs the configured AI router at startup. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
f1a001f923
commit
821b419271
1 changed files with 4 additions and 0 deletions
|
|
@ -13,6 +13,7 @@ from telegram.ext import Application, ApplicationBuilder
|
||||||
|
|
||||||
from moai.bot.config import BotConfig
|
from moai.bot.config import BotConfig
|
||||||
from moai.bot.handlers import register_handlers
|
from moai.bot.handlers import register_handlers
|
||||||
|
from moai.core.ai_client import init_ai_client
|
||||||
from moai.core.database import close_db, create_tables, init_db
|
from moai.core.database import close_db, create_tables, init_db
|
||||||
|
|
||||||
# Module-level config reference for post_init callback
|
# Module-level config reference for post_init callback
|
||||||
|
|
@ -34,6 +35,9 @@ async def post_init(application: Application) -> None:
|
||||||
await create_tables()
|
await create_tables()
|
||||||
logger.info("Database initialized")
|
logger.info("Database initialized")
|
||||||
|
|
||||||
|
init_ai_client(_config)
|
||||||
|
logger.info("AI client initialized with %s", _config.ai_router)
|
||||||
|
|
||||||
|
|
||||||
async def post_shutdown(application: Application) -> None:
|
async def post_shutdown(application: Application) -> None:
|
||||||
"""Clean up database on bot shutdown.
|
"""Clean up database on bot shutdown.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue