A downloadable API

What is LaylaAI

LaylaAI Chatbot is a Python API that allows the user to easily create a functional machine learning-based chatbot. Intents can be edited/added to fit anyone's purpose.


Usage

Since the API is still in a beta state, there is no guarantee, many things might still change.

Functions

FunctionArgument explanationReturns
.respond(input, length)input: The text that
the bot should respond to
**length: The max length of
the respond. Set to 0 for infinity.
Respond to the
given input (String)
.learn(epoch)  *epoch: number of epochs
nothing
.getTag(input)input: The text that you
want to get the tag of
Tag of the given input.
For example: "greeting" 
(String)
.info()nothingnothing

* optional  **not added in the current version

Setup

  1. Download the API
  2. Extract the 'LaylaAI' folder in the .zip file into your project*
  3. Run 'install.py' inside that folder
  4. After the install process is finished, you are ready to go to use the API.

*Don't rename this folder or remove ANY of its files

Code examples

Importing the LaylaAI Chatbot
import LaylaAI
import LaylaAI.chatbot as chatbot


Simple script for chatting via the console
Script
  while True:
     inp = input("You: ")
     outp = chatbot.respond(inp)
     print('Layla: ' + outp)
Console
> You: Hello
> Layla: Hey!
> You: Bye!
> Layla: See you later
Simple script for training the model
layla.learn("intents.json", 1000)

There are probably going to be errors. This is because of TensorFlow. If you did everything like it is explained above, you should be good if you ignore them.


Intents file

Example

{"intents":  [
   {"tag":  "greetings",
   "patterns": ["hello", "hey", "hi", "good day", "greetings", "what's up?", "how is it going?"],
   "responses":  ["Hello!", "Hey!", "Hey There!"],
   "responses2":  ["What can i do for you?", "How can i help you?", "How are you?", "", "", ""],
   },
   {"tag":  "bye",
   "patterns": ["bye", "goodbye", "see you later", "i am leaving", "ciao", "cao", "see you", "i got to leave"],
   "responses":  ["Allright", "", ""],
   "responses2":  ["Talk to you later!", "See you later", "Bye!", "Goodbye", "See you", "Have a nice day"],
   },
]}

How it works

Every intent has 4 parameters: "tag", "patterns", "responses" and "responses2".  The tag is the name of the intent. The patterns are examples of what the input has to be, for it to be that intent. For example "hello" is an example of the intent with the tag "greeting". These patterns are only examples. That means, that if the input is for example "Hello, Layla", it is similar enough to "Hello" so it gets assigned to the intent with the tag "greeting". When the ai has figured out, what the right intent is, it picks a random item from the "responses" list and one from the "responses2" list. These two strings get smushed together to form the end response. LaylaAI.respond() returns it. 

You can add as many intents as you wish. The learning process is going to be affected.


A step by step tutorial will be added here in the future.


The 'intents.json' file that comes with the API is not final. Currently we are working on making the API functional and user friendly. After that we are going to train the model with as much data as we can. Version 1.0 the pre trained model will be trained on a much much bigger intents file.



Download

Download
LaylaAI Chatbot LATEST.zip 29 kB

Development log