Fix team chat integration
This commit is contained in:
+39
-17
@@ -60,24 +60,46 @@ async def startup_event():
|
||||
print("=" * 50)
|
||||
print("Starting OpenWebUI bot...")
|
||||
|
||||
# Start the bot with configuration
|
||||
success = await bot_manager.start_bot(
|
||||
openwebui_url=config.OPENWEBUI_URL,
|
||||
api_key=config.OPENWEBUI_API_KEY,
|
||||
model_id=config.DEFAULT_MODEL,
|
||||
system_prompt=config.BOT_SYSTEM_PROMPT,
|
||||
temperature=config.BOT_TEMPERATURE,
|
||||
max_tokens=config.BOT_MAX_TOKENS,
|
||||
top_p=config.BOT_TOP_P,
|
||||
triggers=config.BOT_TRIGGERS,
|
||||
respond_to_all=config.BOT_RESPOND_TO_ALL
|
||||
)
|
||||
|
||||
if success:
|
||||
print("Bot started successfully!")
|
||||
# Check if the OpenWebUI URL and API key are set
|
||||
if not config.OPENWEBUI_URL or not config.OPENWEBUI_API_KEY:
|
||||
print("ERROR: OpenWebUI URL or API key not set. Bot cannot be started.")
|
||||
print("Please set OPENWEBUI_URL and OPENWEBUI_API_KEY in your .env file.")
|
||||
print("=" * 50)
|
||||
else:
|
||||
print("Failed to start bot. Check the logs for details.")
|
||||
print("=" * 50)
|
||||
# Try to start the bot with multiple retries
|
||||
max_retries = 3
|
||||
retry_delay = 5 # seconds
|
||||
success = False
|
||||
|
||||
for attempt in range(1, max_retries + 1):
|
||||
print(f"Starting bot (attempt {attempt}/{max_retries})...")
|
||||
|
||||
# Start the bot with configuration
|
||||
success = await bot_manager.start_bot(
|
||||
openwebui_url=config.OPENWEBUI_URL,
|
||||
api_key=config.OPENWEBUI_API_KEY,
|
||||
model_id=config.DEFAULT_MODEL,
|
||||
system_prompt=config.BOT_SYSTEM_PROMPT,
|
||||
temperature=config.BOT_TEMPERATURE,
|
||||
max_tokens=config.BOT_MAX_TOKENS,
|
||||
top_p=config.BOT_TOP_P,
|
||||
triggers=config.BOT_TRIGGERS,
|
||||
respond_to_all=config.BOT_RESPOND_TO_ALL
|
||||
)
|
||||
|
||||
if success:
|
||||
print("Bot started successfully!")
|
||||
break
|
||||
else:
|
||||
print(f"Failed to start bot (attempt {attempt}/{max_retries}).")
|
||||
if attempt < max_retries:
|
||||
print(f"Retrying in {retry_delay} seconds...")
|
||||
await asyncio.sleep(retry_delay)
|
||||
else:
|
||||
print("Maximum retry attempts reached. Bot could not be started.")
|
||||
print("Check the logs for details.")
|
||||
|
||||
print("=" * 50)
|
||||
else:
|
||||
print("OpenWebUI bot is disabled. Set BOT_ENABLED=true in .env to enable it.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user