from rasa.core.agent import Agent # Define agent configuration config_file = "config.yml" domain_file = "domain.yml" training_data_file = "stories.md" # Create agent instance agent = Agent( domain = domain_file, policies = config_file ) # Train the agent with training data training_data = agent.load_data(training_data_file) agent.train(training_data) # Start the dialogue response = agent.handle_message("Hi! How can I help you?") print(response)
from rasa.core.agent import Agent from rasa.core.interpreter import RasaNLUInterpreter # Define agent configuration config_file = "config.yml" domain_file = "domain.yml" model_file = "path/to/model" # Instantiate RasaNLUInterpreter interpreter = RasaNLUInterpreter(model_file) # Create agent instance with pre-trained interpreter agent = Agent( domain = domain_file, interpreter = interpreter, policies = config_file ) # Start the dialogue response = agent.handle_message("How do I make a reservation?") print(response)In this example, we first import the `Agent` and `RasaNLUInterpreter` classes from the `rasa.core.agent` and `rasa.core.interpreter` packages respectively. We define the agent configuration as before and specify the location of a pre-trained model file. We instantiate an `RasaNLUInterpreter` with the model file and pass it to the agent as the interpreter. We start the dialogue as before and print the response. The package library for the `rasa.core.agent` module is `rasa.core`.