Amsh

APE MACHINE SHELL (amsh): An A.I. Enhanced Command Line Interface

APE MACHINE SHELL is a command line interface that has been enhanced with chatbot capabilities.

By adding chatbot capabilties to a command line interface we will be able to experiement with a more natural language approach to dealing with the console. This is mostly a toy exercise, and a way to experiment with the various chatbot api platforms that are out there, but with enough work, I think something quite interesting can be done here.

SIGN UP FOR OUR NEWSLETTER

The newsletter will keep you informed of interesting projects in the fast-growing field of A.I. and machine learning.
Of course, we promise we will not spam you, and no shameless self-promotion.

PRO TIP: Highlight any text to share a quote easily!

I have been having a lot of fun with chatbots lately, which I previously described, are considered to be the "new app," taking the throne of mobile applications in the developer space.
For a project I am doing at work, we had a need for something resembling a customer service bot, that is able to hold down natural language conversations with the users of our platform, and we ended up using the services provided by api.ai.

At some point during this process, in an hour where I was a little bored, I had an idea that was both functional, as well as a little wacky.
Since the work project puts the chatbot in a position that takes quite some steps to reach within the overall application, and especially in the beginning requires a lot of testing and play to refine, I wanted to have a more stripped down, and simplified environment to do this in.
The wacky part came into play when I decided to code a quick little command line interface in Ruby, because I, for some strange reason, felt a need inside of me to be able to politely ask the computer to copy a file for me, instead of typing in the same tired old raw commands.
 

APE MACHINE SHELL, or amsh for short, is the result of this, and I now consider it more of a joke, or fun little project, than anything else, although I would like to see how far I can take this usability wise.
You can get it from github, if you feel the need to, and see how this will develop in the future. As for now, it is merely a proof of concept, and the only real command you can perform is actually quiting the shell.
It does do small talk though, and yes, it has text-to-speech, of course.

 

How does it work?

amsh (APE MACHINE SHELL) is a command-line shell enhanced with an A.I. chatbot.

For the A.I. chatbot we use the api.ai service, which handles all the small talk, as well as attempting to encode natural language into processable commands. This shell tries to combine the functionality of many tools on the system, so there are 4 steps in which any given input is processed, detailed below.

STEP 1

Send the user input off to api.ai and try to get a valid response. If this is categorized as small talk, just echo back the response, and run it through text-to-speech for a futuristic effect. If the chatbot recognizes this as an actual command, and all the required parameters are in place, send back an encoded string response that will perform the command inside the shell, using any of the following methods. If there are required parameters missing, use the api.ai chatbot to ask the user to define them in a natural language way.


STEP 2

If the chatbot ends up in its fallback state, echo back a singular response "escalate-command" which is caught by the interpreter, and results in its own fallback mechanism to kick in. In this step, we hand the command off to the host shell, and see what exit status and output receive. If the exit status is 0, we know that the command ran successfully, and we are returned back to the amsh prompt, with the output from the host shell echoed to us. If the exit status is anything else than 0, we fall back to the following step.
STEP 3

We now hand the command off to the Ruby interpreter, and see what the result of this is. If we do not receive an error, we know that the command (line of code), was interpreted, and we can either return to the amsh prompt, or in the case of a block, continue inputting lines of code. If there is an error, we continue to step 4. (currently not implemented)
STEP 4

Finally, after the previous steps all failed to produce correct results, we hand the command off to the internal command mechanism. This first tries to include a file from the ./bin directory, with the filename equal to the command method, without parameters. It then converts the method name into a Class, and tries to instantiate that, before running the .run method on the newly instantiated class. The way this is implemented means, obviously, that additional commands are basically hot-swappable, and there is no need to restart amsh when making changes to, or adding new commands in the ./bin directory.

How to install amsh?

  1. Make sure to install all the gems required at the top of amsh.rb
  2. Install mpg123 (for text-to-speech)
sudo apt-get install mpg123 #for debain based
brew install mpg123 #mac 

 

Improvements I want to make 
 

  • After trying to pass the command to the shell, and the exit status being anything else than 0, try to pass the command to Ruby itself, and see if we can run it that way. Then, and only then, try to handle it as an internal command.
  • Implement recognition in the chatbot for desired actions, and collect all the required parameters.

    ps. For those of you who have read "I Have No Mouth And I must Scream," don't worry your pretty little head about the prompt ;) It's purely a coincidence...
Chatbot ai

My Chatbot Hates Me!

You may be wondering: Has the Singularity happened? Has artificial intelligence turned itself against us?

Then you may be relieved when I tell you nothing even close to this has happened, but over the span of a very short test, I did turn my new best friend against me, and my new best friend was indeed a chatbot...

Distributed comp

Ghetto Distributed Computing For Neural Networks

Using an unlikely technique, we can actually set up a very scalable distributed service for neural networks. We will look into setting up a simple javascript include on any website to turn any visitor into a node.

Muskrisk

Elon Musk vs. Artificial Intelligence?

By now you are probably aware of Elon Musk's performance at the National Governors Association's meeting, where he proceeded to express his deep concerns about artificial intelligence, and that there is a need for regulation and for researchers and companies to "slow down."

No doubt about it, things are moving fast, and some people calling themselves experts are even saying that we are moving a lot faster than earlier predictions by other experts. Whether that is true or not, I think we can all agree that we need to start actively and openly discussing the safety concerns surrounding A.I.

Meanwhile, we also need to start identifying the true valuable resources in this field when it comes to expertise, because sure: Elon Musk may have invested in start OpenAI, but that does not make him an expert, and after his remarks recorded on video, most of the truly important machine learning researchers have spoken out against him.

Elon Musk is first and foremost a businessman, and we need to realize that when taking in his words, and question what his motivations are when he say he thinks there should be more regulation, and other (competing) companies should slow down their research.