Friday, June 12, 2009

Creating a Conversational Interface using Python

Conversational Interfaces (CIs) are programs that permit humans to interact with computers using natural language. Conversational Interfaces are evolving from the simple "chat bot" and increasing in intelligence toward the realm of truly helpful artificial intelligent agents.

The Amy Iris project is a toolkit that facilitates the creation and usage of a central repository of Conversational Intelligence. In this blogpost, I show you how you can use the Amy Iris toolkit to create a Conversational Interface for your website or software.

Let's start with a demonstration of the power and simplicity of the Open Source Amy Iris API. For this example to work, you must install the Amy Iris API (one file, open source), which will be explained in another blog post. Yes, this is another "teaser" blog post... sorry!

Here's a sample program:


import amyirisapi
a=amyirisapi.AmyIris()
for i in range(3):
....kwargs={"textin":raw_input("You: ")}
....print "Amy: "+a.textin.submit(**kwargs)

This simple program prompts You for some input, and submits your input to the Amy Iris system, displaying her response.

Here's a sample execution:

You: Hi, how are you?
Amy: Hello there. I'm doing fine thanks how are you?
You: say I have an emergency in spanish
Amy: tengo una emergencia is i have an emergency in spanish.
You: Where is the nearest Best Buy to 45249?
Amy: The nearest Best Buy store to 45249 is the Fields Ertel OH store, which is 1.47 miles away, at 9871 Waterstone Boulevard.



(Note that the text follows "You:" was typed in by the user, and the text that follows "Amy:" was the system's response.)

Pretty cool simple little bot in five lines of code. The Amy Iris bot is an extended version of the award-winning ALICE chat-bot, built with Open Source components. In the above example, Amy's first response was the exact response from Alice, when presented with "Hi, how are you?"

But the second and third responses hint at the potential power of Amy Iris. The second response, the language translation, and the third response, the Best Buy store look-up, are both the results of a small open source code snippets that were submitted to the Amy Iris system by someone around the world (in this case, me!)

Amy Iris provides a central repository for open source code snippets written by developers from around the world. It's a community-developed bot: the wisdom of crowds boiled down into a conversational interface.

In an upcoming blog post, I'll tell you how this all works! Gotta keep ya coming back, right?

0 comments: