Skip to content

Latest commit

 

History

History
171 lines (120 loc) · 4.14 KB

CONTRIBUTING.md

File metadata and controls

171 lines (120 loc) · 4.14 KB

Introduction

This project is based on the Rust on Nails architecture.

Setup for Development

This project uses Devpod. DevPod is a tool used to create reproducible developer environments. We use K3s to host our development environment as this is also where we do most development.

Install K3s on the Host

sudo curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC='server --write-kubeconfig-mode="644"' sh -

Extract the kubeconfig for use by other K8's tools.

mkdir -p ~/.kube && cp /etc/rancher/k3s/k3s.yaml ~/.kube/config

Install DevPod

Go to https://devpod.sh/docs/getting-started/install and install the CLI.

Then run

devpod go https://github.com/bionic-gpt/bionic-gpt

Sanity check your dev environment.

Open up the terminal using Use the View > Terminal menu command or CTRL/CMD `

You can type the following commands in the Linux command prompt.

  • rustc --version
  • npm -v
  • psql -V

Connecting to the cluster

Use the following command to inject the k3s.yaml into the containers kube config.

POD_NAME=$(kubectl -n devpod get pods --field-selector=status.phase=Running -o jsonpath='{.items[*].metadata.name}' | grep 'bionic-gpt' | head -n 1)
kubectl -n devpod exec $POD_NAME -- mkdir -p /home/vscode/.kube
kubectl -n devpod cp /etc/rancher/k3s/k3s.yaml $POD_NAME:/home/vscode/.kube/config
HOST_IP=$(hostname -I | awk '{print $1}')
kubectl -n devpod exec $POD_NAME -- sed -i "s/127.0.0.1/${HOST_IP}/g" /home/vscode/.kube/config

Create a service pointing to the Devpod

echo "
apiVersion: v1
kind: Service
metadata:
  name: bionic-devpod
  namespace: devpod
spec:
  selector:
    devpod.sh/created: 'true' 
  ports:
    - protocol: TCP
      port: 7703
      targetPort: 7703
" | kubectl apply -f -

Configure envoy to use the new service.

Edit the configmap and set the host to

bionic-devpod.devpod.svc.cluster.local

and the port to

7703

Initialise all the services

cargo run --bin k8s-operator -- install --development --no-operator --hostname-url http://pop-os

Then also run the operator

cargo run --bin k8s-operator -- operator

Running Database Migrations

We use dbmate to manage database migrations.

$ dbmate status
[ ] 20220410155201_initial_setup.sql
[ ] 20220410155211_authentication.sql
[ ] 20220410155233_rbac_and_authorization.sql
[ ] 20220410155252_teams.sql
[ ] 20220728091159_rls_setup.sql
[ ] 20220808093939_auth_and_readonly_policies.sql
[ ] 20220808094314_tenancy_isolation.sql
[ ] 20230801121853_chats.sql
[ ] 20230804140530_documents_and_datasets.sql
[ ] 20230807094835_prompts.sql
[ ] 20230810114756_models.sql

Applied: 0
Pending: 11

Create all the database tables with

dbmate up

Update any of the git submodules

The website uses a zola theme. This will need to be loaded with

git submodule init

gsu

Load and Serve a Model

  1. ollama pull llama2
  2. ollama run llama2 then /bye

Test the above with

curl http://llm-api:11434/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{
        "model": "llama2",
        "messages": [
            {
                "role": "system",
                "content": "You are a helpful assistant."
            },
            {
                "role": "user",
                "content": "Hello!"
            }
        ]
    }'

Starting the services

We have created a .bash_alias file in the .devcontainer folder. Open up 3 consoles in visual studio code and run the following in each one.

  1. wp - Watch Pipeline - compiles the web assets such as typescript, scss and processes images.
  2. wt - Watch TailwindCSS - Runs tailwinf to create an output.css file.
  3. wa - Stands for watch application - compiles and runs the axum server and will recompile on file chnages.
  4. wz - Watch Zola - runs the static site generator.
  5. we - Watch Embeddings - runs the embeddings job.

Problems with permissions

If you get an error such as Permission Denied on the target folder run the following

sudo chmod 777 -R target

Accessing the web front end.

https://localhost:7700