Vytváření osobnosti

Building Chatbots in Python

Alan Nichol

Co-founder and CTO, Rasa

Proč osobnost?

  • Rozdíl mezi příkazovým řádkem a chatbotem
  • Chatboty a hlasové asistenty zpřístupňuje a zpříjemňuje
  • Uživatelé to očekávají!
Building Chatbots in Python

Malá konverzace

responses = {
    "what's your name?": "my name is EchoBot",
    "what's the weather today?": "it's sunny!"
}

def respond(message): if message in responses: return responses[message]
respond("what's your name?")
'my name is EchoBot'
Building Chatbots in Python

Použití proměnných

responses = {
    "what's today's weather?": "it's {} today"
}

weather_today = "cloudy" def respond(message): if message in responses: return responses[message].format(weather_today) respond("what's today's weather?")
"it's cloudy today"
Building Chatbots in Python

Výběr odpovědí

responses = {
    "what's your name?": [
      "my name is EchoBot",
      "they call me EchoBot",
      "the name's Bot, Echo Bot"
    ]
}

import random
def respond(message): if message in responses: return random.choice(responses[message])
respond("what's your name?")
"the name's Bot, Echo Bot"
Building Chatbots in Python

Kladení otázek

responses = [ "tell me more!", "why do you think that?" ]

import random

def respond(message):
    return random.choice(responses)

respond("I think you're really great")
'why do you think that?'
Building Chatbots in Python

Pojďme procvičovat!

Building Chatbots in Python

Preparing Video For Download...