글을 불러오는 중…
글을 불러오는 중…
Rasa Form Handling: 자동화된 Slot Filling 이해하기 Rasa를 사용하면서 에 정의된 들이 에 명시되지 않았음에도 불구하고 정상적으로 응답되는 이유에 대해 고민해 본 적이 있나요? 이번 글에서는 Form과 Slot Filling 메커니즘을 통해 이 과정을 상세히…
Rasa를 사용하면서 domain.yml에 정의된 utter들이 stories.yml에 명시되지 않았음에도 불구하고 정상적으로 응답되는 이유에 대해 고민해 본 적이 있나요? 이번 글에서는 Form과 Slot Filling 메커니즘을 통해 이 과정을 상세히 설명합니다.
📚 출처: Rasa Forms 공식 문서
먼저, provide_travel_info 인텐트가 감지되면 rules.yml의 "Activate travel form" 규칙이 트리거됩니다.
- rule: Activate travel form
steps:
- intent: provide_travel_info
- action: travel_form
- active_loop: travel_form
이 규칙에 따라 travel_form이 활성화되고, 대화의 흐름은 Slot Filling 단계로 넘어갑니다.
domain.yml에는 travel_form이 정의되어 있으며, **location**과 **days**라는 필수 슬롯(required_slots)이 포함되어 있습니다.
forms:
travel_form:
required_slots:
- location
- days
슬롯이 채워지지 않은 경우:
location이 비어 있으면 → utter_ask_location 호출
days가 비어 있으면 → utter_ask_days 호출
이렇게 utter_ask_{slot_name} 패턴은 Rasa가 폼 실행 시 자동으로 호출하는 규칙입니다. 그래서 stories.yml에 명시적으로 작성하지 않아도 자동으로 실행됩니다.
사용자: "서울로 3일 여행 가고 싶어"
location = 서울
days = 3
모든 슬롯이 채워졌기 때문에 travel_form은 즉시 제출됩니다.
rules.yml의 "Submit travel form" 규칙에 따라 utter_confirm_travel이 호출됩니다.
사용자: "서울로 여행 가고 싶어"
location = 서울
days = (없음)
travel_form은 days를 채워야 하므로 자동으로 **utter_ask_days**를 호출합니다.
사용자가 "3일이요"라고 답하면 폼이 제출됩니다.
사용자: "여행 가고 싶어"
location = (없음)
days = (없음)
travel_form은 먼저 **utter_ask_location**을 호출하여 위치를 요청합니다.
위치를 받은 후에는 **utter_ask_days**를 호출하여 기간을 요청합니다.
폼 활성화 → required_slots 확인
비어 있는 슬롯 발견 → utter_ask_{slot_name} 자동 호출
슬롯 모두 채워짐 → 폼 제출 → utter_confirm_travel 호출
따라서 utter_ask_location과 utter_ask_days가 stories.yml에 없어도 자동으로 호출되는 것입니다. 🎯
domain.ymlrecipe: default.v1
assistant_id: 20250115-115620-chief-level
intents:
- provide_travel_info
entities:
- location
- days
slots:
location:
type: text
influence_conversation: true
mappings:
- type: from_entity
entity: location
days:
type: text
influence_conversation: true
mappings:
- type: from_entity
entity: days
forms:
travel_form:
required_slots:
- location
- days
responses:
utter_ask_location:
- text: "어디로 여행가고 싶어?😄"
utter_ask_days:
- text: "몇 일동안 머무를 예정이야?🧐"
utter_confirm_travel:
- text: "좋아요😍 {location}으로 {days}일동안 여행할 일정을 계획해볼게요😎"
rules.ymlrules:
- rule: Activate travel form
steps:
- intent: provide_travel_info
- action: travel_form
- active_loop: travel_form
- rule: Submit travel form
condition:
- active_loop: travel_form
steps:
- action: travel_form
- active_loop: null
- action: utter_confirm_travel
stories.ymlstories:
- story: Complete travel booking
steps:
- intent: provide_travel_info
- action: travel_form
- active_loop: travel_form
- active_loop: null
- action: utter_confirm_travel
Rasa의 Form 기능은 Slot Filling을 자동화하여 개발자의 수고를 덜어줍니다. 이 메커니즘을 잘 활용하면 효율적인 챗봇 개발이 가능합니다. 🚀
📖 더 알아보기: Rasa 공식 문서