Running Personal MAIC Deployment

Preparation

Please make sure you have Docker for your specific OS platform and Python3[?] installed.

Clone Repo

Clone the repo using Git and navigate to the root directory of the project:

git clone git@github.com:THU-MAIC/MAIC-Core.git maic
cd maic

Install pip dependencies

Pip install Requirements with Python >= 3.11:

pip install -r requirements.txt

Initialize MongoDB

Download the MongoDB dump file from this link and unzip the dump file in the current directory. Example of in linux bash (use other commands for other platforms):

# downlod dump file
wget -O dump.zip https://cloud.tsinghua.edu.cn/f/33d4e25fc62041e1b943/?dl=1
# unzip dump file
unzip dump.zip

Then, run the following commands to initialize the MongoDB database in docker:

# install mongo
docker pull mongo:4.4.4
# create mongo from ${your_dump_path}/dump:/mongo_dump
docker run -d --name algo-new-mongo -v ${your_dump_path}/mongo_dump:/dump -p 27017:27017 mongo:4.4.4
# initialize database
docker exec -it -u root algo-new-mongo sh -c "cd /dump && mongorestore ./"

Initialize RabbitMQ

# install rabbitmq-server
docker pull rabbitmq:management
# start rabbitmq
docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.9.15-management

InClass Deployment

Deploy InClass Worker

Run the following code in two separate terminals in the root directory of algo-backend:

# deploy zhipuai workers
python -m service.llm.zhipuai --zhipu_api_key <replace with your zhipuai apikey>
# deploy classroom_session workers
python -m service.inclass.main

Running Commandline Interface

Run the following code in a new python console to initialize the course course “TAGI” by Zhiyuan Liu(modification needed):

python
# Run an inclass example
>>> from service.inclass.main import INCLASS_SERVICE
# Start the inclass service with specified session id, which can be replaced with your own session id created by PreClass service in the MongoDB database
>>> INCLASS_SERVICE.trigger("674ff0c87baecad6fd515719")
# Continue the inclass service with user input
>>> INCLASS_SERVICE.trigger("674ff0c87baecad6fd515719", user_input="Hello!")

PreClass Deployment

PreClass is a service indenpendent from InClass, which helps to create your own class agenda by uploading your slides. We have provided an created inclass agenda from course “TAGI” by Zhiyuan Liu(modification needed).

Deploy PreClass Worker

Run the following code in the root directory of algo-backend:

# deploy openai workers in a separate terminal
python -m service.llm.openai

# deploy main workers in a separate terminal
python -m service.preclass.main

# deploy processors
python -m service.preclass.processors.pptx2pdf
python -m service.preclass.processors.pdf2png
python -m service.preclass.processors.ppt2text
python -m service.preclass.processors.gen_description
python -m service.preclass.processors.gen_structure
python -m service.preclass.processors.gen_readscript
python -m service.preclass.processors.gen_showfile
python -m service.preclass.processors.gen_askquestion

Running Commandline Interface

Make sure you have a slide file named “your_slide.pptx” in the root directory of maic. Run the following code in the python console:

# Run a preclass example
>>> from service.preclass.main import PRECLASS_MAIN
# Trigger a preclass job
>>> PRECLASS_MAIN.trigger("your_slide.pptx")