Free Alternative For The Cleverbot API
Project description
cleverbotfree
Cleverbot.com used to have a free API for their chatbot application. They have
removed their free API in place of a tiered subscription API service.
cleverbotfree is a free alternative to that API that uses a headless Firefox
browser to communicate with their chatbot application. You can use this module
to create applications/bots that send and recieve messages to the Cleverbot
chatbot application
Installation
Requirments
You need to have Python 3.x, pip, and the latest Firefox browser installed.
Once installed, you can install this library through pip.
pip install cleverbotfree
Drivers
Selenium requires a driver to interface with the headless browser. Firefox
requires geckodriver, which needs to be installed before this module can be
used. Make sure it’s in your PATH, e. g., place it in /usr/bin or /usr/local/bin.
You can download the geckodriver at https://github.com/mozilla/geckodriver/releases
Failure to observe this step will give you the error
"Message: ‘geckodriver’ executable needs to be in PATH."
Usage
Examples
Example of a simple CLI script that creates a single use, one message chat session.
import cleverbotfree.cbfree
import sys
cb = cleverbotfree.cbfree.Cleverbot()
def chat():
userInput = input('User: ')
response = cb.single_exchange(userInput)
print(response)
cb.browser.close()
sys.exit()
chat()
Example of a simple CLI script that creates a persistent chat session untill closed.
import cleverbotfree.cbfree
import sys
cb = cleverbotfree.cbfree.Cleverbot()
def chat():
try:
cb.browser.get(cb.url)
except:
cb.browser.close()
sys.exit()
while True:
try:
cb.get_form()
except:
sys.exit()
userInput = input('User: ')
if userInput == 'quit':
break
cb.send_input(userInput)
bot = cb.get_response()
print('Cleverbot: ', bot)
cb.browser.close()
chat()
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
Built Distribution
Hashes for cleverbotfree-1.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9565b9ef6c3ab83633160e88a313bd10cd3d3f68fb784e2435ba35c0ff8ff3ca |
|
MD5 | ba1f832f60fead8283a0c970c072b04c |
|
BLAKE2b-256 | 900463078ea73482d73f788bfffd53ce79c645ace1d018cfa323e5c1b20786d5 |