RASA - 규칙 및 테스트 양식
그러나 변경하기 전에 양식에 대한 테스트를 작성하여 변경하려는 변경 사항이 아무 것도 손상시키지 않는지 확인하십시오.
테스트 양식 행복 경로
Let's add the following test story to our tests/test_stories.yml
file.
# tests/test_stories.yml
# ... previous contents ...
- story: newsletter form happy path
steps:
- user: |
hi
intent: greet
- action: utter_greet
- user: |
I want to subscribe
intent: subscribe
- action: newsletter_form
- active_loop: newsletter_form
- user: |
my email is [[email protected]](email)
intent: inform_email
- action: newsletter_form
- user: |
twice a week
intent: inform_frequency
- action: newsletter_form
- active_loop: null
- action: utter_subscribed
Let's go though this test line by line.
- action: newsletter_form
및 - active_loop: null
로 끝나야 합니다. rasa test
를 실행하여 테스트가 통과하는지 확인하십시오.이제 개선 사항으로 돌아가 봅시다!
규칙
규칙은 대화에서 이전에 말한 내용에 관계없이 항상 동일한 경로를 따라야 하는 대화 부분을 설명합니다.
우리는 어시스턴트가 항상 특정 작업으로 특정 의도에 응답하기를 원하므로 규칙을 사용하여 해당 작업을 의도에 매핑합니다.
우리의 경우 사용자가 구독 의도를 표현할 때마다 newsletter_form을 트리거하려고 합니다.
# data/rules.yml
version: "2.0"
rules:
- rule: activate subscribe form
steps:
- intent: subscribe
- action: newsletter_form
- active_loop: newsletter_form
또한 모든 필수 정보가 제공되면 utter_subscribed 작업을 트리거하려고 합니다.
# data/rules.yml
# ... previous contents ...
- rule: submit form
condition:
- active_loop: newsletter_form
steps:
- action: newsletter_form
- active_loop: null
- action: utter_subscribed
제출 양식 규칙은 처음부터 newsletter_form이 활성화된 경우에만 적용됩니다. 더 이상 활성화되지 않으면(
- active_loop: null
) 양식이 완성됩니다.이제 인사 및 구독 스토리가 더 이상 필요하지 않으며
data/stories.yml
에서 삭제할 수 있습니다.rasa test
를 실행하면 두 테스트 모두 통과했음을 알 수 있습니다!그러나 규칙은 보이지 않는 대화로 일반화되지 않습니다. 단일 전환 대화 스니펫용으로 예약하고 스토리를 사용하여 다중 전환 대화를 훈련해야 합니다. 자세한 내용은 documentation .
documentation에서 규칙에 대해 자세히 알아볼 수 있습니다.
다음 장에서는 불행한 경로를 처리하는 방법을 살펴보겠습니다.
이 튜토리얼의 저장소:
펫7555 / rasa-dev-튜토리얼
이 튜토리얼의 끝에서 다음을 실행하여 리포지토리의 상태를 체크아웃할 수 있습니다.
git clone --branch 04-rules-and-testing-forms [email protected]:petr7555/rasa-dev-tutorial.git
Reference
이 문제에 관하여(RASA - 규칙 및 테스트 양식), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/petr7555/rasa-rules-and-testing-forms-4ffa텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)