Spaces:
Sleeping
Sleeping
import os | |
import subprocess | |
import sys | |
def train_rasa_model(): | |
os.chdir('./rasa_app') | |
try: | |
result = subprocess.run( | |
["python", "-m", "rasa", "train"], | |
check=True, | |
stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE, | |
text=True | |
) | |
if result.returncode == 0: | |
return True | |
else: | |
return False | |
except subprocess.CalledProcessError as e: | |
return False | |
except Exception as e: | |
return False | |
if __name__ == "__main__": | |
success = train_rasa_model() | |
if not success: | |
sys.exit(1) |