PAIAssistant is a AI tool designed for users interact with emails via natural language queries. This demo showcases its ability to organize emails using a vector database. It features various Retrieval-Augmented Generation (RAG) methods including Basic Retrieval, Sentence Window Retrieval, and Auto-Merging Retrieval. These methods enhance the processing of user queries, which are then handled by a Large Language Model (LLM) like OpenAI's. The AI generates responses that can be either displayed on-screen or read aloud, offering a comprehensive and user-friendly email management experience.
The best way to support Kwaai is to give us a ⭐ on GitHub and join our slack community!
- Install docker desktop from Docker Desktop
- Clone the git repository
- Change to PAIAssistant folder and run "docker-compose build"
- Once Step 3 completes you should have paiassistant-pai:latest image in docker ( mine was about 20GB or so )
- Run image using "docker run -it --rm -p 4000:4000 --gpus all paiassistant-pai:latest"
- At this point you should be able to visit https://127.0.0.1:4000. It wont function fully until you populate it with your data.
- Find your container name using
docker ps --format "{{.Names}}"
- Copy pdf files to container in a folder for eg. "docker cp Mypdfdir (containername from step 7):/pai/api/data/Mypdfdir
- Update api/config.ini file to use the newly created folder in step 8 for indexing and querying.
- Download and Copy your model file to api/models folder using same step like you used the pdf copy in step 8. Openchat 3.5
- Update the api/config.ini to reflect the model file name.
- Run api/createindex.py to create the index.
- Start the api process using "python api.py" from api folder.
- Now you can chat with the files using https://127.0.0.1:4000
- [Optionally update the prompt in the api.py and restart to suit the files knowledge base]
The steps below can be used to setup the enviroment for this demo to run on Ubuntu 20.04.6 LTS. Alternatively you can setup the python3.10 environment on a windows machine with Nvidia gpu card with necessary drivers. The install will run with or without GPU. Running locally would be very slow on CPU inference. Running with OpenAI support could be alternative if GPU is not available.
Optional: Check flag/api key settings in documentation to use OpenAI if you dont have a computer with GPU
NOTE: This example VM setup will work for OpenAI inference. Local inference will be very slow due to lack of GPU. For local inference use a machine with GPU, windows or linux.
- Download Ubuntu 20.04.6 LTS server ISO image.
- Download Oracle VirtualBox.
- Create a new virtual machine with the ubuntu image downloaded above. Sample configuration is 4gb ram, 2 vcpu, bridged network settting, 25 gb disk.
- Optional : Signup for platform.openai.com and generate OpenAI api key
- Change directory to web. If necessary update host/port parameter in config.json
- Change directory to web/public. Update the completion.apiendpoint to the ip address of your instance.
- Change directory to api. Update config.ini to update host/port parameters if needed.
cd PAIAssistant
./setupenv.sh
- Create a new folder under api/data and copy over the data in pdf/csv/doc etc
- Update api/config.ini to update the folder name data/ and run createindex.py to create the vector index (basic/sentence/automerge) for query.
cd api
# By default index is created using local embedding file in config.ini
# if you dont have gpu, use export below and set useopenai flag to true to use openai api.
# adjust modelname accordingly for openai.
# export OPENAI_API_KEY=<YOUR OPENAI API KEY>
python createindex.py
Choose which version of index to query by updating the config.ini in api folder [api] section.
cd web
npm start
cd api
# export below is optional. Use when you dont have gpu or if you want to use openai models.
#export OPENAI_API_KEY=<YOUR OPENAI API KEY>
python api.py
To use openai set the following attribute in api/config.ini. By default it is set to false.
useopenai=true
- https://[ipaddress]:4000 in chrome browser to use the demo.
- https://[ipaddress]:7860 gradio text input/response interface.
- Create a jupyter notebook
- Create google colab notebook
- Create git workflow to post to hosting platform to visualize it.
This project is CC-BY-4.0 licensed.