我的代码如下:
async def train_dialogue(domain_file='domain.yml',
model_path='models/dialogue',
config_file='config.yml',
training_data_file='./data/stories/stories.md'):
policies = policy_config.load(config_file)
agent = Agent("domain.yml", policies=policies)
#asyncio.run(agent.load_data(training_data_file))
#training_data = await agent.load_data(training_data_file)
#training_data = asyncio.run(agent.load_data(training_data_file))
#training_data = agent.load_data(training_data_file)
loop = asyncio.get_event_loop()
data = loop.run_until_complete(agent.load_data(training_data_file))
agent.train(training_data)
agent.persist(model_path)
return agent
def run_weather_bot(serve_forever=True):
interpreter = Interpreter.load('./models/nlu/default/chat')
agent = Agent.load('./models/dialogue', interpreter=interpreter)
rasa.core.run.serve_application(agent, channel='cmdline')
return agent
train_dialogue('domain.yml','models/dialogue','config.yml','./data/stories/stories.md')
run_weather_bot()
当我执行上面的这段代码来训练聊天机器人的 rasa 核心模型时,我收到以下错误:
RuntimeWarning: coroutine 'train_dialogue' was never awaited
"""Entry point for launching an IPython kernel.
在查看了网络上的一些解决方案后,我也尝试了这些行,但这些也没有解决他的问题:
#asyncio.run(agent.load_data(training_data_file))
#training_data = await agent.load_data(training_data_file)
#training_data = asyncio.run(agent.load_data(training_data_file))
#training_data = agent.load_data(training_data_file)
另外,当我像这样加载我的模型时:
agent = Agent.load("models/dialogue", interpreter= rasaNLU)
我得到“在模型/对话中找不到核心或 NLU 模型”,所以我相信函数 train_dialogue 没有正确执行,这就是模型没有被持久化的原因。任何帮助都感激不尽!