- This part invokes Openai API to send a message and receive an answer. In particular, it creates an assistant and maintain a thread during the conversation
- It is supported by OpenAI and GPT-3
To obtain an API key, you need to sign up for an OpenAI account and log in to OpenAI platform.
- Student 1: Boxuan Hu, t0933356.
- Student 2: Xiliang Xian, t0933753.
- Student 3: Xinyuan Xia, t0933528.
- Student 4: Shuyang Zhou, t0933418.
This system is an AI-assisted document editor based on Kubernetes, integrating multiple components such as a frontend interface, backend processing, data preprocessing, message queue, data storage, knowledge base generation, and AI interaction.
The whole system is designed with scalability, high availability, and efficient data processing in mind, aiming to provide a smooth and intelligent document editing experience.
It leverages LLM to improve user development efficiency and fully collects and utilizes various data generated during user development to enhance the accuracy of the dedicated model and enrich its knowledge base.
Main Function
- AI-assisted document editor based on Kubernetes and Cloud
- Multiple components for efficient and intelligent document editing
- Collecting data when using for a project-tailored AI
- Frontend Pod: User interface for document input and editing.
- Preprocessing Pods: Cleanses and formats input data.
- Context Organizer Pod / Cloud Drive: Formats content for display and interaction.
- Message Queue: Temporary data storage and transmission.
- OpenAI Interaction Job: Uses AI-assistant to handle requests.
- Knowledge Base File Generation: Create structured knowledge files.
- MongoDB Database: Persistent document storage.
- Backend API Pod: Uses correction messages from mongoDB Database to finetune a new model.
You can visit here to explore this App (updated on 18/07/2024)
List all the prerequisites needed to set up the environment.
-
Node.js:
- Version: v22.4.1
- Installation: node-Installation
-
React:
- Version: @18.3.1
- Installation: react-Installation
-
Python:
- Version: 3.10.12
- Installation: python-Installation
-
AWS CLI:
- Installation: AWS-CLI-Installation
-
Kubectl:
- Installation: Kubectl-Installtion
-
Python Library:
-
pip install -r requirements.txt
-
Tips: Actually, this part (3.2) is not necessary if you just want to experience our App rather than deploying it.
Structure
- main
- AI-system
- AI Agent
- Dockerfile
- ai-agent.py
- AI Finetune
- Dockerfile
- finetune.py
- AI Agent
- Kubenetes
- client
- Dockerfile
- client.py
- client
- Drive
- cloud
- Dockerfile
- server.py
- cloud
- Web
- README.md
- Local Deployment
- Cloud Deployment
Step 1: Clone and Checkout
cd ai-agent
docker build -t <your dockerhub name>/ai-agent .
docker push <your dockerhub name>/ai-agentThen change image name in ai-deployment.yaml to <your dockerhub name>/ai-agent.
For the second, no additional steps are needed.
In this part, we've used a k8s object secret to protect our API key. First run the following command to encode your API key:
echo -n "<your_api_key>`" | base64for example:
echo -n "sk-1234567890" | base64Then replace the value of api-key in ai-secrets.yaml with the output of the above command.
Obtain API Key
To obtain an API key, you need to sign up for an OpenAI account and log in to OpenAI platform.
To use assistant and finetune, you may need to top up some money (like 5 dollars) in advance through a foreign credit card (American credit card works for me).
Dockerize the application
You can either build a docker file locally or pull the image from our docker hub. For the first option, you can run the following command:
cd ai-agent
docker build -t <your dockerhub name>/ai-agent:v1 .
docker push <your dockerhub name>/ai-agent:v1Then change image name in ai-deployment-2.yaml to <your dockerhub name>/ai-agent:v1.
For the second, no additional steps are needed.
Modify the secrets
In this part, we've used a k8s object secrets to protect our API key. First run the following command to encode your API key:
echo -n "<your_api_key>`" | base64for example:
echo -n "sk-1234567890" | base64Then replace the value of api-key in ai-secrets-2.yaml with the output of the above command.
Deploy the application
After connecting to the cloud and forms a cluster, you can run the following code to build the application:
git checkout AI-system
cd ai-agent
kubectl apply -f ai-secrets-2.yaml
kubectl apply -f ai-service-2.yaml
kubectl apply -f ai-deployment-2.yamlObtain API Key
Follow instructions from AI-agent. finetune has been bound to the same secret in finetune-deployment-2.yaml
Dockerize the application
You can either build a docker file locally or pull the image from our docker hub. For the first option, you can run the following command:
git checkout finetune
cd finetune
docker build -t <your dockerhub name>/finetune:v1 .
docker push <your dockerhub name>/finetune:v1Then change image name in finetune-deployment-2 yaml to <your dockerhub name>/finetune:v1.
For the second, no additional steps are needed.
Deploy the application
After create a cluster successfully, run the following command in order to build the finetune part:
kubectl apply -f aws-finetune-pv.yaml
kubectl apply -f aws-finetune-pvc.yaml
kubectl apply -f finetune-service-2.yaml
kubectl apply -f finetune-deployment-2.yamlNote that finetune is rather costly.
Dockerize Cloud Drive
You can either build a docker file locally or pull the image from our docker hub. For the first option, you can run the following command:
git checkout Drive
cd cloud
docker build -t <your dockerhub name>/cloud:v1 .
docker push <your dockerhub name>/cloud:v1Then change image name in cloud-deployment yaml to <your dockerhub name>/cloud:v1.
For the second, no additional steps are needed.
Deploy Cloud Drive
Run the following command in order to build the cloud drive:
kubectl apply -f aws-cloud-pv.yaml
kubectl apply -f aws-cloud-pvc.yaml
kubectl apply -f cloud-service.yaml
kubectl apply -f cloud-deployment.yamlThe Mongodb image is pulled from the official dockerhub.
Deploy Mongodb
Run the following command in order to build the Mongo database:
kubectl apply -f aws-mongodb-pv.yaml
kubectl apply -f aws-mongodb-pvc.yaml
kubectl apply -f mongodb-service.yaml
kubectl apply -f mongodb-secrets.yaml
kubectl apply -f mongodb-deployment.yamlIn any case, deployment.yaml should be applied in the last step.
Dockerize the client
You can either build a docker file locally or pull the image from our docker hub. For the first option, you can run the following command:
git checkout Kubernetes
cd client
docker build -t <your dockerhub name>/client:v1 .
docker push <your dockerhub name>/client:v1Then change image name in client-deployment yaml to <your dockerhub name>/client:v1.
For the second, no additional steps are needed.
Deploy Mongodb Client
Run the following command in order to build the Mongodb client:
kubectl apply -f client-service-2.yaml
kubectl apply -f client-deployment-2.yaml
Dockerize the Transiter
You can either build a docker file locally or pull the image from our docker hub. For the first option, you can run the following command:
git checkout Transit
cd transit
docker build -t <your dockerhub name>/tran:v1 .
docker push <your dockerhub name>/tran:v1Then change image name in transit-deployment yaml to <your dockerhub name>/tran:v1.
For the second, no additional steps are needed.
Deploy the Transiter
Run the following command in order to build the cloud drive:
kubectl apply -f transit-rbac.yaml
kubectl apply -f transit-service.yaml
kubectl apply -f transit-deployment.yamlcd finetune
docker build -t <your dockerhub name>/finetune .
docker push <your dockerhub name>/finetuneHere are brief information concerning application deployment. You can get detailed steps in 3. Environment Setup
For the second, no additional steps are needed.
-
WebUI Deployment
- Get source code
- Initialization
- Run the web page
-
AI System (AI Agent / AI Finetune)
- Obtain API Key
- Dockerize the application
- Deploy the application
-
Cloud Drive Deployment
- Dockerize Cloud Drive
- Deploy Cloud Drive
-
Mongodb and Client Deployment
- Deploy Mongodb
- Dockerize the client
- Deploy Mongodb Client
-
Transit Deployment
- Dockerize the Transiter
- Deploy the Transiter
