对于构建会话软件的Rasa Core官方教程有困难,我很专心the tutorial of Justina Petraityte。您可以在教程on Github之后找到我重新编码的所有文件。但是,在尝试启动findContours
文件时,真正的会话聊天机会能够发送邮件,似乎存在编码问题:
这是文件:
train_online.py
但是出现了以下错误:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import logging
from rasa_core.agent import Agent
from rasa_core.channels.console import ConsoleInputChannel
from rasa_core.interpreter import RegexInterpreter
from rasa_core.policies.keras_policy import KerasPolicy
from rasa_core.policies.memoization import MemoizationPolicy
from rasa_core.interpreter import RasaNLUInterpreter
logger = logging.getLogger(__name__)
def run_weather_online(input_channel, interpreter,
domain_file="weather_domain.yml",
training_data_file='data/stories.md'):
agent = Agent(domain_file,
policies=[MemoizationPolicy(), KerasPolicy()],
interpreter=interpreter)
agent.train_online(training_data_file,
input_channel=input_channel,
max_history=2,
batch_size=50,
epochs=200,
max_training_samples=300)
return agent
if __name__ == '__main__':
logging.basicConfig(level="INFO")
nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/weathernlu')
run_weather_online(ConsoleInputChannel(), nlu_interpreter)
我知道这意味着不能完全支持python版本之间的兼容性,但我不明白为什么以及我能做些什么来应对它。
只是告诉自己我尝试使用Python 2明确启动代码:它给了我:
(MoodbotEnv) mike@mike-thinks:~/Programing/Rasa_tutorial/moodbot4$ python train_online.py
INFO:rasa_nlu.components:Added 'nlp_spacy' to component cache. Key 'nlp_spacy-en'.
Traceback (most recent call last):
File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 508, in _unpickle
obj = unpickler.load()
File "/usr/lib/python3.5/pickle.py", line 1039, in load
dispatch[key[0]](self)
File "/usr/lib/python3.5/pickle.py", line 1177, in load_binstring
self.append(self._decode_string(data))
File "/usr/lib/python3.5/pickle.py", line 1159, in _decode_string
return value.decode(self.encoding, self.errors)
UnicodeDecodeError: 'ascii' codec can't decode byte 0x89 in position 36: ordinal not in range(128)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "train_online.py", line 37, in <module>
nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/weathernlu')
File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/rasa_core/interpreter.py", line 221, in __init__
self._load_interpreter()
File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/rasa_core/interpreter.py", line 237, in _load_interpreter
self.interpreter = Interpreter.load(self.model_directory)
File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/rasa_nlu/model.py", line 276, in load
skip_validation)
File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/rasa_nlu/model.py", line 303, in create
model_metadata, **context)
File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/rasa_nlu/components.py", line 398, in load_component
cached_component, **context)
File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/rasa_nlu/registry.py", line 131, in load_component_by_name
return component_clz.load(model_dir, metadata, cached_component, **kwargs)
File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/rasa_nlu/extractors/crf_entity_extractor.py", line 313, in load
ent_tagger = joblib.load(model_file)
File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 578, in load
obj = _unpickle(fobj, filename, mmap_mode)
File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 523, in _unpickle
raise new_exc
ValueError: You may be trying to read with python 3 a joblib pickle generated with python 2. This feature is not supported by joblib.
这是他们已经处理过的问题,但是就我的rasa-core版本而言,这是一个意外的问题。
我认为问题在于RasaNLUInterpreter模块在这里已经改变了。
域名文件的内容:
(MoodbotEnv) mike@mike-thinks:~/Programing/Rasa_tutorial/moodbot4$ python2 train_online.py
Traceback (most recent call last):
File "train_online.py", line 37, in <module>
nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/weathernlu')
File "/home/mike/.local/lib/python2.7/site-packages/rasa_core/interpreter.py", line 219, in __init__
self._load_interpreter()
File "/home/mike/.local/lib/python2.7/site-packages/rasa_core/interpreter.py", line 234, in _load_interpreter
from rasa_nlu.config import RasaNLUConfig
ImportError: cannot import name RasaNLUConfig
Rasa核心版:
action_factory: null
action_names:
- utter_greet
- utter_goodbye
- utter_ask_location
- action_weather
actions:
- utter_greet
- utter_goodbye
- utter_ask_location
- actions.ActionWeather
config:
store_entities_as_slots: true
entities:
- location
intents:
- greet
- goodbye
- inform
slots:
location:
initial_value: null
type: rasa_core.slots.TextSlot
templates:
utter_ask_location:
- text: In what location?
utter_goodbye:
- text: Talk to you later.
- text: Bye bye :(
utter_greet:
- text: Hello! How can I help?
topics: []
Python版本:
(MoodbotEnv) mike@mike-thinks:~/Programing/Rasa_tutorial/moodbot4$ pip list :
...
rasa-core (0.9.0a3)
rasa-nlu (0.12.3)
操作系统:Linux 16.04
答案 0 :(得分:0)
在Windows 10上的python 3.5中运行时,我遇到了类似的问题。对我有用的是在python 3.7中创建新的env。