35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""
|
||
|
|
Script to run the OpenWebUI AI bot.
|
||
|
|
|
||
|
|
This script runs the AI bot example from the openwebui-bot repository.
|
||
|
|
"""
|
||
|
|
|
||
|
|
import sys
|
||
|
|
import os
|
||
|
|
import asyncio
|
||
|
|
|
||
|
|
# Add the openwebui-bot directory to the Python path
|
||
|
|
# Use a path relative to the current file's directory to ensure it works in any environment
|
||
|
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||
|
|
openwebui_bot_dir = os.path.join(current_dir, 'openwebui-bot')
|
||
|
|
sys.path.insert(0, openwebui_bot_dir)
|
||
|
|
print(f"Adding OpenWebUI bot directory to Python path: {openwebui_bot_dir}")
|
||
|
|
|
||
|
|
# Import the main function from the AI example
|
||
|
|
from examples.ai import main
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
print("Starting OpenWebUI AI bot...")
|
||
|
|
print("Press Ctrl+C to stop")
|
||
|
|
|
||
|
|
try:
|
||
|
|
# Run the main function
|
||
|
|
asyncio.run(main())
|
||
|
|
except KeyboardInterrupt:
|
||
|
|
print("\nBot stopped by user")
|
||
|
|
# No need to call shutdown here as it's handled in the main function
|
||
|
|
except Exception as e:
|
||
|
|
print(f"Error running bot: {str(e)}")
|
||
|
|
print("Check that the OpenWebUI server is running and accessible.")
|