Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: invalid width -106 (must be > 0) #8341

Closed
hei-my opened this issue Mar 30, 2021 · 2 comments · Fixed by #8586
Closed

ValueError: invalid width -106 (must be > 0) #8341

hei-my opened this issue Mar 30, 2021 · 2 comments · Fixed by #8586
Assignees
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.

Comments

@hei-my
Copy link

hei-my commented Mar 30, 2021

Rasa version: 2.4.3

Rasa SDK version (if used & relevant):

Rasa X version (if used & relevant):

Python version:3.8.8

Operating system (windows, osx, ...):

Issue: ValueError: invalid width -106 (must be > 0)

Error (including full traceback):

Bot loaded. Visualisation at http://localhost:5006/visualization.html .
Type a message and press enter (press 'Ctrl-c' to exit).
? Your input -> 放射性肺炎怎么医治哈
? Your NLU model classified '放射性肺炎怎么医治哈' with intent 'search_treat' and there are no entities, is this correct?  (Y/n)

Cancelled by user

? Do you want to stop?  Undo Last
------
Chat History

 #    Bot                You
────────────────────────────────────
 1    action_listen


Current slots:
        disease: None, symptom: None, dept: None, drug: None, food: None, sure: None, pre_disease: None, session_started_metadata: None

------
? Your input -> 牙龈出血有哪些病导致
? Your NLU model classified '牙龈出血有哪些病导致' with intent 'search_disease' and there are no entities, is this correct?  No
? What intent is it?  1.00 search_disease
? Please mark the entities using [value](type) notation [牙龈出血](symptom)有哪些病导致
------
Chat History

 #    Bot                                                   You
───────────────────────────────────────────────────────────────────────
 1    action_listen
───────────────────────────────────────────────────────────────────────
 2                                     [牙龈出血](symptom)有哪些病导致
                                           intent: search_disease 1.00
───────────────────────────────────────────────────────────────────────
 3    slot{"symptom": "牙龈出血"}


Current slots:
        disease: None, symptom: 牙龈出血, dept: None, drug: None, food: None, sure: None, pre_disease: None, session_started_metadata: None

------
? The bot wants to run 'action_search_disease', correct?  Yes
------
Chat History

 #    Bot                                                                                                                                                                                                                                                                                                            You
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 1    action_listen                                                                                                                                                                          
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 2                                                                                                                                                                                                                                                                                              [牙龈出血](symptom)有哪些病导致
                                                                                                                                                                                                                                                                                                    intent: search_disease 1.00
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 3    slot{"symptom": "牙龈出血"}                                                                                                                                                            
      action_search_disease 1.00                                                                                                                                                             
      牙龈出血的症状对应得疾病可能有:肥大性龈炎、骨髓增生异常综合征、口腔疾病、小儿出血性疾病、边缘性龈炎、获得性维生素K依赖性凝血因子异常、小儿白血病、回归热、坏死性龈口炎、青春期功能失调性子宫出血、郎-奥韦综合征、急性淋巴细胞白血病、感染性血小板减少性紫癜、单纯性牙周炎、单核细胞
      白血病、δ-贮存池病、小儿特发性血小板减少性紫癜、老年人真性红细胞增多症、急性根尖牙周炎、慢性根尖牙周炎、创伤性口炎、青少年牙周炎、慢性牙周炎                                          


Current slots:
        disease: None, symptom: 牙龈出血, dept: None, drug: None, food: None, sure: None, pre_disease: None, session_started_metadata: None

------
? The bot wants to run 'action_listen', correct?  Yes
? Your input -> 口腔疾病怎么医治
? Your NLU model classified '口腔疾病怎么医治' with intent 'search_treat' and there are no entities, is this correct?  No
? What intent is it?  1.00 search_treat
? Please mark the entities using [value](type) notation [口腔疾病](disease)怎么医治
2021-03-31 00:06:45 ERROR    rasa.core.training.interactive  - An exception occurred while recording messages.
Traceback (most recent call last):
  File "D:\python\anaconda\install\envs\rasa\lib\site-packages\rasa\core\training\interactive.py", line 1479, in record_messages
    await _predict_till_next_listen(
  File "D:\python\anaconda\install\envs\rasa\lib\site-packages\rasa\core\training\interactive.py", line 964, in _predict_till_next_listen
    await _print_history(conversation_id, endpoint)
  File "D:\python\anaconda\install\envs\rasa\lib\site-packages\rasa\core\training\interactive.py", line 467, in _print_history
    table = _chat_history_table(events)
  File "D:\python\anaconda\install\envs\rasa\lib\site-packages\rasa\core\training\interactive.py", line 547, in _chat_history_table
    msg = format_user_msg(event, user_width(table))
  File "D:\python\anaconda\install\envs\rasa\lib\site-packages\rasa\core\training\interactive.py", line 500, in format_user_msg
    colored(wrap(_md, max_width), "hired"),
  File "D:\python\anaconda\install\envs\rasa\lib\site-packages\rasa\core\training\interactive.py", line 488, in wrap
    return "\n".join(textwrap.wrap(txt, max_width, replace_whitespace=False))
  File "D:\python\anaconda\install\envs\rasa\lib\textwrap.py", line 379, in wrap
    return w.wrap(text)
  File "D:\python\anaconda\install\envs\rasa\lib\textwrap.py", line 354, in wrap
    return self._wrap_chunks(chunks)
  File "D:\python\anaconda\install\envs\rasa\lib\textwrap.py", line 248, in _wrap_chunks
    raise ValueError("invalid width %r (must be > 0)" % self.width)
ValueError: invalid width -106 (must be > 0)
2021-03-31 00:06:45 ERROR    asyncio  - Task exception was never retrieved
future: <Task finished name='Task-3' coro=<_serve_application.<locals>.run_interactive_io() done, defined at D:\python\anaconda\install\envs\rasa\lib\site-packages\rasa\core\training\interactive.py:1569> exception=ValueError('invalid width -106 (must be > 0)')>
Traceback (most recent call last):
  File "D:\python\anaconda\install\envs\rasa\lib\site-packages\rasa\core\training\interactive.py", line 1572, in run_interactive_io
    await record_messages(
  File "D:\python\anaconda\install\envs\rasa\lib\site-packages\rasa\core\training\interactive.py", line 1479, in record_messages
    await _predict_till_next_listen(
  File "D:\python\anaconda\install\envs\rasa\lib\site-packages\rasa\core\training\interactive.py", line 964, in _predict_till_next_listen
    await _print_history(conversation_id, endpoint)
  File "D:\python\anaconda\install\envs\rasa\lib\site-packages\rasa\core\training\interactive.py", line 467, in _print_history
    table = _chat_history_table(events)
  File "D:\python\anaconda\install\envs\rasa\lib\site-packages\rasa\core\training\interactive.py", line 547, in _chat_history_table
    msg = format_user_msg(event, user_width(table))
  File "D:\python\anaconda\install\envs\rasa\lib\site-packages\rasa\core\training\interactive.py", line 500, in format_user_msg
    colored(wrap(_md, max_width), "hired"),
  File "D:\python\anaconda\install\envs\rasa\lib\site-packages\rasa\core\training\interactive.py", line 488, in wrap
    return "\n".join(textwrap.wrap(txt, max_width, replace_whitespace=False))
  File "D:\python\anaconda\install\envs\rasa\lib\textwrap.py", line 379, in wrap
    return w.wrap(text)
  File "D:\python\anaconda\install\envs\rasa\lib\textwrap.py", line 354, in wrap
    return self._wrap_chunks(chunks)
  File "D:\python\anaconda\install\envs\rasa\lib\textwrap.py", line 248, in _wrap_chunks
    raise ValueError("invalid width %r (must be > 0)" % self.width)
ValueError: invalid width -106 (must be > 0)

Command or request that led to error:

python -m rasa interactive -m models/nlu/20210330-231450.tar.gz --endpoints config/endpoints.yml --config config/config_pretrained_embeddings_mitie_zh.yml

Content of configuration file (config.yml) (if relevant):

language: ch
pipeline:
  - name: HFTransformersNLP
    model_name: "bert"
    model_weights: "bert-base-chinese"
  - name: LanguageModelTokenizer
  - name: LanguageModelFeaturizer
  - name: LexicalSyntacticFeaturizer
  - name: CRFEntityExtractor
  - name: EntitySynonymMapper
  - name: DIETClassifier
    epochs: 200

policies:
  - name: AugmentedMemoizationPolicy

  - name: TEDPolicy
    epochs: 100
    featurizer:
      - name: MaxHistoryTrackerFeaturizer
        max_history: 5
        state_featurizer:
          - name: BinarySingleStateFeaturizer


  - name: FallbackPolicy
    fallback_action_name: 'action_default_fallback'
    nlu_threshold: 0.5
    core_threshold: 0.3
    ambiguity_threshold: 0.1

  - name: MappingPolicy

Content of domain file (domain.yml) (if relevant):

session_config:
  session_expiration_time: 60  # value in minutes, 0 means infinitely long
  carry_over_slots_to_new_session: true  # set to false to forget slots between sessions

slots:
  disease:
    type: text
  symptom:
    type: text
  dept:
    type: text
  drug:
    type: text
  food:
    type: text
  sure:
    type: any
  pre_disease:
    type: any


intents:
  - first: {triggers: action_first}
  - greet
  - bye
  - affirmative
  - search_treat
  - search_food
  - search_symptom
  - search_disease
  - search_cause
  - search_neopathy
  - search_drug
  - search_prevention
  - search_drug_func
  - search_disease_treat_time
  - search_easy_get
  - search_disease_dept

entities:
  - disease
  - symptom
  - dept
  - drug
  - food

responses:
  utter_first:
    - text: "您好,我是您的医疗助手Friende,我是个机器人,请问有什么可以帮您?"
  utter_greet:
    - text: "您好~"
    - text: "您好呀~"
  utter_goodbye:
    - text: "再见,祝您身体健康~"
    - text: "拜拜,希望我有帮到您~"
  utter_howcanhelp:
    - text: "您可以这样向我提问: 头痛怎么办/
                              什么人容易头痛/
                              头痛吃什么药/
                              头痛能治吗/
                              头痛属于什么科/
                              头孢地尼分散片用途/
                              如何防止头痛/
                              头痛要治多久/
                              糖尿病有什么并发症/
                              糖尿病有什么症状"
  utter_donknow:
    - text: "啊噢,我没有理解您说的话,我的理解力还需要更多的提升>_<。"

actions:
  - utter_first
  - utter_donknow
  - action_first
  - action_donknow
  - action_echo
  - action_search_treat
  - action_search_food
  - action_search_symptom
  - action_search_cause
  - action_search_disease
  - action_search_neopathy
  - action_search_drug
  - action_search_prevention
  - action_search_drug_func
  - action_search_disease_treat_time
  - action_search_easy_get
  - action_search_disease_dept
  - utter_greet
  - utter_howcanhelp
  - utter_goodbye
@hei-my hei-my added area:rasa-oss 🎡 Anything related to the open source Rasa framework type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors. labels Mar 30, 2021
@sara-tagger
Copy link
Collaborator

Thanks for the issue, @b-quachtran will get back to you about it soon!

You may find help in the docs and the forum, too 🤗

@twerkmeister twerkmeister self-assigned this Apr 6, 2021
@twerkmeister
Copy link
Contributor

twerkmeister commented Apr 12, 2021

Seems the problem is with the package terminaltables that we are using in the interactive training mode. The problem boils down to non-ascii characters potentially having a different width than ascii characters leading to some internal overflow in the table dimension calculations.

For example 210 character long chinese text from the issue creator:
"牙龈出血的症状对应得疾病可能有:肥大性龈炎、骨髓增生异常综合征、口腔疾病、小儿出血性疾病、边缘性龈炎、获得性维生素K依赖性凝血因子异常、小儿白血病、回归热、坏死性龈口炎、青春期功能失调性子宫出血、郎-奥韦综合征、急性淋巴细胞白血病、感染性血小板减少性紫癜、单纯性牙周炎、单核细胞白血病、δ-贮存池病、小儿特发性血小板减少性紫癜、老年人真性红细胞增多症、急性根尖牙周炎、慢性根尖牙周炎、创伤性口炎、青少年牙周炎、慢性牙周炎"

210 character long ascii text (in monospaced font):
'abcdefgaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'

The problem only arises after the texts have a certain length. For example, for an answer of 50 characters it still works. Crashing will happen somewhere between 50 and 100 characters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants