-
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathrun_app.py
More file actions
62 lines (48 loc) · 1.86 KB
/
run_app.py
File metadata and controls
62 lines (48 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python3
"""
Chainlit-compatible wrapper script for VT.ai application.
This script properly exposes the VT.ai callbacks to Chainlit.
"""
import os
import sys
# Add the project root to the Python path so imports work correctly
project_root = os.path.dirname(os.path.abspath(__file__))
if project_root not in sys.path:
sys.path.insert(0, project_root)
# Set the current working directory to the project root
os.chdir(project_root)
# Import all the required callbacks from the main app
from vtai.app import build_chat_profile, on_message, start_chat
def main():
"""
Main entry point for the VT.ai application.
This function can be used to run the application programmatically.
"""
print("Starting VT.ai application...")
# Initialize the application
try:
# Import chainlit here to avoid issues when running as standalone
import chainlit as cl
# Expose the callbacks to Chainlit
globals()["build_chat_profile"] = build_chat_profile
globals()["start_chat"] = start_chat
globals()["on_message"] = on_message
print("VT.ai application initialized successfully!")
print("Access the interface at: http://localhost:8000")
# If this script is run directly, start the Chainlit server
if __name__ == "__main__":
# This will be handled by the chainlit command
pass
except ImportError as e:
print(f"Error importing dependencies: {e}")
print("Make sure you have installed the required dependencies:")
print("pip install -e .")
sys.exit(1)
except Exception as e:
print(f"Error initializing VT.ai application: {e}")
sys.exit(1)
# Expose the callbacks to Chainlit
__all__ = ["build_chat_profile", "start_chat", "on_message"]
# Call main if this script is run directly
if __name__ == "__main__":
main()