Have you ever dreamed of having a conversation with a person from the distant past? Aristotle, William Shakespeare, Benjamin Franklin, Ada Lovelace … any person of your choice.
Would you like to create your own digital replica?
The long-term goal of this project is to make it a reality.
It should work as follows:
- Collect all the writings of the person in one place.
- Give it to AI-Replica.
- The software will try to reconstruct the person’s mind.
- If you ask the replica some question, it should provide an answer that is authentic to the original person.
- If you ask the replica to do some intelligent task, it should be able to do it, as good as the original.
We plan to iteratively expand the replica’s capabilities, to make the conversation more natural and more authentic.
This software and the sample data are under very permissive Creative Commons Zero v1.0 Universal license (basically, it describes a release into the Public Domain).
Clone this repo.
Navigate to the root dir of the repo.
Install make tool, so that you can execute useful commands from project's makefile.
Make sure Python3.9 is installed in the system and available via python3.9 command. (By default, the server uses Rasa which supports Python3.9 as of August 2022.)
Also make sure that the following packages are installed:
python3.9-distutils;python3.9-venv;python3.9-dev.
(You can install them by running sudo apt install python3.9-dev python3.9-venv python3.9-distutils).
Install prerequisites:
make install_prerequisites
Pre-requisites include:
- PyYAML Python module (it is required to read yaml config).
- colorama - used by installation script to output colored text in case of errors.
Install git hooks for the pre-push stage. See documentation/python.md for more info.
pip3 install pre-commit
pre-commit install --hook-type pre-pushInstall Node.js for the webchat development.
Notes.
- The project uses the
blackcode style.
Make sure that Prerequisites are satisfied.
Run the console bot:
make run_simple_console_bot
Make sure that Prerequisites are satisfied.
Install dependencies:
make install_dependenciesThe previous command creates Python3.9 virtual environment (it should be created in the root folder). Activate the venv:
source venv/bin/activate!!! Make sure that all the subsequent commands and work are done in this venv. !!!
Note. Alternatively, you can install general and Rasa's dependencies manually using requirements.txt files in the root dir of the repo and in the rasa dir. (e.g. python3.9 -m pip install -r requirements.txt)
Train Rasa model:
make train_rasa_model
Then you can launch all the servers by running:
make start_all
The UI chat will be available at http://localhost:8000/chat/ (prod mode).
Note. It can take a couple of minutes for Rasa server to start. Until that the UI can work incorrectly. You can check the status of Rasa server in the corresponding terminal (the one that starts reporting the message "Starting Rasa server"). Once the Rasa server is up, the terminal should report "Rasa server is up and running".
Run all in dev mode (server and chat):
make start_all_development_mode
The chat will open at http://localhost:3000 (dev mode).
Run webchat in development mode manually:
- Go to the
webchatfolder. - Install dependencies by running
npm installornpm ci. - Run
npm start. - The chat will open at
http://localhost:3000
By default, Rasa bot engine is used. Before running the server, make sure that:
- Rasa server is being run at
http://localhost:8002. - Rasa actions server is being run at
http://localhost:8004.
To turn off Rasa engine, change the value of the bot_engine setting in config.yaml.
For how to start Rasa, check Rasa docs.
Run the server bot (default port is 8000, default address is localhost):
python3 server_bot.py
or:
python3 server_bot.py --port=8000
For help, run:
python3 server_bot.py -h
Build web chat by running make build_ui. Then copy web chat to the server's static folder: make copy_web_chat_to_server.
Then open your browser and navigate to the \chat path at the address and port the server listens on (by default, the port is 8000) (e.g. http://localhost:8000/chat).
By default, conversations are stored in sqllite in-memory db. In case you want to preserve conversations history between server reloads, you need to:
- set path to db file in the
db_pathfield in server's config. - set sqlite in-file tracker store in Rasa's endpoints.yml (just uncomment the corresponding tracker store and provide path to you db file).
Note. Two dbs are used currently: server's one and Rasa's one - for the sake of concerns separation.
You can activate voice output in the UI chat by setting text_to_speech_activated option in the server's config to true and specifyig TTS engine.
Currently, the voice output can be provided by consuming Google's api on server-side. Also, pyttsx3 output is possible.
Install espeak-ng for text-to-speech generation by pyttsx3: sudo apt install espeak-ng.
Please check how to launch Rasa and other project-related Rasa docs here: Rasa docs.
To run doctests, execute doctests_run