from pytlas import training, intent
@training('en') # Define some training data in your language
def greet_en_training(): return """
%[greet]
hey ~[there?]
hello ~[there?]
what's up
~[there]
there
you
"""
# Trainings are written using a tiny interpreter agnostic
# language and is available at:
# https://github.com/atlassistant/chatl
@intent('greet') # Handle the intent!
def on_greet(request):
# And do whatever you want, such as answering
request.agent.answer('Hello there!')
# And returns to the asleep state using done()
request.agent.done()
from pytlas import training, intent
@training('en')
def lights_en_training(): return """
%[lights_on]
turn lights on in @[room]
lights on in @[room]
@[room](extensible=false)
kitchen
bedroom
"""
@intent('lights_on')
def on_lights_on(request):
# Extract the first room value
room = request.intent.slot('room').first().value
if not room: # If there's none, ask for it
return request.agent.answer('room', 'Which room?')
# Else, do something with the room, control a philips Hue or whatever
return request.agent.done()
from pytlas import training, intent
@training('en')
def temperature_en_training(): return """
%[set_temperature]
raise the temperature to @[temperature_value]
set the temperature to @[temperature_value]
lower the temperature to @[temperature_value]
@[temperature_value](type=temperature)
30 degree
20 degree
13 degree
"""
# Possibilities are infinite, check the documentation!
# https://pytlas.readthedocs.io/en/latest/
@intent('set_temperature')
def on_set_temperature(request):
temp = request.intent.slot('temperature_value').first().value
# Put your logic to set the temperature here!
request.agent.answer(f'Setting temperature to {temp}')
request.agent.done()
Your assistant is powered by the open-source python library pytlas which will extract meaningful data from human language sentences and call your own code when its done.
It offers an easy to use API to make writing skills as painless as possible.
You can embed the library yourself or use some already developed application such as the broker which will expose your assistant across MQTT and other channels.
Want to help us build an open-source assistant and shape the future of atlas? Join us and start contributing 🙌!