Skip to content

Commit 3eb1c1c

Browse files
authored
Merge branch 'master' into default_miro
2 parents a29b44c + 7cf59d9 commit 3eb1c1c

197 files changed

Lines changed: 4141 additions & 1275 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
cd /workspace
4+
5+
# Get the files into the volume without a bind mount
6+
if [ ! -d ".git" ]; then
7+
git clone https://github.com/mudler/LocalAI.git .
8+
else
9+
git fetch
10+
fi
11+
12+
echo "Standard Post-Create script completed."
13+
14+
if [ -f "/devcontainer-customization/postcreate.sh" ]; then
15+
echo "Launching customization postcreate.sh"
16+
bash "/devcontainer-customization/postcreate.sh"
17+
fi

.devcontainer-scripts/poststart.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
cd /workspace
4+
5+
# Grab the pre-stashed backend assets to avoid build issues
6+
cp -r /build/backend-assets /workspace/backend-assets
7+
8+
# Ensures generated source files are present upon load
9+
make prepare
10+
11+
echo "Standard Post-Start script completed."
12+
13+
if [ -f "/devcontainer-customization/poststart.sh" ]; then
14+
echo "Launching customization poststart.sh"
15+
bash "/devcontainer-customization/poststart.sh"
16+
fi

.devcontainer-scripts/utils.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
# This file contains some really simple functions that are useful when building up customization scripts.
4+
5+
6+
# Checks if the git config has a user registered - and sets it up if not.
7+
#
8+
# Param 1: name
9+
# Param 2: email
10+
#
11+
config_user() {
12+
local gcn=$(git config --global user.name)
13+
if [ -z "${gcn}" ]; then
14+
echo "Setting up git user / remote"
15+
git config --global user.name "$1"
16+
git config --global user.email "$2"
17+
18+
fi
19+
}
20+
21+
# Checks if the git remote is configured - and sets it up if not. Fetches either way.
22+
#
23+
# Param 1: remote name
24+
# Param 2: remote url
25+
#
26+
config_remote() {
27+
local gr=$(git remote -v | grep $1)
28+
if [ -z "${gr}" ]; then
29+
git remote add $1 $2
30+
fi
31+
git fetch $1
32+
}
33+
34+
# Setup special .ssh files
35+
#
36+
# Param 1: bash array, filenames relative to the customization directory that should be copied to ~/.ssh
37+
setup_ssh() {
38+
local files=("$@")
39+
for file in "${files[@]}"; then
40+
local cfile="/devcontainer-customization/${file}"
41+
local hfile="~/.ssh/${file}"
42+
if [ ! -f "${hfile}" ]; then
43+
echo "copying ${file}"
44+
cp "${cfile}" "${hfile}"
45+
chmod 600 "${hfile}"
46+
fi
47+
done
48+
ls ~/.ssh
49+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Place any additional resources your environment requires in this directory
2+
3+
Script hooks are currently called for:
4+
`postcreate.sh` and `poststart.sh`
5+
6+
If files with those names exist here, they will be called at the end of the normal script.
7+
8+
This is a good place to set things like `git config --global user.name` are set - and to handle any other files that are mounted via this directory.
9+
10+
To assist in doing so, `source /.devcontainer-scripts/utils.sh` will provide utility functions that may be useful - for example:
11+
12+
```
13+
#!/bin/bash
14+
15+
source "/.devcontainer-scripts/utils.sh"
16+
17+
sshfiles=("config", "key.pub")
18+
19+
setup_ssh "${sshfiles[@]}"
20+
21+
config_user "YOUR NAME" "YOUR EMAIL"
22+
23+
config_remote "REMOTE NAME" "REMOTE URL"
24+
25+
```

.devcontainer/devcontainer.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainer.schema.json",
3+
"name": "LocalAI",
4+
"workspaceFolder": "/workspace",
5+
"dockerComposeFile": [ "./docker-compose-devcontainer.yml" ],
6+
"service": "api",
7+
"shutdownAction": "stopCompose",
8+
"customizations": {
9+
"vscode": {
10+
"extensions": [
11+
"golang.go",
12+
"ms-vscode.makefile-tools",
13+
"ms-azuretools.vscode-docker",
14+
"ms-python.python",
15+
"ms-python.debugpy",
16+
"wayou.vscode-todo-highlight",
17+
"waderyan.gitblame"
18+
]
19+
}
20+
},
21+
"forwardPorts": [8080, 3000],
22+
"postCreateCommand": "bash /.devcontainer-scripts/postcreate.sh",
23+
"postStartCommand": "bash /.devcontainer-scripts/poststart.sh"
24+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
services:
2+
api:
3+
build:
4+
context: ..
5+
dockerfile: Dockerfile
6+
target: devcontainer
7+
args:
8+
- FFMPEG=true
9+
- IMAGE_TYPE=extras
10+
- GO_TAGS=stablediffusion p2p tts
11+
env_file:
12+
- ../.env
13+
ports:
14+
- 8080:8080
15+
volumes:
16+
- localai_workspace:/workspace
17+
- ../models:/host-models
18+
- ./customization:/devcontainer-customization
19+
command: /bin/sh -c "while sleep 1000; do :; done"
20+
cap_add:
21+
- SYS_PTRACE
22+
security_opt:
23+
- seccomp:unconfined
24+
prometheus:
25+
image: prom/prometheus
26+
container_name: prometheus
27+
command:
28+
- '--config.file=/etc/prometheus/prometheus.yml'
29+
ports:
30+
- 9090:9090
31+
restart: unless-stopped
32+
volumes:
33+
- ./prometheus:/etc/prometheus
34+
- prom_data:/prometheus
35+
grafana:
36+
image: grafana/grafana
37+
container_name: grafana
38+
ports:
39+
- 3000:3000
40+
restart: unless-stopped
41+
environment:
42+
- GF_SECURITY_ADMIN_USER=admin
43+
- GF_SECURITY_ADMIN_PASSWORD=grafana
44+
volumes:
45+
- ./grafana:/etc/grafana/provisioning/datasources
46+
volumes:
47+
prom_data:
48+
localai_workspace:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
apiVersion: 1
3+
4+
datasources:
5+
- name: Prometheus
6+
type: prometheus
7+
url: http://prometheus:9090
8+
isDefault: true
9+
access: proxy
10+
editable: true
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
global:
2+
scrape_interval: 15s
3+
scrape_timeout: 10s
4+
evaluation_interval: 15s
5+
alerting:
6+
alertmanagers:
7+
- static_configs:
8+
- targets: []
9+
scheme: http
10+
timeout: 10s
11+
api_version: v1
12+
scrape_configs:
13+
- job_name: prometheus
14+
honor_timestamps: true
15+
scrape_interval: 15s
16+
scrape_timeout: 10s
17+
metrics_path: /metrics
18+
scheme: http
19+
static_configs:
20+
- targets:
21+
- localhost:9090

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.idea
22
.github
33
.vscode
4+
.devcontainer
45
models
56
examples/chatbot-ui/models
67
examples/rwkv/models

.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@
7979
### Enable to run parallel requests
8080
# LOCALAI_PARALLEL_REQUESTS=true
8181

82+
# Enable to allow p2p mode
83+
# LOCALAI_P2P=true
84+
8285
### Watchdog settings
8386
###
8487
# Enables watchdog to kill backends that are inactive for too much time

0 commit comments

Comments
 (0)