High-speed conversational dialogue engine
Project description
What is it?
Flipgenic is a library for creating simple chatbots. A Flipgenic bot starts with an empty mind and learns how to communicate over time by reusing messages it has seen in previous conversations. It does not write anything original.
Here is an example from its use in Axyn:
Flipgenic is focused on fast reply times and a simple API. Chatterbot, a more well-known library, has additional features such as custom filters and logic adapters.
How do I use it?
Here is a basic example:
# python -m pip install flipgenic
# python -m spacy download en_core_web_md
from flipgenic import Responder
# Create and connect to database
# This can take a while to load the spaCy models
responder = Responder('/path/to/data/folder/')
# Initialize the database with a single response
responder.learn_response('Hello', 'Hi!')
response = None
while True:
text = input('> ')
if response:
# Learn the input as a response to the previous output
responder.learn_response(response, text)
# Generate a response
response, distance = responder.get_response(text)
print(response.text, f'({distance})')
For more, see ReadTheDocs.
How does it work?
- Upon calling
get_response
, the input is converted to a 300-dimensional vector. The vector embeddings for each word are provided by SpaCy; calculating the mean gives a single vector representing the whole text. - A closest match is found by searching the vectors of previously seen messages. An NGT index improves performance.
- The search result corresponds to one or more known responses. These responses are stored in an SQLite database.
- We select a matching response at random. The same response might have been learned more than once, giving it a higher chance of selection.
- Along with the selected response, the distance between the input vector and the search result is returned as a confidence heuristic.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
flipgenic-2.2.0.tar.gz
(17.0 kB
view hashes)
Built Distribution
flipgenic-2.2.0-py3-none-any.whl
(17.5 kB
view hashes)
Close
Hashes for flipgenic-2.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b703fc00d4e4593771a40501c7f7668258c37c93fdc8af055050672ac8d003c5 |
|
MD5 | 570757a63fc265b772784712c7413e84 |
|
BLAKE2b-256 | 68a6ec7960446b945dbda1b75b17564093ac65e28ebd72c815a165830f2ec13e |