Conversational AI Design and Practice
GitHubAuthor
  • Preface
    • Syllabus
    • Schedule
  • 0. Getting Started
    • 0.1. Environment Setup
    • 0.2. Quiz
  • 1. Exploration
    • 1.1. Overview
    • 1.2. Project Ideas
    • 1.3. Quiz
  • 2. Dialogue Graph
    • 2.1. Emora STDM
    • 2.2. State Transition
    • 2.3. Matching Strategy
    • 2.4. Multi-turn Dialogue
    • 2.5. Quiz
  • 3. Contextual Understanding
    • 3.1. Natex
    • 3.2. Ontology
    • 3.4. Regular Expression
    • 3.5. Macro
    • 3.5. Quiz
  • 4. Interaction Design
    • 4.1. State Referencing
    • 4.2. Advanced Interaction
    • 4.3. Compound States
    • 4.4. Global Transition
    • 4.5. Saving and Loading
    • 4.6. Quiz
  • 5. LM-based Matching
    • 5.1. Language Models
    • 5.2. Quickstart with GPT
    • 5.3. Information Extraction
    • 5.4. Quiz
  • 6. Conversational Analysis
    • 6.1. H2H vs. H2M
    • 6.2. Team Evaluation
    • 6.3. Quiz
  • Project
    • Projects
    • Proposal Guidelines
    • Final Report Guidelines
  • Supplements
    • LINC Course
    • Page 1
Powered by GitBook

©2023 Emory University - All rights reserved

On this page

Was this helpful?

Export as PDF
  1. 2. Dialogue Graph

2.4. Multi-turn Dialogue

Create a multi-turn dialogue flow.

All examples in the previous session are single-turn dialogues, where users get to interact with the system only once. Let us design a multi-turn dialogue:

transitions = {
    'state': 'start',
    '`Hello. How are you?`': {
        '[{good, fantastic}]': {
            '`Glad to hear that you are doing well :)`': {
                '[{how, and}, {you, going}]': {
                    '`I feel superb. Thank you!`': 'end'
                }
            }
        },
        'error': {
            '`Got it; thanks for sharing.`': 'end'
        },
    }
}
  • #5: after the system says "Glad to ...", it matches the input with those conditions.

  • #6: if the condition in #5 is true, the system responds with "I feel superb ...".

S: Hello. How are you?
U: Good!
S: Glad to hear that you are doing well :)
U: How are you doing?
S: I feel superb. Thank you!
S: Hello. How are you?
U: Fantastic
S: Glad to hear that you are doing well :)
U: Thank you!
Traceback (most recent call last):
...

The condition in #6 does not come with the default action indicated by an error transition. Let us create an error transition for it:

def multiturn_dialogue() -> DialogueFlow:
    transitions = {
        'state': 'start',
        '`Hello. How are you?`': {
            '[{good, fantastic}]': {
                '`Glad to hear that you are doing well :)`': {
                    '[{how, and}, {you, going}]': {
                        '`I feel superb. Thank you!`': 'end'
                    },
                    'error': {
                        '`You are the best!`': 'end'
                    }
                }
            },
            'error': {
                '`Got it; thanks for sharing.`': 'end'
            },
        }
    }

    df = DialogueFlow('start', end_state='end')
    df.load_transitions(transitions)
    return df


if __name__ == '__main__':
    multiturn_dialogue().run()
  • #10: prompts the error statement for any other inputs.

S: Hello. How are you?
U: Fantastic!
S: Glad to hear that you are doing well :)
U: Thank you!
S: You are the best!
Previous2.3. Matching StrategyNext2.5. Quiz

Last updated 2 years ago

Was this helpful?