-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
53 lines (46 loc) · 1.89 KB
/
main.py
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
import subprocess
import os
import platform
def run_rasa():
current_dir = os.path.dirname(os.path.realpath(__file__))
rasa_dir = os.path.join(current_dir, "rasa")
if platform.system() == "Darwin": # macOS
# Command to open a new Terminal tab and run the Rasa server on macOS
command = f"""
osascript -e 'tell application "Terminal"
activate
do script "cd '{rasa_dir}'; source ~/.bash_profile; conda activate rasa; rasa run --enable-api --cors \\"*\\" --debug"
end tell'
"""
elif platform.system() == "Windows": # Windows
# Command to open a new Command Prompt window and run the Rasa server on Windows
command = f"""
start cmd /k "cd /d "{rasa_dir}"; conda activate rasa; rasa run --enable-api --cors "*" --debug"
"""
else:
print("Unsupported operating system")
return
subprocess.Popen(command, shell=True)
def run_streamlit():
current_dir = os.path.dirname(os.path.realpath(__file__))
rasa_dir = os.path.join(current_dir, "rasa")
if platform.system() == "Darwin": # macOS
# Command to open a new Terminal tab and run the Streamlit app on macOS
command = f"""
osascript -e 'tell application "Terminal"
activate
do script "cd '{rasa_dir}'; source ~/.bash_profile; conda activate rasa; streamlit run ui/app.py --server.runOnSave true"
end tell'
"""
elif platform.system() == "Windows": # Windows
# Command to open a new Command Prompt window and run the Streamlit app on Windows
command = f"""
start cmd /k "cd /d "{rasa_dir}"; conda activate rasa; streamlit run ui/app.py --server.runOnSave true"
"""
else:
print("Unsupported operating system")
return
subprocess.Popen(command, shell=True)
if __name__ == "__main__":
run_rasa()
run_streamlit()