eder0782 commited on
Commit
7def60a
·
1 Parent(s): d7f1e52
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .dockerignore +16 -0
  2. .editorconfig +31 -0
  3. .env +94 -0
  4. .github/FUNDING.yml +5 -0
  5. .github/ISSUE_TEMPLATE/bug_report.md +29 -0
  6. .github/ISSUE_TEMPLATE/config.yml +8 -0
  7. .github/ISSUE_TEMPLATE/feature_request.md +20 -0
  8. .github/PULL_REQUEST_TEMPLATE.md +31 -0
  9. .github/bump_deps.sh +22 -0
  10. .github/bump_docs.sh +7 -0
  11. .github/check_and_update.py +80 -0
  12. .github/checksum_checker.sh +63 -0
  13. .github/ci/modelslist.go +297 -0
  14. .github/dependabot.yml +137 -0
  15. .github/labeler.yml +24 -0
  16. .github/release.yml +37 -0
  17. .github/stale.yml +18 -0
  18. .github/workflows/bump_deps.yaml +70 -0
  19. .github/workflows/bump_docs.yaml +31 -0
  20. .github/workflows/checksum_checker.yaml +47 -0
  21. .github/workflows/dependabot_auto.yml +43 -0
  22. .github/workflows/disabled/comment-pr.yaml +83 -0
  23. .github/workflows/disabled/test-gpu.yml +63 -0
  24. .github/workflows/generate_grpc_cache.yaml +94 -0
  25. .github/workflows/generate_intel_image.yaml +59 -0
  26. .github/workflows/image-pr.yml +140 -0
  27. .github/workflows/image.yml +328 -0
  28. .github/workflows/image_build.yml +335 -0
  29. .github/workflows/labeler.yml +12 -0
  30. .github/workflows/localaibot_automerge.yml +35 -0
  31. .github/workflows/notify-models.yaml +168 -0
  32. .github/workflows/notify-releases.yaml +63 -0
  33. .github/workflows/prlint.yaml +28 -0
  34. .github/workflows/release.yaml +357 -0
  35. .github/workflows/secscan.yaml +30 -0
  36. .github/workflows/test-extra.yml +321 -0
  37. .github/workflows/test.yml +232 -0
  38. .github/workflows/update_swagger.yaml +37 -0
  39. .github/workflows/yaml-check.yml +18 -0
  40. .gitignore +56 -0
  41. .gitmodules +6 -0
  42. .vscode/extensions.json +5 -0
  43. .vscode/launch.json +33 -0
  44. .yamllint +4 -0
  45. CONTRIBUTING.md +88 -0
  46. Dockerfile +397 -0
  47. Dockerfile.aio +8 -0
  48. Earthfile +5 -0
  49. Entitlements.plist +10 -0
  50. LICENSE +21 -0
.dockerignore ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .idea
2
+ .github
3
+ .vscode
4
+ models
5
+ examples/chatbot-ui/models
6
+ examples/rwkv/models
7
+ examples/**/models
8
+ Dockerfile*
9
+ __pycache__
10
+
11
+ # SonarQube
12
+ .scannerwork
13
+
14
+ # backend virtual environments
15
+ **/venv
16
+ backend/python/**/source
.editorconfig ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ charset = utf-8
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
11
+
12
+ [*.go]
13
+ indent_style = tab
14
+
15
+ [Makefile]
16
+ indent_style = tab
17
+
18
+ [*.proto]
19
+ indent_size = 2
20
+
21
+ [*.py]
22
+ indent_size = 4
23
+
24
+ [*.js]
25
+ indent_size = 2
26
+
27
+ [*.yaml]
28
+ indent_size = 2
29
+
30
+ [*.md]
31
+ trim_trailing_whitespace = false
.env ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Set number of threads.
2
+ ## Note: prefer the number of physical cores. Overbooking the CPU degrades performance notably.
3
+ # LOCALAI_THREADS=14
4
+
5
+ ## Specify a different bind address (defaults to ":8080")
6
+ # LOCALAI_ADDRESS=127.0.0.1:8080
7
+
8
+ ## Default models context size
9
+ # LOCALAI_CONTEXT_SIZE=512
10
+ #
11
+ ## Define galleries.
12
+ ## models will to install will be visible in `/models/available`
13
+ # LOCALAI_GALLERIES=[{"name":"localai", "url":"github:mudler/LocalAI/gallery/index.yaml@master"}]
14
+
15
+ ## CORS settings
16
+ # LOCALAI_CORS=true
17
+ # LOCALAI_CORS_ALLOW_ORIGINS=*
18
+
19
+ ## Default path for models
20
+ #
21
+ # LOCALAI_MODELS_PATH=/models
22
+
23
+ ## Enable debug mode
24
+ # LOCALAI_LOG_LEVEL=debug
25
+
26
+ ## Disables COMPEL (Diffusers)
27
+ # COMPEL=0
28
+
29
+ ## Enable/Disable single backend (useful if only one GPU is available)
30
+ # LOCALAI_SINGLE_ACTIVE_BACKEND=true
31
+
32
+ ## Specify a build type. Available: cublas, openblas, clblas.
33
+ ## cuBLAS: This is a GPU-accelerated version of the complete standard BLAS (Basic Linear Algebra Subprograms) library. It's provided by Nvidia and is part of their CUDA toolkit.
34
+ ## OpenBLAS: This is an open-source implementation of the BLAS library that aims to provide highly optimized code for various platforms. It includes support for multi-threading and can be compiled to use hardware-specific features for additional performance. OpenBLAS can run on many kinds of hardware, including CPUs from Intel, AMD, and ARM.
35
+ ## clBLAS: This is an open-source implementation of the BLAS library that uses OpenCL, a framework for writing programs that execute across heterogeneous platforms consisting of CPUs, GPUs, and other processors. clBLAS is designed to take advantage of the parallel computing power of GPUs but can also run on any hardware that supports OpenCL. This includes hardware from different vendors like Nvidia, AMD, and Intel.
36
+ # BUILD_TYPE=openblas
37
+
38
+ ## Uncomment and set to true to enable rebuilding from source
39
+ # REBUILD=true
40
+
41
+ ## Enable go tags, available: stablediffusion, tts
42
+ ## stablediffusion: image generation with stablediffusion
43
+ ## tts: enables text-to-speech with go-piper
44
+ ## (requires REBUILD=true)
45
+ #
46
+ # GO_TAGS=stablediffusion
47
+
48
+ ## Path where to store generated images
49
+ # LOCALAI_IMAGE_PATH=/tmp/generated/images
50
+
51
+ ## Specify a default upload limit in MB (whisper)
52
+ # LOCALAI_UPLOAD_LIMIT=15
53
+
54
+ ## List of external GRPC backends (note on the container image this variable is already set to use extra backends available in extra/)
55
+ # LOCALAI_EXTERNAL_GRPC_BACKENDS=my-backend:127.0.0.1:9000,my-backend2:/usr/bin/backend.py
56
+
57
+ ### Advanced settings ###
58
+ ### Those are not really used by LocalAI, but from components in the stack ###
59
+ ##
60
+ ### Preload libraries
61
+ # LD_PRELOAD=
62
+
63
+ ### Huggingface cache for models
64
+ # HUGGINGFACE_HUB_CACHE=/usr/local/huggingface
65
+
66
+ ### Python backends GRPC max workers
67
+ ### Default number of workers for GRPC Python backends.
68
+ ### This actually controls wether a backend can process multiple requests or not.
69
+ # PYTHON_GRPC_MAX_WORKERS=1
70
+
71
+ ### Define the number of parallel LLAMA.cpp workers (Defaults to 1)
72
+ # LLAMACPP_PARALLEL=1
73
+
74
+ ### Define a list of GRPC Servers for llama-cpp workers to distribute the load
75
+ # https://github.com/ggerganov/llama.cpp/pull/6829
76
+ # https://github.com/ggerganov/llama.cpp/blob/master/examples/rpc/README.md
77
+ # LLAMACPP_GRPC_SERVERS=""
78
+
79
+ ### Enable to run parallel requests
80
+ # LOCALAI_PARALLEL_REQUESTS=true
81
+
82
+ ### Watchdog settings
83
+ ###
84
+ # Enables watchdog to kill backends that are inactive for too much time
85
+ # LOCALAI_WATCHDOG_IDLE=true
86
+ #
87
+ # Time in duration format (e.g. 1h30m) after which a backend is considered idle
88
+ # LOCALAI_WATCHDOG_IDLE_TIMEOUT=5m
89
+ #
90
+ # Enables watchdog to kill backends that are busy for too much time
91
+ # LOCALAI_WATCHDOG_BUSY=true
92
+ #
93
+ # Time in duration format (e.g. 1h30m) after which a backend is considered busy
94
+ # LOCALAI_WATCHDOG_BUSY_TIMEOUT=5m
.github/FUNDING.yml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # These are supported funding model platforms
2
+
3
+ github: [mudler]
4
+ custom:
5
+ - https://www.buymeacoffee.com/mudler
.github/ISSUE_TEMPLATE/bug_report.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: bug, unconfirmed, up-for-grabs
6
+ ---
7
+
8
+ <!-- Thanks for helping us to improve LocalAI! We welcome all bug reports. Please fill out each area of the template so we can better help you. Comments like this will be hidden when you post but you can delete them if you wish. -->
9
+
10
+ **LocalAI version:**
11
+ <!-- Container Image or LocalAI tag/commit -->
12
+
13
+ **Environment, CPU architecture, OS, and Version:**
14
+ <!-- Provide the output from "uname -a", HW specs, if it's a VM -->
15
+
16
+ **Describe the bug**
17
+ <!-- A clear and concise description of what the bug is. -->
18
+
19
+ **To Reproduce**
20
+ <!-- Steps to reproduce the behavior, including the LocalAI command used, if any -->
21
+
22
+ **Expected behavior**
23
+ <!-- A clear and concise description of what you expected to happen. -->
24
+
25
+ **Logs**
26
+ <!-- If applicable, add logs while running LocalAI in debug mode (`--debug` or `DEBUG=true`) to help explain your problem. -->
27
+
28
+ **Additional context**
29
+ <!-- Add any other context about the problem here. -->
.github/ISSUE_TEMPLATE/config.yml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: Community Support
4
+ url: https://github.com/go-skynet/LocalAI/discussions
5
+ about: Please ask and answer questions here.
6
+ - name: Discord
7
+ url: https://discord.gg/uJAeKSAGDy
8
+ about: Join our community on Discord!
.github/ISSUE_TEMPLATE/feature_request.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: enhancement, up-for-grabs
6
+ ---
7
+
8
+ <!-- Thanks for helping us to improve LocalAI! We welcome all feature requests. Please fill out each area of the template so we can better help you. Comments like this will be hidden when you post but you can delete them if you wish. -->
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ <!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
12
+
13
+ **Describe the solution you'd like**
14
+ <!-- A clear and concise description of what you want to happen. -->
15
+
16
+ **Describe alternatives you've considered**
17
+ <!-- A clear and concise description of any alternative solutions or features you've considered. -->
18
+
19
+ **Additional context**
20
+ <!-- Add any other context or screenshots about the feature request here. -->
.github/PULL_REQUEST_TEMPLATE.md ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ **Description**
2
+
3
+ This PR fixes #
4
+
5
+ **Notes for Reviewers**
6
+
7
+
8
+ **[Signed commits](../CONTRIBUTING.md#signing-off-on-commits-developer-certificate-of-origin)**
9
+ - [ ] Yes, I signed my commits.
10
+
11
+ <!--
12
+ Thank you for contributing to LocalAI!
13
+
14
+ Contributing Conventions
15
+ -------------------------
16
+
17
+ The draft above helps to give a quick overview of your PR.
18
+
19
+ Remember to remove this comment and to at least:
20
+
21
+ 1. Include descriptive PR titles with [<component-name>] prepended. We use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/).
22
+ 2. Build and test your changes before submitting a PR (`make build`).
23
+ 3. Sign your commits
24
+ 4. **Tag maintainer:** for a quicker response, tag the relevant maintainer (see below).
25
+ 5. **X/Twitter handle:** we announce bigger features on X/Twitter. If your PR gets announced, and you'd like a mention, we'll gladly shout you out!
26
+
27
+ By following the community's contribution conventions upfront, the review process will
28
+ be accelerated and your PR merged more quickly.
29
+
30
+ If no one reviews your PR within a few days, please @-mention @mudler.
31
+ -->
.github/bump_deps.sh ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -xe
3
+ REPO=$1
4
+ BRANCH=$2
5
+ VAR=$3
6
+
7
+ LAST_COMMIT=$(curl -s -H "Accept: application/vnd.github.VERSION.sha" "https://api.github.com/repos/$REPO/commits/$BRANCH")
8
+
9
+ # Read $VAR from Makefile (only first match)
10
+ set +e
11
+ CURRENT_COMMIT="$(grep -m1 "^$VAR?=" Makefile | cut -d'=' -f2)"
12
+ set -e
13
+
14
+ sed -i Makefile -e "s/$VAR?=.*/$VAR?=$LAST_COMMIT/"
15
+
16
+ if [ -z "$CURRENT_COMMIT" ]; then
17
+ echo "Could not find $VAR in Makefile."
18
+ exit 0
19
+ fi
20
+
21
+ echo "Changes: https://github.com/$REPO/compare/${CURRENT_COMMIT}..${LAST_COMMIT}" >> "${VAR}_message.txt"
22
+ echo "${LAST_COMMIT}" >> "${VAR}_commit.txt"
.github/bump_docs.sh ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -xe
3
+ REPO=$1
4
+
5
+ LATEST_TAG=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | jq -r '.tag_name')
6
+
7
+ cat <<< $(jq ".version = \"$LATEST_TAG\"" docs/data/version.json) > docs/data/version.json
.github/check_and_update.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import hashlib
2
+ from huggingface_hub import hf_hub_download, get_paths_info
3
+ import requests
4
+ import sys
5
+ import os
6
+
7
+ uri = sys.argv[1]
8
+ file_name = uri.split('/')[-1]
9
+
10
+ # Function to parse the URI and determine download method
11
+ def parse_uri(uri):
12
+ if uri.startswith('huggingface://'):
13
+ repo_id = uri.split('://')[1]
14
+ return 'huggingface', repo_id.rsplit('/', 1)[0]
15
+ elif 'huggingface.co' in uri:
16
+ parts = uri.split('/resolve/')
17
+ if len(parts) > 1:
18
+ repo_path = parts[0].split('https://huggingface.co/')[-1]
19
+ return 'huggingface', repo_path
20
+ return 'direct', uri
21
+
22
+ def calculate_sha256(file_path):
23
+ sha256_hash = hashlib.sha256()
24
+ with open(file_path, 'rb') as f:
25
+ for byte_block in iter(lambda: f.read(4096), b''):
26
+ sha256_hash.update(byte_block)
27
+ return sha256_hash.hexdigest()
28
+
29
+ def manual_safety_check_hf(repo_id):
30
+ scanResponse = requests.get('https://huggingface.co/api/models/' + repo_id + "/scan")
31
+ scan = scanResponse.json()
32
+ if scan['hasUnsafeFile']:
33
+ return scan
34
+ return None
35
+
36
+ download_type, repo_id_or_url = parse_uri(uri)
37
+
38
+ new_checksum = None
39
+ file_path = None
40
+
41
+ # Decide download method based on URI type
42
+ if download_type == 'huggingface':
43
+ # Check if the repo is flagged as dangerous by HF
44
+ hazard = manual_safety_check_hf(repo_id_or_url)
45
+ if hazard != None:
46
+ print(f'Error: HuggingFace has detected security problems for {repo_id_or_url}: {str(hazard)}', filename=file_name)
47
+ sys.exit(5)
48
+ # Use HF API to pull sha
49
+ for file in get_paths_info(repo_id_or_url, [file_name], repo_type='model'):
50
+ try:
51
+ new_checksum = file.lfs.sha256
52
+ break
53
+ except Exception as e:
54
+ print(f'Error from Hugging Face Hub: {str(e)}', file=sys.stderr)
55
+ sys.exit(2)
56
+ if new_checksum is None:
57
+ try:
58
+ file_path = hf_hub_download(repo_id=repo_id_or_url, filename=file_name)
59
+ except Exception as e:
60
+ print(f'Error from Hugging Face Hub: {str(e)}', file=sys.stderr)
61
+ sys.exit(2)
62
+ else:
63
+ response = requests.get(repo_id_or_url)
64
+ if response.status_code == 200:
65
+ with open(file_name, 'wb') as f:
66
+ f.write(response.content)
67
+ file_path = file_name
68
+ elif response.status_code == 404:
69
+ print(f'File not found: {response.status_code}', file=sys.stderr)
70
+ sys.exit(2)
71
+ else:
72
+ print(f'Error downloading file: {response.status_code}', file=sys.stderr)
73
+ sys.exit(1)
74
+
75
+ if new_checksum is None:
76
+ new_checksum = calculate_sha256(file_path)
77
+ print(new_checksum)
78
+ os.remove(file_path)
79
+ else:
80
+ print(new_checksum)
.github/checksum_checker.sh ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # This scripts needs yq and huggingface_hub to be installed
3
+ # to install hugingface_hub run pip install huggingface_hub
4
+
5
+ # Path to the input YAML file
6
+ input_yaml=$1
7
+
8
+ # Function to download file and check checksum using Python
9
+ function check_and_update_checksum() {
10
+ model_name="$1"
11
+ file_name="$2"
12
+ uri="$3"
13
+ old_checksum="$4"
14
+ idx="$5"
15
+
16
+ # Download the file and calculate new checksum using Python
17
+ new_checksum=$(python3 ./.github/check_and_update.py $uri)
18
+ result=$?
19
+
20
+ if [[ $result -eq 5 ]]; then
21
+ echo "Contaminated entry detected, deleting entry for $model_name..."
22
+ yq eval -i "del([$idx])" "$input_yaml"
23
+ return
24
+ fi
25
+
26
+ if [[ "$new_checksum" == "" ]]; then
27
+ echo "Error calculating checksum for $file_name. Skipping..."
28
+ return
29
+ fi
30
+
31
+ echo "Checksum for $file_name: $new_checksum"
32
+
33
+ # Compare and update the YAML file if checksums do not match
34
+
35
+ if [[ $result -eq 2 ]]; then
36
+ echo "File not found, deleting entry for $file_name..."
37
+ # yq eval -i "del(.[$idx].files[] | select(.filename == \"$file_name\"))" "$input_yaml"
38
+ elif [[ "$old_checksum" != "$new_checksum" ]]; then
39
+ echo "Checksum mismatch for $file_name. Updating..."
40
+ yq eval -i "del(.[$idx].files[] | select(.filename == \"$file_name\").sha256)" "$input_yaml"
41
+ yq eval -i "(.[$idx].files[] | select(.filename == \"$file_name\")).sha256 = \"$new_checksum\"" "$input_yaml"
42
+ elif [[ $result -ne 0 ]]; then
43
+ echo "Error downloading file $file_name. Skipping..."
44
+ else
45
+ echo "Checksum match for $file_name. No update needed."
46
+ fi
47
+ }
48
+
49
+ # Read the YAML and process each file
50
+ len=$(yq eval '. | length' "$input_yaml")
51
+ for ((i=0; i<$len; i++))
52
+ do
53
+ name=$(yq eval ".[$i].name" "$input_yaml")
54
+ files_len=$(yq eval ".[$i].files | length" "$input_yaml")
55
+ for ((j=0; j<$files_len; j++))
56
+ do
57
+ filename=$(yq eval ".[$i].files[$j].filename" "$input_yaml")
58
+ uri=$(yq eval ".[$i].files[$j].uri" "$input_yaml")
59
+ checksum=$(yq eval ".[$i].files[$j].sha256" "$input_yaml")
60
+ echo "Checking model $name, file $filename. URI = $uri, Checksum = $checksum"
61
+ check_and_update_checksum "$name" "$filename" "$uri" "$checksum" "$i"
62
+ done
63
+ done
.github/ci/modelslist.go ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package main
2
+
3
+ import (
4
+ "fmt"
5
+ "html/template"
6
+ "io/ioutil"
7
+ "os"
8
+
9
+ "gopkg.in/yaml.v3"
10
+ )
11
+
12
+ var modelPageTemplate string = `
13
+ <!DOCTYPE html>
14
+ <html>
15
+ <head>
16
+ <meta charset="UTF-8">
17
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
18
+ <title>LocalAI models</title>
19
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.3.0/flowbite.min.css" rel="stylesheet" />
20
+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/lazyload.min.js"></script>
21
+
22
+ <link
23
+ rel="stylesheet"
24
+ href="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/default.min.css"
25
+ />
26
+ <script
27
+ defer
28
+ src="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/highlight.min.js"
29
+ ></script>
30
+ <script
31
+ defer
32
+ src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"
33
+ ></script>
34
+ <script
35
+ defer
36
+ src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"
37
+ ></script>
38
+ <script
39
+ defer
40
+ src="https://cdn.jsdelivr.net/npm/[email protected]/dist/purify.min.js"
41
+ ></script>
42
+
43
+ <link href="/static/general.css" rel="stylesheet" />
44
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Roboto:wght@400;500&display=swap" rel="stylesheet">
45
+ <link
46
+ href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,900&display=swap"
47
+ rel="stylesheet" />
48
+ <link
49
+ rel="stylesheet"
50
+ href="https://cdn.jsdelivr.net/npm/tw-elements/css/tw-elements.min.css" />
51
+ <script src="https://cdn.tailwindcss.com/3.3.0"></script>
52
+ <script>
53
+ tailwind.config = {
54
+ darkMode: "class",
55
+ theme: {
56
+ fontFamily: {
57
+ sans: ["Roboto", "sans-serif"],
58
+ body: ["Roboto", "sans-serif"],
59
+ mono: ["ui-monospace", "monospace"],
60
+ },
61
+ },
62
+ corePlugins: {
63
+ preflight: false,
64
+ },
65
+ };
66
+ </script>
67
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
68
+ <script src="https://unpkg.com/[email protected]" integrity="sha384-ujb1lZYygJmzgSwoxRggbCHcjc0rB2XoQrxeTUQyRjrOnlCoYta87iKBWq3EsdM2" crossorigin="anonymous"></script>
69
+ </head>
70
+
71
+ <body class="bg-gray-900 text-gray-200">
72
+ <div class="flex flex-col min-h-screen">
73
+
74
+ <nav class="bg-gray-800 shadow-lg">
75
+ <div class="container mx-auto px-4 py-4">
76
+ <div class="flex items-center justify-between">
77
+ <div class="flex items-center">
78
+ <a href="/" class="text-white text-xl font-bold"><img src="https://github.com/mudler/LocalAI/assets/2420543/0966aa2a-166e-4f99-a3e5-6c915fc997dd" alt="LocalAI Logo" class="h-10 mr-3 border-2 border-gray-300 shadow rounded"></a>
79
+ <a href="/" class="text-white text-xl font-bold">LocalAI</a>
80
+ </div>
81
+ <!-- Menu button for small screens -->
82
+ <div class="lg:hidden">
83
+ <button id="menu-toggle" class="text-gray-400 hover:text-white focus:outline-none">
84
+ <i class="fas fa-bars fa-lg"></i>
85
+ </button>
86
+ </div>
87
+ <!-- Navigation links -->
88
+ <div class="hidden lg:flex lg:items-center lg:justify-end lg:flex-1 lg:w-0">
89
+ <a href="https://localai.io" class="text-gray-400 hover:text-white px-3 py-2 rounded" target="_blank" ><i class="fas fa-book-reader pr-2"></i> Documentation</a>
90
+ </div>
91
+ </div>
92
+ <!-- Collapsible menu for small screens -->
93
+ <div class="hidden lg:hidden" id="mobile-menu">
94
+ <div class="pt-4 pb-3 border-t border-gray-700">
95
+
96
+ <a href="https://localai.io" class="block text-gray-400 hover:text-white px-3 py-2 rounded mt-1" target="_blank" ><i class="fas fa-book-reader pr-2"></i> Documentation</a>
97
+
98
+ </div>
99
+ </div>
100
+ </div>
101
+ </nav>
102
+
103
+ <style>
104
+ .is-hidden {
105
+ display: none;
106
+ }
107
+ </style>
108
+
109
+ <div class="container mx-auto px-4 flex-grow">
110
+
111
+ <div class="models mt-12">
112
+ <h2 class="text-center text-3xl font-semibold text-gray-100">
113
+ LocalAI model gallery list </h2><br>
114
+
115
+ <h2 class="text-center text-3xl font-semibold text-gray-100">
116
+
117
+ 🖼️ Available {{.AvailableModels}} models</i> <a href="https://localai.io/models/" target="_blank" >
118
+ <i class="fas fa-circle-info pr-2"></i>
119
+ </a></h2>
120
+
121
+ <h3>
122
+ Refer to the Model gallery <a href="https://localai.io/models/" target="_blank" ><i class="fas fa-circle-info pr-2"></i></a> for more information on how to use the models with LocalAI.<br>
123
+
124
+ You can install models with the CLI command <code>local-ai models install <model-name></code>. or by using the WebUI.
125
+ </h3>
126
+
127
+ <input class="form-control appearance-none block w-full mt-5 px-3 py-2 text-base font-normal text-gray-300 pb-2 mb-5 bg-gray-800 bg-clip-padding border border-solid border-gray-600 rounded transition ease-in-out m-0 focus:text-gray-300 focus:bg-gray-900 focus:border-blue-500 focus:outline-none" type="search"
128
+ id="searchbox" placeholder="Live search keyword..">
129
+ <div class="dark grid grid-cols-1 grid-rows-1 md:grid-cols-3 block rounded-lg shadow-secondary-1 dark:bg-surface-dark">
130
+ {{ range $_, $model := .Models }}
131
+ <div class="box me-4 mb-2 block rounded-lg bg-white shadow-secondary-1 dark:bg-gray-800 dark:bg-surface-dark dark:text-white text-surface pb-2">
132
+ <div>
133
+ {{ $icon := "https://upload.wikimedia.org/wikipedia/commons/6/65/No-Image-Placeholder.svg" }}
134
+ {{ if $model.Icon }}
135
+ {{ $icon = $model.Icon }}
136
+ {{ end }}
137
+ <div class="flex justify-center items-center">
138
+ <img data-src="{{ $icon }}" alt="{{$model.Name}}" class="rounded-t-lg max-h-48 max-w-96 object-cover mt-3 lazy">
139
+ </div>
140
+ <div class="p-6 text-surface dark:text-white">
141
+ <h5 class="mb-2 text-xl font-medium leading-tight">{{$model.Name}}</h5>
142
+
143
+
144
+ <p class="mb-4 text-base truncate">{{ $model.Description }}</p>
145
+
146
+ </div>
147
+ <div class="px-6 pt-4 pb-2">
148
+
149
+ <!-- Modal toggle -->
150
+ <button data-modal-target="{{ $model.Name}}-modal" data-modal-toggle="{{ $model.Name }}-modal" class="block text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800" type="button">
151
+ More info
152
+ </button>
153
+
154
+ <!-- Main modal -->
155
+ <div id="{{ $model.Name}}-modal" tabindex="-1" aria-hidden="true" class="hidden overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 justify-center items-center w-full md:inset-0 h-[calc(100%-1rem)] max-h-full">
156
+ <div class="relative p-4 w-full max-w-2xl max-h-full">
157
+ <!-- Modal content -->
158
+ <div class="relative bg-white rounded-lg shadow dark:bg-gray-700">
159
+ <!-- Modal header -->
160
+ <div class="flex items-center justify-between p-4 md:p-5 border-b rounded-t dark:border-gray-600">
161
+ <h3 class="text-xl font-semibold text-gray-900 dark:text-white">
162
+ {{ $model.Name}}
163
+ </h3>
164
+ <button type="button" class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white" data-modal-hide="{{$model.Name}}-modal">
165
+ <svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
166
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
167
+ </svg>
168
+ <span class="sr-only">Close modal</span>
169
+ </button>
170
+ </div>
171
+ <!-- Modal body -->
172
+ <div class="p-4 md:p-5 space-y-4">
173
+ <div class="flex justify-center items-center">
174
+ <img data-src="{{ $icon }}" alt="{{$model.Name}}" class="lazy rounded-t-lg max-h-48 max-w-96 object-cover mt-3">
175
+ </div>
176
+
177
+ <p class="text-base leading-relaxed text-gray-500 dark:text-gray-400">
178
+ {{ $model.Description }}
179
+
180
+ </p>
181
+
182
+ <p class="text-base leading-relaxed text-gray-500 dark:text-gray-400">
183
+ To install the model with the CLI, run: <br>
184
+ <code> local-ai models install {{$model.Name}} </code> <br>
185
+
186
+ <hr>
187
+ See also <a href="https://localai.io/models/" target="_blank" >
188
+ Installation <i class="fas fa-circle-info pr-2"></i>
189
+ </a> to see how to install models with the REST API.
190
+ </p>
191
+
192
+ <p class="text-base leading-relaxed text-gray-500 dark:text-gray-400">
193
+ <ul>
194
+ {{ range $_, $u := $model.URLs }}
195
+ <li><a href="{{ $u }}" target=_blank><i class="fa-solid fa-link"></i> {{ $u }}</a></li>
196
+ {{ end }}
197
+ </ul>
198
+ </p>
199
+ </div>
200
+ <!-- Modal footer -->
201
+ <div class="flex items-center p-4 md:p-5 border-t border-gray-200 rounded-b dark:border-gray-600">
202
+ <button data-modal-hide="{{ $model.Name}}-modal" type="button" class="py-2.5 px-5 ms-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-lg border border-gray-200 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700">Close</button>
203
+ </div>
204
+ </div>
205
+ </div>
206
+ </div>
207
+
208
+
209
+ </div>
210
+ </div>
211
+ </div>
212
+ {{ end }}
213
+
214
+ </div>
215
+ </div>
216
+ </div>
217
+
218
+ <script>
219
+ var lazyLoadInstance = new LazyLoad({
220
+ // Your custom settings go here
221
+ });
222
+
223
+ let cards = document.querySelectorAll('.box')
224
+
225
+ function liveSearch() {
226
+ let search_query = document.getElementById("searchbox").value;
227
+
228
+ //Use innerText if all contents are visible
229
+ //Use textContent for including hidden elements
230
+ for (var i = 0; i < cards.length; i++) {
231
+ if(cards[i].textContent.toLowerCase()
232
+ .includes(search_query.toLowerCase())) {
233
+ cards[i].classList.remove("is-hidden");
234
+ } else {
235
+ cards[i].classList.add("is-hidden");
236
+ }
237
+ }
238
+ }
239
+
240
+ //A little delay
241
+ let typingTimer;
242
+ let typeInterval = 500;
243
+ let searchInput = document.getElementById('searchbox');
244
+
245
+ searchInput.addEventListener('keyup', () => {
246
+ clearTimeout(typingTimer);
247
+ typingTimer = setTimeout(liveSearch, typeInterval);
248
+ });
249
+ </script>
250
+
251
+ </div>
252
+
253
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.3.0/flowbite.min.js"></script>
254
+ </body>
255
+ </html>
256
+ `
257
+
258
+ type GalleryModel struct {
259
+ Name string `json:"name" yaml:"name"`
260
+ URLs []string `json:"urls" yaml:"urls"`
261
+ Icon string `json:"icon" yaml:"icon"`
262
+ Description string `json:"description" yaml:"description"`
263
+ }
264
+
265
+ func main() {
266
+ // read the YAML file which contains the models
267
+
268
+ f, err := ioutil.ReadFile(os.Args[1])
269
+ if err != nil {
270
+ fmt.Println("Error reading file:", err)
271
+ return
272
+ }
273
+
274
+ models := []*GalleryModel{}
275
+ err = yaml.Unmarshal(f, &models)
276
+ if err != nil {
277
+ // write to stderr
278
+ os.Stderr.WriteString("Error unmarshaling YAML: " + err.Error() + "\n")
279
+ return
280
+ }
281
+
282
+ // render the template
283
+ data := struct {
284
+ Models []*GalleryModel
285
+ AvailableModels int
286
+ }{
287
+ Models: models,
288
+ AvailableModels: len(models),
289
+ }
290
+ tmpl := template.Must(template.New("modelPage").Parse(modelPageTemplate))
291
+
292
+ err = tmpl.Execute(os.Stdout, data)
293
+ if err != nil {
294
+ fmt.Println("Error executing template:", err)
295
+ return
296
+ }
297
+ }
.github/dependabot.yml ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
2
+ version: 2
3
+ updates:
4
+ - package-ecosystem: "gitsubmodule"
5
+ directory: "/"
6
+ schedule:
7
+ interval: "weekly"
8
+ - package-ecosystem: "gomod"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "weekly"
12
+ - package-ecosystem: "github-actions"
13
+ # Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.)
14
+ directory: "/"
15
+ schedule:
16
+ # Check for updates to GitHub Actions every weekday
17
+ interval: "weekly"
18
+ - package-ecosystem: "pip"
19
+ # Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.)
20
+ directory: "/"
21
+ schedule:
22
+ # Check for updates to GitHub Actions every weekday
23
+ interval: "weekly"
24
+ - package-ecosystem: "docker"
25
+ # Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.)
26
+ directory: "/"
27
+ schedule:
28
+ # Check for updates to GitHub Actions every weekday
29
+ interval: "weekly"
30
+ - package-ecosystem: "pip"
31
+ directory: "/backend/python/autogptq"
32
+ schedule:
33
+ interval: "weekly"
34
+ - package-ecosystem: "pip"
35
+ directory: "/backend/python/bark"
36
+ schedule:
37
+ interval: "weekly"
38
+ - package-ecosystem: "pip"
39
+ directory: "/backend/python/common/template"
40
+ schedule:
41
+ interval: "weekly"
42
+ - package-ecosystem: "pip"
43
+ directory: "/backend/python/coqui"
44
+ schedule:
45
+ interval: "weekly"
46
+ - package-ecosystem: "pip"
47
+ directory: "/backend/python/diffusers"
48
+ schedule:
49
+ interval: "weekly"
50
+ - package-ecosystem: "pip"
51
+ directory: "/backend/python/exllama"
52
+ schedule:
53
+ interval: "weekly"
54
+ - package-ecosystem: "pip"
55
+ directory: "/backend/python/exllama2"
56
+ schedule:
57
+ interval: "weekly"
58
+ - package-ecosystem: "pip"
59
+ directory: "/backend/python/mamba"
60
+ schedule:
61
+ interval: "weekly"
62
+ - package-ecosystem: "pip"
63
+ directory: "/backend/python/openvoice"
64
+ schedule:
65
+ interval: "weekly"
66
+ - package-ecosystem: "pip"
67
+ directory: "/backend/python/parler-tts"
68
+ schedule:
69
+ interval: "weekly"
70
+ - package-ecosystem: "pip"
71
+ directory: "/backend/python/petals"
72
+ schedule:
73
+ interval: "weekly"
74
+ - package-ecosystem: "pip"
75
+ directory: "/backend/python/rerankers"
76
+ schedule:
77
+ interval: "weekly"
78
+ - package-ecosystem: "pip"
79
+ directory: "/backend/python/sentencetransformers"
80
+ schedule:
81
+ interval: "weekly"
82
+ - package-ecosystem: "pip"
83
+ directory: "/backend/python/transformers"
84
+ schedule:
85
+ interval: "weekly"
86
+ - package-ecosystem: "pip"
87
+ directory: "/backend/python/transformers-musicgen"
88
+ schedule:
89
+ interval: "weekly"
90
+ - package-ecosystem: "pip"
91
+ directory: "/backend/python/vall-e-x"
92
+ schedule:
93
+ interval: "weekly"
94
+ - package-ecosystem: "pip"
95
+ directory: "/backend/python/vllm"
96
+ schedule:
97
+ interval: "weekly"
98
+ - package-ecosystem: "pip"
99
+ directory: "/examples/chainlit"
100
+ schedule:
101
+ interval: "weekly"
102
+ - package-ecosystem: "pip"
103
+ directory: "/examples/functions"
104
+ schedule:
105
+ interval: "weekly"
106
+ - package-ecosystem: "pip"
107
+ directory: "/examples/langchain/langchainpy-localai-example"
108
+ schedule:
109
+ interval: "weekly"
110
+ - package-ecosystem: "pip"
111
+ directory: "/examples/langchain-chroma"
112
+ schedule:
113
+ interval: "weekly"
114
+ - package-ecosystem: "pip"
115
+ directory: "/examples/streamlit-bot"
116
+ schedule:
117
+ interval: "weekly"
118
+ - package-ecosystem: "docker"
119
+ directory: "/examples/k8sgpt"
120
+ schedule:
121
+ interval: "weekly"
122
+ - package-ecosystem: "docker"
123
+ directory: "/examples/kubernetes"
124
+ schedule:
125
+ interval: "weekly"
126
+ - package-ecosystem: "docker"
127
+ directory: "/examples/langchain"
128
+ schedule:
129
+ interval: "weekly"
130
+ - package-ecosystem: "gomod"
131
+ directory: "/examples/semantic-todo"
132
+ schedule:
133
+ interval: "weekly"
134
+ - package-ecosystem: "docker"
135
+ directory: "/examples/telegram-bot"
136
+ schedule:
137
+ interval: "weekly"
.github/labeler.yml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ enhancements:
2
+ - head-branch: ['^feature', 'feature']
3
+
4
+ kind/documentation:
5
+ - any:
6
+ - changed-files:
7
+ - any-glob-to-any-file: 'docs/*'
8
+ - changed-files:
9
+ - any-glob-to-any-file: '*.md'
10
+
11
+ area/ai-model:
12
+ - any:
13
+ - changed-files:
14
+ - any-glob-to-any-file: 'gallery/*'
15
+
16
+ examples:
17
+ - any:
18
+ - changed-files:
19
+ - any-glob-to-any-file: 'examples/*'
20
+
21
+ ci:
22
+ - any:
23
+ - changed-files:
24
+ - any-glob-to-any-file: '.github/*'
.github/release.yml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # .github/release.yml
2
+
3
+ changelog:
4
+ exclude:
5
+ labels:
6
+ - ignore-for-release
7
+ categories:
8
+ - title: Breaking Changes 🛠
9
+ labels:
10
+ - Semver-Major
11
+ - breaking-change
12
+ - title: "Bug fixes :bug:"
13
+ labels:
14
+ - bug
15
+ - regression
16
+ - title: "🖧 P2P area"
17
+ labels:
18
+ - area/p2p
19
+ - title: Exciting New Features 🎉
20
+ labels:
21
+ - Semver-Minor
22
+ - enhancement
23
+ - ux
24
+ - roadmap
25
+ - title: 🧠 Models
26
+ labels:
27
+ - area/ai-model
28
+ - title: 📖 Documentation and examples
29
+ labels:
30
+ - kind/documentation
31
+ - examples
32
+ - title: 👒 Dependencies
33
+ labels:
34
+ - dependencies
35
+ - title: Other Changes
36
+ labels:
37
+ - "*"
.github/stale.yml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Number of days of inactivity before an issue becomes stale
2
+ daysUntilStale: 45
3
+ # Number of days of inactivity before a stale issue is closed
4
+ daysUntilClose: 10
5
+ # Issues with these labels will never be considered stale
6
+ exemptLabels:
7
+ - issue/willfix
8
+ # Label to use when marking an issue as stale
9
+ staleLabel: issue/stale
10
+ # Comment to post when marking an issue as stale. Set to `false` to disable
11
+ markComment: >
12
+ This issue has been automatically marked as stale because it has not had
13
+ recent activity. It will be closed if no further activity occurs. Thank you
14
+ for your contributions.
15
+ # Comment to post when closing a stale issue. Set to `false` to disable
16
+ closeComment: >
17
+ This issue is being automatically closed due to inactivity.
18
+ However, you may choose to reopen this issue.
.github/workflows/bump_deps.yaml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Bump dependencies
2
+ on:
3
+ schedule:
4
+ - cron: 0 20 * * *
5
+ workflow_dispatch:
6
+ jobs:
7
+ bump:
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ include:
12
+ - repository: "ggerganov/llama.cpp"
13
+ variable: "CPPLLAMA_VERSION"
14
+ branch: "master"
15
+ - repository: "go-skynet/go-ggml-transformers.cpp"
16
+ variable: "GOGGMLTRANSFORMERS_VERSION"
17
+ branch: "master"
18
+ - repository: "donomii/go-rwkv.cpp"
19
+ variable: "RWKV_VERSION"
20
+ branch: "main"
21
+ - repository: "ggerganov/whisper.cpp"
22
+ variable: "WHISPER_CPP_VERSION"
23
+ branch: "master"
24
+ - repository: "go-skynet/go-bert.cpp"
25
+ variable: "BERT_VERSION"
26
+ branch: "master"
27
+ - repository: "go-skynet/bloomz.cpp"
28
+ variable: "BLOOMZ_VERSION"
29
+ branch: "main"
30
+ - repository: "mudler/go-ggllm.cpp"
31
+ variable: "GOGGLLM_VERSION"
32
+ branch: "master"
33
+ - repository: "mudler/go-stable-diffusion"
34
+ variable: "STABLEDIFFUSION_VERSION"
35
+ branch: "master"
36
+ - repository: "mudler/go-piper"
37
+ variable: "PIPER_VERSION"
38
+ branch: "master"
39
+ runs-on: ubuntu-latest
40
+ steps:
41
+ - uses: actions/checkout@v4
42
+ - name: Bump dependencies 🔧
43
+ id: bump
44
+ run: |
45
+ bash .github/bump_deps.sh ${{ matrix.repository }} ${{ matrix.branch }} ${{ matrix.variable }}
46
+ {
47
+ echo 'message<<EOF'
48
+ cat "${{ matrix.variable }}_message.txt"
49
+ echo EOF
50
+ } >> "$GITHUB_OUTPUT"
51
+ {
52
+ echo 'commit<<EOF'
53
+ cat "${{ matrix.variable }}_commit.txt"
54
+ echo EOF
55
+ } >> "$GITHUB_OUTPUT"
56
+ rm -rfv ${{ matrix.variable }}_message.txt
57
+ rm -rfv ${{ matrix.variable }}_commit.txt
58
+ - name: Create Pull Request
59
+ uses: peter-evans/create-pull-request@v6
60
+ with:
61
+ token: ${{ secrets.UPDATE_BOT_TOKEN }}
62
+ push-to-fork: ci-forks/LocalAI
63
+ commit-message: ':arrow_up: Update ${{ matrix.repository }}'
64
+ title: 'chore: :arrow_up: Update ${{ matrix.repository }} to `${{ steps.bump.outputs.commit }}`'
65
+ branch: "update/${{ matrix.variable }}"
66
+ body: ${{ steps.bump.outputs.message }}
67
+ signoff: true
68
+
69
+
70
+
.github/workflows/bump_docs.yaml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Bump dependencies
2
+ on:
3
+ schedule:
4
+ - cron: 0 20 * * *
5
+ workflow_dispatch:
6
+ jobs:
7
+ bump:
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ include:
12
+ - repository: "mudler/LocalAI"
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - name: Bump dependencies 🔧
17
+ run: |
18
+ bash .github/bump_docs.sh ${{ matrix.repository }}
19
+ - name: Create Pull Request
20
+ uses: peter-evans/create-pull-request@v6
21
+ with:
22
+ token: ${{ secrets.UPDATE_BOT_TOKEN }}
23
+ push-to-fork: ci-forks/LocalAI
24
+ commit-message: ':arrow_up: Update docs version ${{ matrix.repository }}'
25
+ title: 'docs: :arrow_up: update docs version ${{ matrix.repository }}'
26
+ branch: "update/docs"
27
+ body: Bump of ${{ matrix.repository }} version inside docs
28
+ signoff: true
29
+
30
+
31
+
.github/workflows/checksum_checker.yaml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Check if checksums are up-to-date
2
+ on:
3
+ schedule:
4
+ - cron: 0 20 * * *
5
+ workflow_dispatch:
6
+ jobs:
7
+ checksum_check:
8
+ runs-on: arc-runner-set
9
+ steps:
10
+ - name: Force Install GIT latest
11
+ run: |
12
+ sudo apt-get update \
13
+ && sudo apt-get install -y software-properties-common \
14
+ && sudo apt-get update \
15
+ && sudo add-apt-repository -y ppa:git-core/ppa \
16
+ && sudo apt-get update \
17
+ && sudo apt-get install -y git
18
+ - uses: actions/checkout@v4
19
+ - name: Install dependencies
20
+ run: |
21
+ sudo apt-get update
22
+ sudo apt-get install -y pip wget
23
+ sudo pip install --upgrade pip
24
+ pip install huggingface_hub
25
+ - name: 'Setup yq'
26
+ uses: dcarbone/[email protected]
27
+ with:
28
+ version: 'v4.44.2'
29
+ download-compressed: true
30
+ force: true
31
+
32
+ - name: Checksum checker 🔧
33
+ run: |
34
+ export HF_HOME=/hf_cache
35
+ sudo mkdir /hf_cache
36
+ sudo chmod 777 /hf_cache
37
+ bash .github/checksum_checker.sh gallery/index.yaml
38
+ - name: Create Pull Request
39
+ uses: peter-evans/create-pull-request@v6
40
+ with:
41
+ token: ${{ secrets.UPDATE_BOT_TOKEN }}
42
+ push-to-fork: ci-forks/LocalAI
43
+ commit-message: ':arrow_up: Checksum updates in gallery/index.yaml'
44
+ title: 'chore(model-gallery): :arrow_up: update checksum'
45
+ branch: "update/checksum"
46
+ body: Updating checksums in gallery/index.yaml
47
+ signoff: true
.github/workflows/dependabot_auto.yml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Dependabot auto-merge
2
+ on:
3
+ - pull_request_target
4
+
5
+ permissions:
6
+ contents: write
7
+ pull-requests: write
8
+ packages: read
9
+
10
+ jobs:
11
+ dependabot:
12
+ runs-on: ubuntu-latest
13
+ if: ${{ github.actor == 'dependabot[bot]' }}
14
+ steps:
15
+ - name: Dependabot metadata
16
+ id: metadata
17
+ uses: dependabot/[email protected]
18
+ with:
19
+ github-token: "${{ secrets.GITHUB_TOKEN }}"
20
+ skip-commit-verification: true
21
+
22
+ - name: Checkout repository
23
+ uses: actions/checkout@v4
24
+
25
+ - name: Approve a PR if not already approved
26
+ run: |
27
+ gh pr checkout "$PR_URL"
28
+ if [ "$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" != "APPROVED" ];
29
+ then
30
+ gh pr review --approve "$PR_URL"
31
+ else
32
+ echo "PR already approved.";
33
+ fi
34
+ env:
35
+ PR_URL: ${{github.event.pull_request.html_url}}
36
+ GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
37
+
38
+ - name: Enable auto-merge for Dependabot PRs
39
+ if: ${{ contains(github.event.pull_request.title, 'bump')}}
40
+ run: gh pr merge --auto --squash "$PR_URL"
41
+ env:
42
+ PR_URL: ${{github.event.pull_request.html_url}}
43
+ GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
.github/workflows/disabled/comment-pr.yaml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Comment PRs
2
+ on:
3
+ pull_request_target:
4
+
5
+ jobs:
6
+ comment-pr:
7
+ env:
8
+ MODEL_NAME: hermes-2-theta-llama-3-8b
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - name: Checkout code
12
+ uses: actions/checkout@v3
13
+ with:
14
+ ref: "${{ github.event.pull_request.merge_commit_sha }}"
15
+ fetch-depth: 0 # needed to checkout all branches for this Action to work
16
+ - uses: mudler/localai-github-action@v1
17
+ with:
18
+ model: 'hermes-2-theta-llama-3-8b' # Any from models.localai.io, or from huggingface.com with: "huggingface://<repository>/file"
19
+ # Check the PR diff using the current branch and the base branch of the PR
20
+ - uses: GrantBirki/[email protected]
21
+ id: git-diff-action
22
+ with:
23
+ json_diff_file_output: diff.json
24
+ raw_diff_file_output: diff.txt
25
+ file_output_only: "true"
26
+ base_branch: ${{ github.event.pull_request.base.sha }}
27
+ - name: Show diff
28
+ env:
29
+ DIFF: ${{ steps.git-diff-action.outputs.raw-diff-path }}
30
+ run: |
31
+ cat $DIFF
32
+ - name: Summarize
33
+ env:
34
+ DIFF: ${{ steps.git-diff-action.outputs.raw-diff-path }}
35
+ id: summarize
36
+ run: |
37
+ input="$(cat $DIFF)"
38
+
39
+ # Define the LocalAI API endpoint
40
+ API_URL="http://localhost:8080/chat/completions"
41
+
42
+ # Create a JSON payload using jq to handle special characters
43
+ json_payload=$(jq -n --arg input "$input" '{
44
+ model: "'$MODEL_NAME'",
45
+ messages: [
46
+ {
47
+ role: "system",
48
+ content: "You are LocalAI-bot in Github that helps understanding PRs and assess complexity. Explain what has changed in this PR diff and why"
49
+ },
50
+ {
51
+ role: "user",
52
+ content: $input
53
+ }
54
+ ]
55
+ }')
56
+
57
+ # Send the request to LocalAI
58
+ response=$(curl -s -X POST $API_URL \
59
+ -H "Content-Type: application/json" \
60
+ -d "$json_payload")
61
+
62
+ # Extract the summary from the response
63
+ summary="$(echo $response | jq -r '.choices[0].message.content')"
64
+
65
+ # Print the summary
66
+ # -H "Authorization: Bearer $API_KEY" \
67
+ echo "Summary:"
68
+ echo "$summary"
69
+ echo "payload sent"
70
+ echo "$json_payload"
71
+ {
72
+ echo 'message<<EOF'
73
+ echo "$summary"
74
+ echo EOF
75
+ } >> "$GITHUB_OUTPUT"
76
+ docker logs --tail 10 local-ai
77
+ - uses: mshick/add-pr-comment@v2
78
+ if: always()
79
+ with:
80
+ repo-token: ${{ secrets.UPDATE_BOT_TOKEN }}
81
+ message: ${{ steps.summarize.outputs.message }}
82
+ message-failure: |
83
+ Uh oh! Could not analyze this PR, maybe it's too big?
.github/workflows/disabled/test-gpu.yml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: 'GPU tests'
3
+
4
+ on:
5
+ pull_request:
6
+ push:
7
+ branches:
8
+ - master
9
+ tags:
10
+ - '*'
11
+
12
+ concurrency:
13
+ group: ci-gpu-tests-${{ github.head_ref || github.ref }}-${{ github.repository }}
14
+ cancel-in-progress: true
15
+
16
+ jobs:
17
+ ubuntu-latest:
18
+ runs-on: gpu
19
+ strategy:
20
+ matrix:
21
+ go-version: ['1.21.x']
22
+ steps:
23
+ - name: Clone
24
+ uses: actions/checkout@v4
25
+ with:
26
+ submodules: true
27
+ - name: Setup Go ${{ matrix.go-version }}
28
+ uses: actions/setup-go@v4
29
+ with:
30
+ go-version: ${{ matrix.go-version }}
31
+ # You can test your matrix by printing the current Go version
32
+ - name: Display Go version
33
+ run: go version
34
+ - name: Dependencies
35
+ run: |
36
+ sudo apt-get update
37
+ sudo DEBIAN_FRONTEND=noninteractive apt-get install -y make wget
38
+ - name: Build
39
+ run: |
40
+ if [ ! -e /run/systemd/system ]; then
41
+ sudo mkdir /run/systemd/system
42
+ fi
43
+ sudo mkdir -p /host/tests/${{ github.head_ref || github.ref }}
44
+ sudo chmod -R 777 /host/tests/${{ github.head_ref || github.ref }}
45
+ make \
46
+ TEST_DIR="/host/tests/${{ github.head_ref || github.ref }}" \
47
+ BUILD_TYPE=cublas \
48
+ prepare-e2e run-e2e-image test-e2e
49
+ - name: Release space from worker ♻
50
+ if: always()
51
+ run: |
52
+ sudo rm -rf build || true
53
+ sudo rm -rf bin || true
54
+ sudo rm -rf dist || true
55
+ sudo docker logs $(sudo docker ps -q --filter ancestor=localai-tests) > logs.txt
56
+ sudo cat logs.txt || true
57
+ sudo rm -rf logs.txt
58
+ make clean || true
59
+ make \
60
+ TEST_DIR="/host/tests/${{ github.head_ref || github.ref }}" \
61
+ teardown-e2e || true
62
+ sudo rm -rf /host/tests/${{ github.head_ref || github.ref }} || true
63
+ docker system prune -f -a --volumes || true
.github/workflows/generate_grpc_cache.yaml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 'generate and publish GRPC docker caches'
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches:
7
+ - master
8
+
9
+ concurrency:
10
+ group: grpc-cache-${{ github.head_ref || github.ref }}-${{ github.repository }}
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ generate_caches:
15
+ strategy:
16
+ matrix:
17
+ include:
18
+ - grpc-base-image: ubuntu:22.04
19
+ runs-on: 'ubuntu-latest'
20
+ platforms: 'linux/amd64,linux/arm64'
21
+ runs-on: ${{matrix.runs-on}}
22
+ steps:
23
+ - name: Release space from worker
24
+ if: matrix.runs-on == 'ubuntu-latest'
25
+ run: |
26
+ echo "Listing top largest packages"
27
+ pkgs=$(dpkg-query -Wf '${Installed-Size}\t${Package}\t${Status}\n' | awk '$NF == "installed"{print $1 "\t" $2}' | sort -nr)
28
+ head -n 30 <<< "${pkgs}"
29
+ echo
30
+ df -h
31
+ echo
32
+ sudo apt-get remove -y '^llvm-.*|^libllvm.*' || true
33
+ sudo apt-get remove --auto-remove android-sdk-platform-tools || true
34
+ sudo apt-get purge --auto-remove android-sdk-platform-tools || true
35
+ sudo rm -rf /usr/local/lib/android
36
+ sudo apt-get remove -y '^dotnet-.*|^aspnetcore-.*' || true
37
+ sudo rm -rf /usr/share/dotnet
38
+ sudo apt-get remove -y '^mono-.*' || true
39
+ sudo apt-get remove -y '^ghc-.*' || true
40
+ sudo apt-get remove -y '.*jdk.*|.*jre.*' || true
41
+ sudo apt-get remove -y 'php.*' || true
42
+ sudo apt-get remove -y hhvm powershell firefox monodoc-manual msbuild || true
43
+ sudo apt-get remove -y '^google-.*' || true
44
+ sudo apt-get remove -y azure-cli || true
45
+ sudo apt-get remove -y '^mongo.*-.*|^postgresql-.*|^mysql-.*|^mssql-.*' || true
46
+ sudo apt-get remove -y '^gfortran-.*' || true
47
+ sudo apt-get remove -y microsoft-edge-stable || true
48
+ sudo apt-get remove -y firefox || true
49
+ sudo apt-get remove -y powershell || true
50
+ sudo apt-get remove -y r-base-core || true
51
+ sudo apt-get autoremove -y
52
+ sudo apt-get clean
53
+ echo
54
+ echo "Listing top largest packages"
55
+ pkgs=$(dpkg-query -Wf '${Installed-Size}\t${Package}\t${Status}\n' | awk '$NF == "installed"{print $1 "\t" $2}' | sort -nr)
56
+ head -n 30 <<< "${pkgs}"
57
+ echo
58
+ sudo rm -rfv build || true
59
+ sudo rm -rf /usr/share/dotnet || true
60
+ sudo rm -rf /opt/ghc || true
61
+ sudo rm -rf "/usr/local/share/boost" || true
62
+ sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true
63
+ df -h
64
+
65
+ - name: Set up QEMU
66
+ uses: docker/setup-qemu-action@master
67
+ with:
68
+ platforms: all
69
+
70
+ - name: Set up Docker Buildx
71
+ id: buildx
72
+ uses: docker/setup-buildx-action@master
73
+
74
+ - name: Checkout
75
+ uses: actions/checkout@v4
76
+
77
+ - name: Cache GRPC
78
+ uses: docker/build-push-action@v6
79
+ with:
80
+ builder: ${{ steps.buildx.outputs.name }}
81
+ # The build-args MUST be an EXACT match between the image cache and other workflow steps that want to use that cache.
82
+ # This means that even the MAKEFLAGS have to be an EXACT match.
83
+ # If the build-args are not an EXACT match, it will result in a cache miss, which will require GRPC to be built from scratch.
84
+ build-args: |
85
+ GRPC_BASE_IMAGE=${{ matrix.grpc-base-image }}
86
+ GRPC_MAKEFLAGS=--jobs=4 --output-sync=target
87
+ GRPC_VERSION=v1.65.0
88
+ context: .
89
+ file: ./Dockerfile
90
+ cache-to: type=gha,ignore-error=true
91
+ cache-from: type=gha
92
+ target: grpc
93
+ platforms: ${{ matrix.platforms }}
94
+ push: false
.github/workflows/generate_intel_image.yaml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 'generate and publish intel docker caches'
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches:
7
+ - master
8
+
9
+ concurrency:
10
+ group: intel-cache-${{ github.head_ref || github.ref }}-${{ github.repository }}
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ generate_caches:
15
+ strategy:
16
+ matrix:
17
+ include:
18
+ - base-image: intel/oneapi-basekit:2024.2.0-devel-ubuntu22.04
19
+ runs-on: 'ubuntu-latest'
20
+ platforms: 'linux/amd64'
21
+ runs-on: ${{matrix.runs-on}}
22
+ steps:
23
+ - name: Set up QEMU
24
+ uses: docker/setup-qemu-action@master
25
+ with:
26
+ platforms: all
27
+ - name: Login to DockerHub
28
+ if: github.event_name != 'pull_request'
29
+ uses: docker/login-action@v3
30
+ with:
31
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
32
+ password: ${{ secrets.DOCKERHUB_PASSWORD }}
33
+
34
+ - name: Login to quay
35
+ if: github.event_name != 'pull_request'
36
+ uses: docker/login-action@v3
37
+ with:
38
+ registry: quay.io
39
+ username: ${{ secrets.LOCALAI_REGISTRY_USERNAME }}
40
+ password: ${{ secrets.LOCALAI_REGISTRY_PASSWORD }}
41
+ - name: Set up Docker Buildx
42
+ id: buildx
43
+ uses: docker/setup-buildx-action@master
44
+
45
+ - name: Checkout
46
+ uses: actions/checkout@v4
47
+
48
+ - name: Cache Intel images
49
+ uses: docker/build-push-action@v6
50
+ with:
51
+ builder: ${{ steps.buildx.outputs.name }}
52
+ build-args: |
53
+ BASE_IMAGE=${{ matrix.base-image }}
54
+ context: .
55
+ file: ./Dockerfile
56
+ tags: quay.io/go-skynet/intel-oneapi-base:latest
57
+ push: true
58
+ target: intel
59
+ platforms: ${{ matrix.platforms }}
.github/workflows/image-pr.yml ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: 'build container images tests'
3
+
4
+ on:
5
+ pull_request:
6
+
7
+ concurrency:
8
+ group: ci-${{ github.head_ref || github.ref }}-${{ github.repository }}
9
+ cancel-in-progress: true
10
+
11
+ jobs:
12
+ extras-image-build:
13
+ uses: ./.github/workflows/image_build.yml
14
+ with:
15
+ tag-latest: ${{ matrix.tag-latest }}
16
+ tag-suffix: ${{ matrix.tag-suffix }}
17
+ ffmpeg: ${{ matrix.ffmpeg }}
18
+ image-type: ${{ matrix.image-type }}
19
+ build-type: ${{ matrix.build-type }}
20
+ cuda-major-version: ${{ matrix.cuda-major-version }}
21
+ cuda-minor-version: ${{ matrix.cuda-minor-version }}
22
+ platforms: ${{ matrix.platforms }}
23
+ runs-on: ${{ matrix.runs-on }}
24
+ base-image: ${{ matrix.base-image }}
25
+ grpc-base-image: ${{ matrix.grpc-base-image }}
26
+ makeflags: ${{ matrix.makeflags }}
27
+ secrets:
28
+ dockerUsername: ${{ secrets.DOCKERHUB_USERNAME }}
29
+ dockerPassword: ${{ secrets.DOCKERHUB_PASSWORD }}
30
+ quayUsername: ${{ secrets.LOCALAI_REGISTRY_USERNAME }}
31
+ quayPassword: ${{ secrets.LOCALAI_REGISTRY_PASSWORD }}
32
+ strategy:
33
+ # Pushing with all jobs in parallel
34
+ # eats the bandwidth of all the nodes
35
+ max-parallel: ${{ github.event_name != 'pull_request' && 4 || 8 }}
36
+ matrix:
37
+ include:
38
+ # This is basically covered by the AIO test
39
+ # - build-type: ''
40
+ # platforms: 'linux/amd64'
41
+ # tag-latest: 'false'
42
+ # tag-suffix: '-ffmpeg'
43
+ # ffmpeg: 'true'
44
+ # image-type: 'extras'
45
+ # runs-on: 'arc-runner-set'
46
+ # base-image: "ubuntu:22.04"
47
+ # makeflags: "--jobs=3 --output-sync=target"
48
+ - build-type: 'cublas'
49
+ cuda-major-version: "12"
50
+ cuda-minor-version: "0"
51
+ platforms: 'linux/amd64'
52
+ tag-latest: 'false'
53
+ tag-suffix: '-cublas-cuda12-ffmpeg'
54
+ ffmpeg: 'true'
55
+ image-type: 'extras'
56
+ runs-on: 'arc-runner-set'
57
+ base-image: "ubuntu:22.04"
58
+ makeflags: "--jobs=3 --output-sync=target"
59
+ # - build-type: 'hipblas'
60
+ # platforms: 'linux/amd64'
61
+ # tag-latest: 'false'
62
+ # tag-suffix: '-hipblas'
63
+ # ffmpeg: 'false'
64
+ # image-type: 'extras'
65
+ # base-image: "rocm/dev-ubuntu-22.04:6.1"
66
+ # grpc-base-image: "ubuntu:22.04"
67
+ # runs-on: 'arc-runner-set'
68
+ # makeflags: "--jobs=3 --output-sync=target"
69
+ # - build-type: 'sycl_f16'
70
+ # platforms: 'linux/amd64'
71
+ # tag-latest: 'false'
72
+ # base-image: "quay.io/go-skynet/intel-oneapi-base:latest"
73
+ # grpc-base-image: "ubuntu:22.04"
74
+ # tag-suffix: 'sycl-f16-ffmpeg'
75
+ # ffmpeg: 'true'
76
+ # image-type: 'extras'
77
+ # runs-on: 'arc-runner-set'
78
+ # makeflags: "--jobs=3 --output-sync=target"
79
+ # core-image-build:
80
+ # uses: ./.github/workflows/image_build.yml
81
+ # with:
82
+ # tag-latest: ${{ matrix.tag-latest }}
83
+ # tag-suffix: ${{ matrix.tag-suffix }}
84
+ # ffmpeg: ${{ matrix.ffmpeg }}
85
+ # image-type: ${{ matrix.image-type }}
86
+ # build-type: ${{ matrix.build-type }}
87
+ # cuda-major-version: ${{ matrix.cuda-major-version }}
88
+ # cuda-minor-version: ${{ matrix.cuda-minor-version }}
89
+ # platforms: ${{ matrix.platforms }}
90
+ # runs-on: ${{ matrix.runs-on }}
91
+ # base-image: ${{ matrix.base-image }}
92
+ # grpc-base-image: ${{ matrix.grpc-base-image }}
93
+ # makeflags: ${{ matrix.makeflags }}
94
+ # secrets:
95
+ # dockerUsername: ${{ secrets.DOCKERHUB_USERNAME }}
96
+ # dockerPassword: ${{ secrets.DOCKERHUB_PASSWORD }}
97
+ # quayUsername: ${{ secrets.LOCALAI_REGISTRY_USERNAME }}
98
+ # quayPassword: ${{ secrets.LOCALAI_REGISTRY_PASSWORD }}
99
+ # strategy:
100
+ # matrix:
101
+ # include:
102
+ # - build-type: ''
103
+ # platforms: 'linux/amd64'
104
+ # tag-latest: 'false'
105
+ # tag-suffix: '-ffmpeg-core'
106
+ # ffmpeg: 'true'
107
+ # image-type: 'core'
108
+ # runs-on: 'ubuntu-latest'
109
+ # base-image: "ubuntu:22.04"
110
+ # makeflags: "--jobs=4 --output-sync=target"
111
+ # - build-type: 'sycl_f16'
112
+ # platforms: 'linux/amd64'
113
+ # tag-latest: 'false'
114
+ # base-image: "quay.io/go-skynet/intel-oneapi-base:latest"
115
+ # grpc-base-image: "ubuntu:22.04"
116
+ # tag-suffix: 'sycl-f16-ffmpeg-core'
117
+ # ffmpeg: 'true'
118
+ # image-type: 'core'
119
+ # runs-on: 'arc-runner-set'
120
+ # makeflags: "--jobs=3 --output-sync=target"
121
+ # - build-type: 'cublas'
122
+ # cuda-major-version: "12"
123
+ # cuda-minor-version: "0"
124
+ # platforms: 'linux/amd64'
125
+ # tag-latest: 'false'
126
+ # tag-suffix: '-cublas-cuda12-ffmpeg-core'
127
+ # ffmpeg: 'true'
128
+ # image-type: 'core'
129
+ # runs-on: 'ubuntu-latest'
130
+ # base-image: "ubuntu:22.04"
131
+ # makeflags: "--jobs=4 --output-sync=target"
132
+ # - build-type: 'vulkan'
133
+ # platforms: 'linux/amd64'
134
+ # tag-latest: 'false'
135
+ # tag-suffix: '-vulkan-ffmpeg-core'
136
+ # ffmpeg: 'true'
137
+ # image-type: 'core'
138
+ # runs-on: 'ubuntu-latest'
139
+ # base-image: "ubuntu:22.04"
140
+ # makeflags: "--jobs=4 --output-sync=target"
.github/workflows/image.yml ADDED
@@ -0,0 +1,328 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: 'build container images'
3
+
4
+ on:
5
+ push:
6
+ branches:
7
+ - master
8
+ tags:
9
+ - '*'
10
+
11
+ concurrency:
12
+ group: ci-${{ github.head_ref || github.ref }}-${{ github.repository }}
13
+ cancel-in-progress: true
14
+
15
+ jobs:
16
+ self-hosted-jobs:
17
+ uses: ./.github/workflows/image_build.yml
18
+ with:
19
+ tag-latest: ${{ matrix.tag-latest }}
20
+ tag-suffix: ${{ matrix.tag-suffix }}
21
+ ffmpeg: ${{ matrix.ffmpeg }}
22
+ image-type: ${{ matrix.image-type }}
23
+ build-type: ${{ matrix.build-type }}
24
+ cuda-major-version: ${{ matrix.cuda-major-version }}
25
+ cuda-minor-version: ${{ matrix.cuda-minor-version }}
26
+ platforms: ${{ matrix.platforms }}
27
+ runs-on: ${{ matrix.runs-on }}
28
+ base-image: ${{ matrix.base-image }}
29
+ grpc-base-image: ${{ matrix.grpc-base-image }}
30
+ aio: ${{ matrix.aio }}
31
+ makeflags: ${{ matrix.makeflags }}
32
+ latest-image: ${{ matrix.latest-image }}
33
+ latest-image-aio: ${{ matrix.latest-image-aio }}
34
+ secrets:
35
+ dockerUsername: ${{ secrets.DOCKERHUB_USERNAME }}
36
+ dockerPassword: ${{ secrets.DOCKERHUB_PASSWORD }}
37
+ quayUsername: ${{ secrets.LOCALAI_REGISTRY_USERNAME }}
38
+ quayPassword: ${{ secrets.LOCALAI_REGISTRY_PASSWORD }}
39
+ strategy:
40
+ # Pushing with all jobs in parallel
41
+ # eats the bandwidth of all the nodes
42
+ max-parallel: ${{ github.event_name != 'pull_request' && 6 || 10 }}
43
+ matrix:
44
+ include:
45
+ # Extra images
46
+ - build-type: ''
47
+ #platforms: 'linux/amd64,linux/arm64'
48
+ platforms: 'linux/amd64'
49
+ tag-latest: 'auto'
50
+ tag-suffix: ''
51
+ ffmpeg: ''
52
+ image-type: 'extras'
53
+ runs-on: 'arc-runner-set'
54
+ base-image: "ubuntu:22.04"
55
+ makeflags: "--jobs=3 --output-sync=target"
56
+ - build-type: ''
57
+ platforms: 'linux/amd64'
58
+ tag-latest: 'auto'
59
+ tag-suffix: '-ffmpeg'
60
+ ffmpeg: 'true'
61
+ image-type: 'extras'
62
+ runs-on: 'arc-runner-set'
63
+ base-image: "ubuntu:22.04"
64
+ makeflags: "--jobs=3 --output-sync=target"
65
+ - build-type: 'cublas'
66
+ cuda-major-version: "11"
67
+ cuda-minor-version: "7"
68
+ platforms: 'linux/amd64'
69
+ tag-latest: 'false'
70
+ tag-suffix: '-cublas-cuda11'
71
+ ffmpeg: ''
72
+ image-type: 'extras'
73
+ runs-on: 'arc-runner-set'
74
+ base-image: "ubuntu:22.04"
75
+ makeflags: "--jobs=3 --output-sync=target"
76
+ - build-type: 'cublas'
77
+ cuda-major-version: "12"
78
+ cuda-minor-version: "0"
79
+ platforms: 'linux/amd64'
80
+ tag-latest: 'false'
81
+ tag-suffix: '-cublas-cuda12'
82
+ ffmpeg: ''
83
+ image-type: 'extras'
84
+ runs-on: 'arc-runner-set'
85
+ base-image: "ubuntu:22.04"
86
+ makeflags: "--jobs=3 --output-sync=target"
87
+ - build-type: 'cublas'
88
+ cuda-major-version: "11"
89
+ cuda-minor-version: "7"
90
+ platforms: 'linux/amd64'
91
+ tag-latest: 'auto'
92
+ tag-suffix: '-cublas-cuda11-ffmpeg'
93
+ ffmpeg: 'true'
94
+ image-type: 'extras'
95
+ runs-on: 'arc-runner-set'
96
+ base-image: "ubuntu:22.04"
97
+ aio: "-aio-gpu-nvidia-cuda-11"
98
+ latest-image: 'latest-gpu-nvidia-cuda-11'
99
+ latest-image-aio: 'latest-aio-gpu-nvidia-cuda-11'
100
+ makeflags: "--jobs=3 --output-sync=target"
101
+ - build-type: 'cublas'
102
+ cuda-major-version: "12"
103
+ cuda-minor-version: "0"
104
+ platforms: 'linux/amd64'
105
+ tag-latest: 'auto'
106
+ tag-suffix: '-cublas-cuda12-ffmpeg'
107
+ ffmpeg: 'true'
108
+ image-type: 'extras'
109
+ runs-on: 'arc-runner-set'
110
+ base-image: "ubuntu:22.04"
111
+ aio: "-aio-gpu-nvidia-cuda-12"
112
+ latest-image: 'latest-gpu-nvidia-cuda-12'
113
+ latest-image-aio: 'latest-aio-gpu-nvidia-cuda-12'
114
+ makeflags: "--jobs=3 --output-sync=target"
115
+ - build-type: ''
116
+ #platforms: 'linux/amd64,linux/arm64'
117
+ platforms: 'linux/amd64'
118
+ tag-latest: 'auto'
119
+ tag-suffix: ''
120
+ ffmpeg: ''
121
+ image-type: 'extras'
122
+ base-image: "ubuntu:22.04"
123
+ runs-on: 'arc-runner-set'
124
+ makeflags: "--jobs=3 --output-sync=target"
125
+ - build-type: 'hipblas'
126
+ platforms: 'linux/amd64'
127
+ tag-latest: 'auto'
128
+ tag-suffix: '-hipblas-ffmpeg'
129
+ ffmpeg: 'true'
130
+ image-type: 'extras'
131
+ aio: "-aio-gpu-hipblas"
132
+ base-image: "rocm/dev-ubuntu-22.04:6.1"
133
+ grpc-base-image: "ubuntu:22.04"
134
+ latest-image: 'latest-gpu-hipblas'
135
+ latest-image-aio: 'latest-aio-gpu-hipblas'
136
+ runs-on: 'arc-runner-set'
137
+ makeflags: "--jobs=3 --output-sync=target"
138
+ - build-type: 'hipblas'
139
+ platforms: 'linux/amd64'
140
+ tag-latest: 'false'
141
+ tag-suffix: '-hipblas'
142
+ ffmpeg: 'false'
143
+ image-type: 'extras'
144
+ base-image: "rocm/dev-ubuntu-22.04:6.1"
145
+ grpc-base-image: "ubuntu:22.04"
146
+ runs-on: 'arc-runner-set'
147
+ makeflags: "--jobs=3 --output-sync=target"
148
+ - build-type: 'sycl_f16'
149
+ platforms: 'linux/amd64'
150
+ tag-latest: 'auto'
151
+ base-image: "quay.io/go-skynet/intel-oneapi-base:latest"
152
+ grpc-base-image: "ubuntu:22.04"
153
+ tag-suffix: '-sycl-f16-ffmpeg'
154
+ ffmpeg: 'true'
155
+ image-type: 'extras'
156
+ runs-on: 'arc-runner-set'
157
+ aio: "-aio-gpu-intel-f16"
158
+ latest-image: 'latest-gpu-intel-f16'
159
+ latest-image-aio: 'latest-aio-gpu-intel-f16'
160
+ makeflags: "--jobs=3 --output-sync=target"
161
+ - build-type: 'sycl_f32'
162
+ platforms: 'linux/amd64'
163
+ tag-latest: 'auto'
164
+ base-image: "quay.io/go-skynet/intel-oneapi-base:latest"
165
+ grpc-base-image: "ubuntu:22.04"
166
+ tag-suffix: '-sycl-f32-ffmpeg'
167
+ ffmpeg: 'true'
168
+ image-type: 'extras'
169
+ runs-on: 'arc-runner-set'
170
+ aio: "-aio-gpu-intel-f32"
171
+ latest-image: 'latest-gpu-intel-f32'
172
+ latest-image-aio: 'latest-aio-gpu-intel-f32'
173
+ makeflags: "--jobs=3 --output-sync=target"
174
+ # Core images
175
+ - build-type: 'sycl_f16'
176
+ platforms: 'linux/amd64'
177
+ tag-latest: 'false'
178
+ base-image: "quay.io/go-skynet/intel-oneapi-base:latest"
179
+ grpc-base-image: "ubuntu:22.04"
180
+ tag-suffix: '-sycl-f16-core'
181
+ ffmpeg: 'false'
182
+ image-type: 'core'
183
+ runs-on: 'arc-runner-set'
184
+ makeflags: "--jobs=3 --output-sync=target"
185
+ - build-type: 'sycl_f32'
186
+ platforms: 'linux/amd64'
187
+ tag-latest: 'false'
188
+ base-image: "quay.io/go-skynet/intel-oneapi-base:latest"
189
+ grpc-base-image: "ubuntu:22.04"
190
+ tag-suffix: '-sycl-f32-core'
191
+ ffmpeg: 'false'
192
+ image-type: 'core'
193
+ runs-on: 'arc-runner-set'
194
+ makeflags: "--jobs=3 --output-sync=target"
195
+ - build-type: 'sycl_f16'
196
+ platforms: 'linux/amd64'
197
+ tag-latest: 'false'
198
+ base-image: "quay.io/go-skynet/intel-oneapi-base:latest"
199
+ grpc-base-image: "ubuntu:22.04"
200
+ tag-suffix: '-sycl-f16-ffmpeg-core'
201
+ ffmpeg: 'true'
202
+ image-type: 'core'
203
+ runs-on: 'arc-runner-set'
204
+ makeflags: "--jobs=3 --output-sync=target"
205
+ - build-type: 'sycl_f32'
206
+ platforms: 'linux/amd64'
207
+ tag-latest: 'false'
208
+ base-image: "quay.io/go-skynet/intel-oneapi-base:latest"
209
+ grpc-base-image: "ubuntu:22.04"
210
+ tag-suffix: '-sycl-f32-ffmpeg-core'
211
+ ffmpeg: 'true'
212
+ image-type: 'core'
213
+ runs-on: 'arc-runner-set'
214
+ makeflags: "--jobs=3 --output-sync=target"
215
+ - build-type: 'hipblas'
216
+ platforms: 'linux/amd64'
217
+ tag-latest: 'false'
218
+ tag-suffix: '-hipblas-ffmpeg-core'
219
+ ffmpeg: 'true'
220
+ image-type: 'core'
221
+ base-image: "rocm/dev-ubuntu-22.04:6.1"
222
+ grpc-base-image: "ubuntu:22.04"
223
+ runs-on: 'arc-runner-set'
224
+ makeflags: "--jobs=3 --output-sync=target"
225
+ - build-type: 'hipblas'
226
+ platforms: 'linux/amd64'
227
+ tag-latest: 'false'
228
+ tag-suffix: '-hipblas-core'
229
+ ffmpeg: 'false'
230
+ image-type: 'core'
231
+ base-image: "rocm/dev-ubuntu-22.04:6.1"
232
+ grpc-base-image: "ubuntu:22.04"
233
+ runs-on: 'arc-runner-set'
234
+ makeflags: "--jobs=3 --output-sync=target"
235
+
236
+ core-image-build:
237
+ uses: ./.github/workflows/image_build.yml
238
+ with:
239
+ tag-latest: ${{ matrix.tag-latest }}
240
+ tag-suffix: ${{ matrix.tag-suffix }}
241
+ ffmpeg: ${{ matrix.ffmpeg }}
242
+ image-type: ${{ matrix.image-type }}
243
+ build-type: ${{ matrix.build-type }}
244
+ cuda-major-version: ${{ matrix.cuda-major-version }}
245
+ cuda-minor-version: ${{ matrix.cuda-minor-version }}
246
+ platforms: ${{ matrix.platforms }}
247
+ runs-on: ${{ matrix.runs-on }}
248
+ aio: ${{ matrix.aio }}
249
+ base-image: ${{ matrix.base-image }}
250
+ grpc-base-image: ${{ matrix.grpc-base-image }}
251
+ makeflags: ${{ matrix.makeflags }}
252
+ latest-image: ${{ matrix.latest-image }}
253
+ latest-image-aio: ${{ matrix.latest-image-aio }}
254
+ secrets:
255
+ dockerUsername: ${{ secrets.DOCKERHUB_USERNAME }}
256
+ dockerPassword: ${{ secrets.DOCKERHUB_PASSWORD }}
257
+ quayUsername: ${{ secrets.LOCALAI_REGISTRY_USERNAME }}
258
+ quayPassword: ${{ secrets.LOCALAI_REGISTRY_PASSWORD }}
259
+ strategy:
260
+ max-parallel: ${{ github.event_name != 'pull_request' && 2 || 4 }}
261
+ matrix:
262
+ include:
263
+ - build-type: ''
264
+ platforms: 'linux/amd64,linux/arm64'
265
+ tag-latest: 'auto'
266
+ tag-suffix: '-ffmpeg-core'
267
+ ffmpeg: 'true'
268
+ image-type: 'core'
269
+ base-image: "ubuntu:22.04"
270
+ runs-on: 'arc-runner-set'
271
+ aio: "-aio-cpu"
272
+ latest-image: 'latest-cpu'
273
+ latest-image-aio: 'latest-aio-cpu'
274
+ makeflags: "--jobs=4 --output-sync=target"
275
+ - build-type: 'cublas'
276
+ cuda-major-version: "11"
277
+ cuda-minor-version: "7"
278
+ platforms: 'linux/amd64'
279
+ tag-latest: 'false'
280
+ tag-suffix: '-cublas-cuda11-core'
281
+ ffmpeg: ''
282
+ image-type: 'core'
283
+ base-image: "ubuntu:22.04"
284
+ runs-on: 'arc-runner-set'
285
+ makeflags: "--jobs=4 --output-sync=target"
286
+ - build-type: 'cublas'
287
+ cuda-major-version: "12"
288
+ cuda-minor-version: "0"
289
+ platforms: 'linux/amd64'
290
+ tag-latest: 'false'
291
+ tag-suffix: '-cublas-cuda12-core'
292
+ ffmpeg: ''
293
+ image-type: 'core'
294
+ base-image: "ubuntu:22.04"
295
+ runs-on: 'arc-runner-set'
296
+ makeflags: "--jobs=4 --output-sync=target"
297
+ - build-type: 'cublas'
298
+ cuda-major-version: "11"
299
+ cuda-minor-version: "7"
300
+ platforms: 'linux/amd64'
301
+ tag-latest: 'false'
302
+ tag-suffix: '-cublas-cuda11-ffmpeg-core'
303
+ ffmpeg: 'true'
304
+ image-type: 'core'
305
+ runs-on: 'arc-runner-set'
306
+ base-image: "ubuntu:22.04"
307
+ makeflags: "--jobs=4 --output-sync=target"
308
+ - build-type: 'cublas'
309
+ cuda-major-version: "12"
310
+ cuda-minor-version: "0"
311
+ platforms: 'linux/amd64'
312
+ tag-latest: 'false'
313
+ tag-suffix: '-cublas-cuda12-ffmpeg-core'
314
+ ffmpeg: 'true'
315
+ image-type: 'core'
316
+ runs-on: 'arc-runner-set'
317
+ base-image: "ubuntu:22.04"
318
+ makeflags: "--jobs=4 --output-sync=target"
319
+ - build-type: 'vulkan'
320
+ platforms: 'linux/amd64'
321
+ tag-latest: 'false'
322
+ tag-suffix: '-vulkan-ffmpeg-core'
323
+ latest-image: 'latest-vulkan-ffmpeg-core'
324
+ ffmpeg: 'true'
325
+ image-type: 'core'
326
+ runs-on: 'arc-runner-set'
327
+ base-image: "ubuntu:22.04"
328
+ makeflags: "--jobs=4 --output-sync=target"
.github/workflows/image_build.yml ADDED
@@ -0,0 +1,335 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: 'build container images (reusable)'
3
+
4
+ on:
5
+ workflow_call:
6
+ inputs:
7
+ base-image:
8
+ description: 'Base image'
9
+ required: true
10
+ type: string
11
+ grpc-base-image:
12
+ description: 'GRPC Base image, must be a compatible image with base-image'
13
+ required: false
14
+ default: ''
15
+ type: string
16
+ build-type:
17
+ description: 'Build type'
18
+ default: ''
19
+ type: string
20
+ cuda-major-version:
21
+ description: 'CUDA major version'
22
+ default: "12"
23
+ type: string
24
+ cuda-minor-version:
25
+ description: 'CUDA minor version'
26
+ default: "4"
27
+ type: string
28
+ platforms:
29
+ description: 'Platforms'
30
+ default: ''
31
+ type: string
32
+ tag-latest:
33
+ description: 'Tag latest'
34
+ default: ''
35
+ type: string
36
+ latest-image:
37
+ description: 'Tag latest'
38
+ default: ''
39
+ type: string
40
+ latest-image-aio:
41
+ description: 'Tag latest'
42
+ default: ''
43
+ type: string
44
+ tag-suffix:
45
+ description: 'Tag suffix'
46
+ default: ''
47
+ type: string
48
+ ffmpeg:
49
+ description: 'FFMPEG'
50
+ default: ''
51
+ type: string
52
+ image-type:
53
+ description: 'Image type'
54
+ default: ''
55
+ type: string
56
+ runs-on:
57
+ description: 'Runs on'
58
+ required: true
59
+ default: ''
60
+ type: string
61
+ makeflags:
62
+ description: 'Make Flags'
63
+ required: false
64
+ default: '--jobs=4 --output-sync=target'
65
+ type: string
66
+ aio:
67
+ description: 'AIO Image Name'
68
+ required: false
69
+ default: ''
70
+ type: string
71
+ secrets:
72
+ dockerUsername:
73
+ required: true
74
+ dockerPassword:
75
+ required: true
76
+ quayUsername:
77
+ required: true
78
+ quayPassword:
79
+ required: true
80
+ jobs:
81
+ reusable_image-build:
82
+ runs-on: ${{ inputs.runs-on }}
83
+ steps:
84
+ - name: Force Install GIT latest
85
+ run: |
86
+ sudo apt-get update \
87
+ && sudo apt-get install -y software-properties-common \
88
+ && sudo apt-get update \
89
+ && sudo add-apt-repository -y ppa:git-core/ppa \
90
+ && sudo apt-get update \
91
+ && sudo apt-get install -y git
92
+ - name: Checkout
93
+ uses: actions/checkout@v4
94
+
95
+ - name: Release space from worker
96
+ if: inputs.runs-on == 'ubuntu-latest'
97
+ run: |
98
+ echo "Listing top largest packages"
99
+ pkgs=$(dpkg-query -Wf '${Installed-Size}\t${Package}\t${Status}\n' | awk '$NF == "installed"{print $1 "\t" $2}' | sort -nr)
100
+ head -n 30 <<< "${pkgs}"
101
+ echo
102
+ df -h
103
+ echo
104
+ sudo apt-get remove -y '^llvm-.*|^libllvm.*' || true
105
+ sudo apt-get remove --auto-remove android-sdk-platform-tools || true
106
+ sudo apt-get purge --auto-remove android-sdk-platform-tools || true
107
+ sudo rm -rf /usr/local/lib/android
108
+ sudo apt-get remove -y '^dotnet-.*|^aspnetcore-.*' || true
109
+ sudo rm -rf /usr/share/dotnet
110
+ sudo apt-get remove -y '^mono-.*' || true
111
+ sudo apt-get remove -y '^ghc-.*' || true
112
+ sudo apt-get remove -y '.*jdk.*|.*jre.*' || true
113
+ sudo apt-get remove -y 'php.*' || true
114
+ sudo apt-get remove -y hhvm powershell firefox monodoc-manual msbuild || true
115
+ sudo apt-get remove -y '^google-.*' || true
116
+ sudo apt-get remove -y azure-cli || true
117
+ sudo apt-get remove -y '^mongo.*-.*|^postgresql-.*|^mysql-.*|^mssql-.*' || true
118
+ sudo apt-get remove -y '^gfortran-.*' || true
119
+ sudo apt-get remove -y microsoft-edge-stable || true
120
+ sudo apt-get remove -y firefox || true
121
+ sudo apt-get remove -y powershell || true
122
+ sudo apt-get remove -y r-base-core || true
123
+ sudo apt-get autoremove -y
124
+ sudo apt-get clean
125
+ echo
126
+ echo "Listing top largest packages"
127
+ pkgs=$(dpkg-query -Wf '${Installed-Size}\t${Package}\t${Status}\n' | awk '$NF == "installed"{print $1 "\t" $2}' | sort -nr)
128
+ head -n 30 <<< "${pkgs}"
129
+ echo
130
+ sudo rm -rfv build || true
131
+ sudo rm -rf /usr/share/dotnet || true
132
+ sudo rm -rf /opt/ghc || true
133
+ sudo rm -rf "/usr/local/share/boost" || true
134
+ sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true
135
+ df -h
136
+
137
+ - name: Docker meta
138
+ id: meta
139
+ if: github.event_name != 'pull_request'
140
+ uses: docker/metadata-action@v5
141
+ with:
142
+ images: |
143
+ quay.io/go-skynet/local-ai
144
+ localai/localai
145
+ tags: |
146
+ type=ref,event=branch
147
+ type=semver,pattern={{raw}}
148
+ type=sha
149
+ flavor: |
150
+ latest=${{ inputs.tag-latest }}
151
+ suffix=${{ inputs.tag-suffix }}
152
+ - name: Docker meta for PR
153
+ id: meta_pull_request
154
+ if: github.event_name == 'pull_request'
155
+ uses: docker/metadata-action@v5
156
+ with:
157
+ images: |
158
+ ttl.sh/localai-ci-pr-${{ github.event.number }}
159
+ tags: |
160
+ type=ref,event=branch
161
+ type=semver,pattern={{raw}}
162
+ type=sha
163
+ flavor: |
164
+ latest=${{ inputs.tag-latest }}
165
+ suffix=${{ inputs.tag-suffix }}
166
+ - name: Docker meta AIO (quay.io)
167
+ if: inputs.aio != ''
168
+ id: meta_aio
169
+ uses: docker/metadata-action@v5
170
+ with:
171
+ images: |
172
+ quay.io/go-skynet/local-ai
173
+ tags: |
174
+ type=ref,event=branch
175
+ type=semver,pattern={{raw}}
176
+ flavor: |
177
+ latest=${{ inputs.tag-latest }}
178
+ suffix=${{ inputs.aio }}
179
+
180
+ - name: Docker meta AIO (dockerhub)
181
+ if: inputs.aio != ''
182
+ id: meta_aio_dockerhub
183
+ uses: docker/metadata-action@v5
184
+ with:
185
+ images: |
186
+ localai/localai
187
+ tags: |
188
+ type=ref,event=branch
189
+ type=semver,pattern={{raw}}
190
+ flavor: |
191
+ suffix=${{ inputs.aio }}
192
+
193
+ - name: Set up QEMU
194
+ uses: docker/setup-qemu-action@master
195
+ with:
196
+ platforms: all
197
+
198
+ - name: Set up Docker Buildx
199
+ id: buildx
200
+ uses: docker/setup-buildx-action@master
201
+
202
+ - name: Login to DockerHub
203
+ if: github.event_name != 'pull_request'
204
+ uses: docker/login-action@v3
205
+ with:
206
+ username: ${{ secrets.dockerUsername }}
207
+ password: ${{ secrets.dockerPassword }}
208
+
209
+ - name: Login to DockerHub
210
+ if: github.event_name != 'pull_request'
211
+ uses: docker/login-action@v3
212
+ with:
213
+ registry: quay.io
214
+ username: ${{ secrets.quayUsername }}
215
+ password: ${{ secrets.quayPassword }}
216
+
217
+ - name: Build and push
218
+ uses: docker/build-push-action@v6
219
+ if: github.event_name != 'pull_request'
220
+ with:
221
+ builder: ${{ steps.buildx.outputs.name }}
222
+ # The build-args MUST be an EXACT match between the image cache and other workflow steps that want to use that cache.
223
+ # This means that even the MAKEFLAGS have to be an EXACT match.
224
+ # If the build-args are not an EXACT match, it will result in a cache miss, which will require GRPC to be built from scratch.
225
+ # This is why some build args like GRPC_VERSION and MAKEFLAGS are hardcoded
226
+ build-args: |
227
+ BUILD_TYPE=${{ inputs.build-type }}
228
+ CUDA_MAJOR_VERSION=${{ inputs.cuda-major-version }}
229
+ CUDA_MINOR_VERSION=${{ inputs.cuda-minor-version }}
230
+ FFMPEG=${{ inputs.ffmpeg }}
231
+ IMAGE_TYPE=${{ inputs.image-type }}
232
+ BASE_IMAGE=${{ inputs.base-image }}
233
+ GRPC_BASE_IMAGE=${{ inputs.grpc-base-image || inputs.base-image }}
234
+ GRPC_MAKEFLAGS=--jobs=4 --output-sync=target
235
+ GRPC_VERSION=v1.65.0
236
+ MAKEFLAGS=${{ inputs.makeflags }}
237
+ context: .
238
+ file: ./Dockerfile
239
+ cache-from: type=gha
240
+ platforms: ${{ inputs.platforms }}
241
+ push: ${{ github.event_name != 'pull_request' }}
242
+ tags: ${{ steps.meta.outputs.tags }}
243
+ labels: ${{ steps.meta.outputs.labels }}
244
+ ### Start testing image
245
+ - name: Build and push
246
+ uses: docker/build-push-action@v6
247
+ if: github.event_name == 'pull_request'
248
+ with:
249
+ builder: ${{ steps.buildx.outputs.name }}
250
+ # The build-args MUST be an EXACT match between the image cache and other workflow steps that want to use that cache.
251
+ # This means that even the MAKEFLAGS have to be an EXACT match.
252
+ # If the build-args are not an EXACT match, it will result in a cache miss, which will require GRPC to be built from scratch.
253
+ # This is why some build args like GRPC_VERSION and MAKEFLAGS are hardcoded
254
+ build-args: |
255
+ BUILD_TYPE=${{ inputs.build-type }}
256
+ CUDA_MAJOR_VERSION=${{ inputs.cuda-major-version }}
257
+ CUDA_MINOR_VERSION=${{ inputs.cuda-minor-version }}
258
+ FFMPEG=${{ inputs.ffmpeg }}
259
+ IMAGE_TYPE=${{ inputs.image-type }}
260
+ BASE_IMAGE=${{ inputs.base-image }}
261
+ GRPC_BASE_IMAGE=${{ inputs.grpc-base-image || inputs.base-image }}
262
+ GRPC_MAKEFLAGS=--jobs=4 --output-sync=target
263
+ GRPC_VERSION=v1.65.0
264
+ MAKEFLAGS=${{ inputs.makeflags }}
265
+ context: .
266
+ file: ./Dockerfile
267
+ cache-from: type=gha
268
+ platforms: ${{ inputs.platforms }}
269
+ push: true
270
+ tags: ${{ steps.meta_pull_request.outputs.tags }}
271
+ labels: ${{ steps.meta_pull_request.outputs.labels }}
272
+ - name: Testing image
273
+ if: github.event_name == 'pull_request'
274
+ run: |
275
+ echo "Image is available at ttl.sh/localai-ci-pr-${{ github.event.number }}:${{ steps.meta_pull_request.outputs.version }}" >> $GITHUB_STEP_SUMMARY
276
+ ## End testing image
277
+ - name: Build and push AIO image
278
+ if: inputs.aio != ''
279
+ uses: docker/build-push-action@v6
280
+ with:
281
+ builder: ${{ steps.buildx.outputs.name }}
282
+ build-args: |
283
+ BASE_IMAGE=quay.io/go-skynet/local-ai:${{ steps.meta.outputs.version }}
284
+ MAKEFLAGS=${{ inputs.makeflags }}
285
+ context: .
286
+ file: ./Dockerfile.aio
287
+ platforms: ${{ inputs.platforms }}
288
+ push: ${{ github.event_name != 'pull_request' }}
289
+ tags: ${{ steps.meta_aio.outputs.tags }}
290
+ labels: ${{ steps.meta_aio.outputs.labels }}
291
+
292
+ - name: Build and push AIO image (dockerhub)
293
+ if: inputs.aio != ''
294
+ uses: docker/build-push-action@v6
295
+ with:
296
+ builder: ${{ steps.buildx.outputs.name }}
297
+ build-args: |
298
+ BASE_IMAGE=localai/localai:${{ steps.meta.outputs.version }}
299
+ MAKEFLAGS=${{ inputs.makeflags }}
300
+ context: .
301
+ file: ./Dockerfile.aio
302
+ platforms: ${{ inputs.platforms }}
303
+ push: ${{ github.event_name != 'pull_request' }}
304
+ tags: ${{ steps.meta_aio_dockerhub.outputs.tags }}
305
+ labels: ${{ steps.meta_aio_dockerhub.outputs.labels }}
306
+
307
+ - name: Latest tag
308
+ # run this on branches, when it is a tag and there is a latest-image defined
309
+ if: github.event_name != 'pull_request' && inputs.latest-image != '' && github.ref_type == 'tag'
310
+ run: |
311
+ docker pull localai/localai:${{ steps.meta.outputs.version }}
312
+ docker tag localai/localai:${{ steps.meta.outputs.version }} localai/localai:${{ inputs.latest-image }}
313
+ docker push localai/localai:${{ inputs.latest-image }}
314
+ docker pull quay.io/go-skynet/local-ai:${{ steps.meta.outputs.version }}
315
+ docker tag quay.io/go-skynet/local-ai:${{ steps.meta.outputs.version }} quay.io/go-skynet/local-ai:${{ inputs.latest-image }}
316
+ docker push quay.io/go-skynet/local-ai:${{ inputs.latest-image }}
317
+ - name: Latest AIO tag
318
+ # run this on branches, when it is a tag and there is a latest-image defined
319
+ if: github.event_name != 'pull_request' && inputs.latest-image-aio != '' && github.ref_type == 'tag'
320
+ run: |
321
+ docker pull localai/localai:${{ steps.meta_aio_dockerhub.outputs.version }}
322
+ docker tag localai/localai:${{ steps.meta_aio_dockerhub.outputs.version }} localai/localai:${{ inputs.latest-image-aio }}
323
+ docker push localai/localai:${{ inputs.latest-image-aio }}
324
+ docker pull quay.io/go-skynet/local-ai:${{ steps.meta_aio.outputs.version }}
325
+ docker tag quay.io/go-skynet/local-ai:${{ steps.meta_aio.outputs.version }} quay.io/go-skynet/local-ai:${{ inputs.latest-image-aio }}
326
+ docker push quay.io/go-skynet/local-ai:${{ inputs.latest-image-aio }}
327
+
328
+ - name: job summary
329
+ run: |
330
+ echo "Built image: ${{ steps.meta.outputs.labels }}" >> $GITHUB_STEP_SUMMARY
331
+
332
+ - name: job summary(AIO)
333
+ if: inputs.aio != ''
334
+ run: |
335
+ echo "Built image: ${{ steps.meta_aio.outputs.labels }}" >> $GITHUB_STEP_SUMMARY
.github/workflows/labeler.yml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: "Pull Request Labeler"
2
+ on:
3
+ - pull_request_target
4
+
5
+ jobs:
6
+ labeler:
7
+ permissions:
8
+ contents: read
9
+ pull-requests: write
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/labeler@v5
.github/workflows/localaibot_automerge.yml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: LocalAI-bot auto-merge
2
+ on:
3
+ - pull_request_target
4
+
5
+ permissions:
6
+ contents: write
7
+ pull-requests: write
8
+ packages: read
9
+
10
+ jobs:
11
+ dependabot:
12
+ runs-on: ubuntu-latest
13
+ if: ${{ github.actor == 'localai-bot' }}
14
+ steps:
15
+ - name: Checkout repository
16
+ uses: actions/checkout@v4
17
+
18
+ - name: Approve a PR if not already approved
19
+ run: |
20
+ gh pr checkout "$PR_URL"
21
+ if [ "$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" != "APPROVED" ];
22
+ then
23
+ gh pr review --approve "$PR_URL"
24
+ else
25
+ echo "PR already approved.";
26
+ fi
27
+ env:
28
+ PR_URL: ${{github.event.pull_request.html_url}}
29
+ GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
30
+
31
+ - name: Enable auto-merge for LocalAIBot PRs
32
+ run: gh pr merge --auto --squash "$PR_URL"
33
+ env:
34
+ PR_URL: ${{github.event.pull_request.html_url}}
35
+ GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
.github/workflows/notify-models.yaml ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Notifications for new models
2
+ on:
3
+ pull_request:
4
+ types:
5
+ - closed
6
+
7
+ jobs:
8
+ notify-discord:
9
+ if: ${{ (github.event.pull_request.merged == true) && (contains(github.event.pull_request.labels.*.name, 'area/ai-model')) }}
10
+ env:
11
+ MODEL_NAME: hermes-2-theta-llama-3-8b
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ with:
16
+ fetch-depth: 0 # needed to checkout all branches for this Action to work
17
+ - uses: mudler/localai-github-action@v1
18
+ with:
19
+ model: 'hermes-2-theta-llama-3-8b' # Any from models.localai.io, or from huggingface.com with: "huggingface://<repository>/file"
20
+ # Check the PR diff using the current branch and the base branch of the PR
21
+ - uses: GrantBirki/[email protected]
22
+ id: git-diff-action
23
+ with:
24
+ json_diff_file_output: diff.json
25
+ raw_diff_file_output: diff.txt
26
+ file_output_only: "true"
27
+ - name: Summarize
28
+ env:
29
+ DIFF: ${{ steps.git-diff-action.outputs.raw-diff-path }}
30
+ id: summarize
31
+ run: |
32
+ input="$(cat $DIFF)"
33
+
34
+ # Define the LocalAI API endpoint
35
+ API_URL="http://localhost:8080/chat/completions"
36
+
37
+ # Create a JSON payload using jq to handle special characters
38
+ json_payload=$(jq -n --arg input "$input" '{
39
+ model: "'$MODEL_NAME'",
40
+ messages: [
41
+ {
42
+ role: "system",
43
+ content: "You are LocalAI-bot. Write a discord message to notify everyone about the new model from the git diff. Make it informal. An example can include: the URL of the model, the name, and a brief description of the model if exists. Also add an hint on how to install it in LocalAI and that can be browsed over https://models.localai.io. For example: local-ai run model_name_here"
44
+ },
45
+ {
46
+ role: "user",
47
+ content: $input
48
+ }
49
+ ]
50
+ }')
51
+
52
+ # Send the request to LocalAI
53
+ response=$(curl -s -X POST $API_URL \
54
+ -H "Content-Type: application/json" \
55
+ -d "$json_payload")
56
+
57
+ # Extract the summary from the response
58
+ summary="$(echo $response | jq -r '.choices[0].message.content')"
59
+
60
+ # Print the summary
61
+ # -H "Authorization: Bearer $API_KEY" \
62
+ echo "Summary:"
63
+ echo "$summary"
64
+ echo "payload sent"
65
+ echo "$json_payload"
66
+ {
67
+ echo 'message<<EOF'
68
+ echo "$summary"
69
+ echo EOF
70
+ } >> "$GITHUB_OUTPUT"
71
+ docker logs --tail 10 local-ai
72
+ - name: Discord notification
73
+ env:
74
+ DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
75
+ DISCORD_USERNAME: "LocalAI-Bot"
76
+ DISCORD_AVATAR: "https://avatars.githubusercontent.com/u/139863280?v=4"
77
+ uses: Ilshidur/action-discord@master
78
+ with:
79
+ args: ${{ steps.summarize.outputs.message }}
80
+ - name: Setup tmate session if fails
81
+ if: ${{ failure() }}
82
+ uses: mxschmitt/[email protected]
83
+ with:
84
+ detached: true
85
+ connect-timeout-seconds: 180
86
+ limit-access-to-actor: true
87
+ notify-twitter:
88
+ if: ${{ (github.event.pull_request.merged == true) && (contains(github.event.pull_request.labels.*.name, 'area/ai-model')) }}
89
+ env:
90
+ MODEL_NAME: hermes-2-theta-llama-3-8b
91
+ runs-on: ubuntu-latest
92
+ steps:
93
+ - uses: actions/checkout@v4
94
+ with:
95
+ fetch-depth: 0 # needed to checkout all branches for this Action to work
96
+ - name: Start LocalAI
97
+ run: |
98
+ echo "Starting LocalAI..."
99
+ docker run -e -ti -d --name local-ai -p 8080:8080 localai/localai:master-ffmpeg-core run --debug $MODEL_NAME
100
+ until [ "`docker inspect -f {{.State.Health.Status}} local-ai`" == "healthy" ]; do echo "Waiting for container to be ready"; docker logs --tail 10 local-ai; sleep 2; done
101
+ # Check the PR diff using the current branch and the base branch of the PR
102
+ - uses: GrantBirki/[email protected]
103
+ id: git-diff-action
104
+ with:
105
+ json_diff_file_output: diff.json
106
+ raw_diff_file_output: diff.txt
107
+ file_output_only: "true"
108
+ - name: Summarize
109
+ env:
110
+ DIFF: ${{ steps.git-diff-action.outputs.raw-diff-path }}
111
+ id: summarize
112
+ run: |
113
+ input="$(cat $DIFF)"
114
+
115
+ # Define the LocalAI API endpoint
116
+ API_URL="http://localhost:8080/chat/completions"
117
+
118
+ # Create a JSON payload using jq to handle special characters
119
+ json_payload=$(jq -n --arg input "$input" '{
120
+ model: "'$MODEL_NAME'",
121
+ messages: [
122
+ {
123
+ role: "system",
124
+ content: "You are LocalAI-bot. Write a twitter message to notify everyone about the new model from the git diff. Make it informal and really short. An example can include: the name, and a brief description of the model if exists. Also add an hint on how to install it in LocalAI. For example: local-ai run model_name_here"
125
+ },
126
+ {
127
+ role: "user",
128
+ content: $input
129
+ }
130
+ ]
131
+ }')
132
+
133
+ # Send the request to LocalAI
134
+ response=$(curl -s -X POST $API_URL \
135
+ -H "Content-Type: application/json" \
136
+ -d "$json_payload")
137
+
138
+ # Extract the summary from the response
139
+ summary="$(echo $response | jq -r '.choices[0].message.content')"
140
+
141
+ # Print the summary
142
+ # -H "Authorization: Bearer $API_KEY" \
143
+ echo "Summary:"
144
+ echo "$summary"
145
+ echo "payload sent"
146
+ echo "$json_payload"
147
+ {
148
+ echo 'message<<EOF'
149
+ echo "$summary"
150
+ echo EOF
151
+ } >> "$GITHUB_OUTPUT"
152
+ docker logs --tail 10 local-ai
153
+ - uses: Eomm/why-don-t-you-tweet@v2
154
+ with:
155
+ tweet-message: ${{ steps.summarize.outputs.message }}
156
+ env:
157
+ # Get your tokens from https://developer.twitter.com/apps
158
+ TWITTER_CONSUMER_API_KEY: ${{ secrets.TWITTER_APP_KEY }}
159
+ TWITTER_CONSUMER_API_SECRET: ${{ secrets.TWITTER_APP_SECRET }}
160
+ TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
161
+ TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
162
+ - name: Setup tmate session if fails
163
+ if: ${{ failure() }}
164
+ uses: mxschmitt/[email protected]
165
+ with:
166
+ detached: true
167
+ connect-timeout-seconds: 180
168
+ limit-access-to-actor: true
.github/workflows/notify-releases.yaml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Release notifications
2
+ on:
3
+ release:
4
+ types:
5
+ - published
6
+
7
+ jobs:
8
+ notify-discord:
9
+ runs-on: ubuntu-latest
10
+ env:
11
+ RELEASE_BODY: ${{ github.event.release.body }}
12
+ RELEASE_TITLE: ${{ github.event.release.name }}
13
+ RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
14
+ steps:
15
+ - uses: mudler/localai-github-action@v1
16
+ with:
17
+ model: 'hermes-2-theta-llama-3-8b' # Any from models.localai.io, or from huggingface.com with: "huggingface://<repository>/file"
18
+ - name: Summarize
19
+ id: summarize
20
+ run: |
21
+ input="$RELEASE_TITLE\b$RELEASE_BODY"
22
+
23
+ # Define the LocalAI API endpoint
24
+ API_URL="http://localhost:8080/chat/completions"
25
+
26
+ # Create a JSON payload using jq to handle special characters
27
+ json_payload=$(jq -n --arg input "$input" '{
28
+ model: "'$MODEL_NAME'",
29
+ messages: [
30
+ {
31
+ role: "system",
32
+ content: "Write a discord message with a bullet point summary of the release notes."
33
+ },
34
+ {
35
+ role: "user",
36
+ content: $input
37
+ }
38
+ ]
39
+ }')
40
+
41
+ # Send the request to LocalAI API
42
+ response=$(curl -s -X POST $API_URL \
43
+ -H "Content-Type: application/json" \
44
+ -d "$json_payload")
45
+
46
+ # Extract the summary from the response
47
+ summary=$(echo $response | jq -r '.choices[0].message.content')
48
+
49
+ # Print the summary
50
+ # -H "Authorization: Bearer $API_KEY" \
51
+ {
52
+ echo 'message<<EOF'
53
+ echo "$summary"
54
+ echo EOF
55
+ } >> "$GITHUB_OUTPUT"
56
+ - name: Discord notification
57
+ env:
58
+ DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL_RELEASE }}
59
+ DISCORD_USERNAME: "LocalAI-Bot"
60
+ DISCORD_AVATAR: "https://avatars.githubusercontent.com/u/139863280?v=4"
61
+ uses: Ilshidur/action-discord@master
62
+ with:
63
+ args: ${{ steps.summarize.outputs.message }}
.github/workflows/prlint.yaml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Check PR style
2
+
3
+ on:
4
+ pull_request_target:
5
+ types:
6
+ - opened
7
+ - reopened
8
+ - edited
9
+ - synchronize
10
+
11
+ jobs:
12
+ title-lint:
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ statuses: write
16
+ steps:
17
+ - uses: aslafy-z/conventional-pr-title-action@v3
18
+ env:
19
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20
+ # check-pr-description:
21
+ # runs-on: ubuntu-latest
22
+ # steps:
23
+ # - uses: actions/checkout@v2
24
+ # - uses: jadrol/[email protected]
25
+ # id: description-checker
26
+ # with:
27
+ # repo-token: ${{ secrets.GITHUB_TOKEN }}
28
+ # exempt-labels: no qa
.github/workflows/release.yaml ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Build and Release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ tags:
8
+ - 'v*'
9
+ pull_request:
10
+
11
+ env:
12
+ GRPC_VERSION: v1.65.0
13
+
14
+ permissions:
15
+ contents: write
16
+
17
+ concurrency:
18
+ group: ci-releases-${{ github.head_ref || github.ref }}-${{ github.repository }}
19
+ cancel-in-progress: true
20
+
21
+ jobs:
22
+
23
+ build-linux-arm:
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - name: Clone
27
+ uses: actions/checkout@v4
28
+ with:
29
+ submodules: true
30
+ - uses: actions/setup-go@v5
31
+ with:
32
+ go-version: '1.21.x'
33
+ cache: false
34
+ - name: Dependencies
35
+ run: |
36
+ sudo apt-get update
37
+ sudo apt-get install build-essential ffmpeg protobuf-compiler ccache upx-ucl gawk
38
+ sudo apt-get install -qy binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libgmock-dev
39
+ - name: Install CUDA Dependencies
40
+ run: |
41
+ curl -O https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/cross-linux-aarch64/cuda-keyring_1.1-1_all.deb
42
+ sudo dpkg -i cuda-keyring_1.1-1_all.deb
43
+ sudo apt-get update
44
+ sudo apt-get install -y cuda-cross-aarch64 cuda-nvcc-cross-aarch64-${CUDA_VERSION} libcublas-cross-aarch64-${CUDA_VERSION}
45
+ env:
46
+ CUDA_VERSION: 12-4
47
+ - name: Cache grpc
48
+ id: cache-grpc
49
+ uses: actions/cache@v4
50
+ with:
51
+ path: grpc
52
+ key: ${{ runner.os }}-arm-grpc-${{ env.GRPC_VERSION }}
53
+ - name: Build grpc
54
+ if: steps.cache-grpc.outputs.cache-hit != 'true'
55
+ run: |
56
+
57
+ git clone --recurse-submodules -b ${{ env.GRPC_VERSION }} --depth 1 --shallow-submodules https://github.com/grpc/grpc && \
58
+ cd grpc && sed -i "216i\ TESTONLY" "third_party/abseil-cpp/absl/container/CMakeLists.txt" && mkdir -p cmake/build && \
59
+ cd cmake/build && cmake -DgRPC_INSTALL=ON \
60
+ -DgRPC_BUILD_TESTS=OFF \
61
+ ../.. && sudo make --jobs 5 --output-sync=target
62
+ - name: Install gRPC
63
+ run: |
64
+ GNU_HOST=aarch64-linux-gnu
65
+ C_COMPILER_ARM_LINUX=$GNU_HOST-gcc
66
+ CXX_COMPILER_ARM_LINUX=$GNU_HOST-g++
67
+
68
+ CROSS_TOOLCHAIN=/usr/$GNU_HOST
69
+ CROSS_STAGING_PREFIX=$CROSS_TOOLCHAIN/stage
70
+ CMAKE_CROSS_TOOLCHAIN=/tmp/arm.toolchain.cmake
71
+
72
+ # https://cmake.org/cmake/help/v3.13/manual/cmake-toolchains.7.html#cross-compiling-for-linux
73
+ echo "set(CMAKE_SYSTEM_NAME Linux)" >> $CMAKE_CROSS_TOOLCHAIN && \
74
+ echo "set(CMAKE_SYSTEM_PROCESSOR arm)" >> $CMAKE_CROSS_TOOLCHAIN && \
75
+ echo "set(CMAKE_STAGING_PREFIX $CROSS_STAGING_PREFIX)" >> $CMAKE_CROSS_TOOLCHAIN && \
76
+ echo "set(CMAKE_SYSROOT ${CROSS_TOOLCHAIN}/sysroot)" >> $CMAKE_CROSS_TOOLCHAIN && \
77
+ echo "set(CMAKE_C_COMPILER /usr/bin/$C_COMPILER_ARM_LINUX)" >> $CMAKE_CROSS_TOOLCHAIN && \
78
+ echo "set(CMAKE_CXX_COMPILER /usr/bin/$CXX_COMPILER_ARM_LINUX)" >> $CMAKE_CROSS_TOOLCHAIN && \
79
+ echo "set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)" >> $CMAKE_CROSS_TOOLCHAIN && \
80
+ echo "set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)" >> $CMAKE_CROSS_TOOLCHAIN && \
81
+ echo "set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)" >> $CMAKE_CROSS_TOOLCHAIN && \
82
+ echo "set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)" >> $CMAKE_CROSS_TOOLCHAIN
83
+ GRPC_DIR=$PWD/grpc
84
+ cd grpc && cd cmake/build && sudo make --jobs 5 --output-sync=target install && \
85
+ GRPC_CROSS_BUILD_DIR=$GRPC_DIR/cmake/cross_build && \
86
+ mkdir -p $GRPC_CROSS_BUILD_DIR && \
87
+ cd $GRPC_CROSS_BUILD_DIR && \
88
+ cmake -DCMAKE_TOOLCHAIN_FILE=$CMAKE_CROSS_TOOLCHAIN \
89
+ -DCMAKE_BUILD_TYPE=Release \
90
+ -DCMAKE_INSTALL_PREFIX=$CROSS_TOOLCHAIN/grpc_install \
91
+ ../.. && \
92
+ sudo make -j`nproc` install
93
+ - name: Build
94
+ id: build
95
+ run: |
96
+ GNU_HOST=aarch64-linux-gnu
97
+ C_COMPILER_ARM_LINUX=$GNU_HOST-gcc
98
+ CXX_COMPILER_ARM_LINUX=$GNU_HOST-g++
99
+
100
+ CROSS_TOOLCHAIN=/usr/$GNU_HOST
101
+ CROSS_STAGING_PREFIX=$CROSS_TOOLCHAIN/stage
102
+ CMAKE_CROSS_TOOLCHAIN=/tmp/arm.toolchain.cmake
103
+ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@1958fcbe2ca8bd93af633f11e97d44e567e945af
104
+ go install google.golang.org/protobuf/cmd/[email protected]
105
+ export PATH=$PATH:$GOPATH/bin
106
+ export PATH=/usr/local/cuda/bin:$PATH
107
+ sudo rm -rf /usr/aarch64-linux-gnu/lib/libstdc++.so.6
108
+ sudo cp -rf /usr/aarch64-linux-gnu/lib/libstdc++.so* /usr/aarch64-linux-gnu/lib/libstdc++.so.6
109
+ sudo cp /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 ld.so
110
+ BACKEND_LIBS="./grpc/cmake/cross_build/third_party/re2/libre2.a ./grpc/cmake/cross_build/libgrpc.a ./grpc/cmake/cross_build/libgrpc++.a ./grpc/cmake/cross_build/third_party/protobuf/libprotobuf.a /usr/aarch64-linux-gnu/lib/libc.so.6 /usr/aarch64-linux-gnu/lib/libstdc++.so.6 /usr/aarch64-linux-gnu/lib/libgomp.so.1 /usr/aarch64-linux-gnu/lib/libm.so.6 /usr/aarch64-linux-gnu/lib/libgcc_s.so.1 /usr/aarch64-linux-gnu/lib/libdl.so.2 /usr/aarch64-linux-gnu/lib/libpthread.so.0 ./ld.so" \
111
+ GOOS=linux \
112
+ GOARCH=arm64 \
113
+ CMAKE_ARGS="-DProtobuf_INCLUDE_DIRS=$CROSS_STAGING_PREFIX/include -DProtobuf_DIR=$CROSS_STAGING_PREFIX/lib/cmake/protobuf -DgRPC_DIR=$CROSS_STAGING_PREFIX/lib/cmake/grpc -DCMAKE_TOOLCHAIN_FILE=$CMAKE_CROSS_TOOLCHAIN -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++" make dist-cross-linux-arm64
114
+ - uses: actions/upload-artifact@v4
115
+ with:
116
+ name: LocalAI-linux-arm64
117
+ path: release/
118
+ - name: Release
119
+ uses: softprops/action-gh-release@v2
120
+ if: startsWith(github.ref, 'refs/tags/')
121
+ with:
122
+ files: |
123
+ release/*
124
+ - name: Setup tmate session if tests fail
125
+ if: ${{ failure() }}
126
+ uses: mxschmitt/[email protected]
127
+ with:
128
+ detached: true
129
+ connect-timeout-seconds: 180
130
+ limit-access-to-actor: true
131
+ build-linux:
132
+ runs-on: arc-runner-set
133
+ steps:
134
+ - name: Force Install GIT latest
135
+ run: |
136
+ sudo apt-get update \
137
+ && sudo apt-get install -y software-properties-common \
138
+ && sudo apt-get update \
139
+ && sudo add-apt-repository -y ppa:git-core/ppa \
140
+ && sudo apt-get update \
141
+ && sudo apt-get install -y git
142
+ - name: Clone
143
+ uses: actions/checkout@v4
144
+ with:
145
+ submodules: true
146
+ - uses: actions/setup-go@v5
147
+ with:
148
+ go-version: '1.21.x'
149
+ cache: false
150
+ - name: Dependencies
151
+ run: |
152
+ sudo apt-get update
153
+ sudo apt-get install -y wget curl build-essential ffmpeg protobuf-compiler ccache upx-ucl gawk cmake libgmock-dev
154
+ - name: Intel Dependencies
155
+ run: |
156
+ wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
157
+ echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
158
+ sudo apt update
159
+ sudo apt install -y intel-basekit
160
+ - name: Install CUDA Dependencies
161
+ run: |
162
+ curl -O https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
163
+ sudo dpkg -i cuda-keyring_1.1-1_all.deb
164
+ sudo apt-get update
165
+ sudo apt-get install -y cuda-nvcc-${CUDA_VERSION} libcublas-dev-${CUDA_VERSION}
166
+ env:
167
+ CUDA_VERSION: 12-5
168
+ - name: "Install Hipblas"
169
+ env:
170
+ ROCM_VERSION: "6.1"
171
+ AMDGPU_VERSION: "6.1"
172
+ run: |
173
+ set -ex
174
+
175
+ sudo apt-get update
176
+ sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl libnuma-dev gnupg
177
+
178
+ curl -sL https://repo.radeon.com/rocm/rocm.gpg.key | sudo apt-key add -
179
+
180
+ printf "deb [arch=amd64] https://repo.radeon.com/rocm/apt/$ROCM_VERSION/ jammy main" | sudo tee /etc/apt/sources.list.d/rocm.list
181
+
182
+ printf "deb [arch=amd64] https://repo.radeon.com/amdgpu/$AMDGPU_VERSION/ubuntu jammy main" | sudo tee /etc/apt/sources.list.d/amdgpu.list
183
+ printf 'Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600' | sudo tee /etc/apt/preferences.d/rocm-pin-600
184
+ sudo apt-get update
185
+
186
+ sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
187
+ hipblas-dev rocm-dev \
188
+ rocblas-dev
189
+
190
+ sudo apt-get clean
191
+ sudo rm -rf /var/lib/apt/lists/*
192
+ sudo ldconfig
193
+ - name: Cache grpc
194
+ id: cache-grpc
195
+ uses: actions/cache@v4
196
+ with:
197
+ path: grpc
198
+ key: ${{ runner.os }}-grpc-${{ env.GRPC_VERSION }}
199
+ - name: Build grpc
200
+ if: steps.cache-grpc.outputs.cache-hit != 'true'
201
+ run: |
202
+ git clone --recurse-submodules -b ${{ env.GRPC_VERSION }} --depth 1 --shallow-submodules https://github.com/grpc/grpc && \
203
+ cd grpc && sed -i "216i\ TESTONLY" "third_party/abseil-cpp/absl/container/CMakeLists.txt" && mkdir -p cmake/build && \
204
+ cd cmake/build && cmake -DgRPC_INSTALL=ON \
205
+ -DgRPC_BUILD_TESTS=OFF \
206
+ ../.. && sudo make --jobs 5 --output-sync=target
207
+ - name: Install gRPC
208
+ run: |
209
+ cd grpc && cd cmake/build && sudo make --jobs 5 --output-sync=target install
210
+ # BACKEND_LIBS needed for gpu-workload: /opt/intel/oneapi/*/lib/libiomp5.so /opt/intel/oneapi/*/lib/libmkl_core.so /opt/intel/oneapi/*/lib/libmkl_core.so.2 /opt/intel/oneapi/*/lib/libmkl_intel_ilp64.so /opt/intel/oneapi/*/lib/libmkl_intel_ilp64.so.2 /opt/intel/oneapi/*/lib/libmkl_sycl_blas.so /opt/intel/oneapi/*/lib/libmkl_sycl_blas.so.4 /opt/intel/oneapi/*/lib/libmkl_tbb_thread.so /opt/intel/oneapi/*/lib/libmkl_tbb_thread.so.2 /opt/intel/oneapi/*/lib/libsycl.so /opt/intel/oneapi/*/lib/libsycl.so.7 /opt/intel/oneapi/*/lib/libsycl.so.7.1.0 /opt/rocm-*/lib/libamdhip64.so /opt/rocm-*/lib/libamdhip64.so.5 /opt/rocm-*/lib/libamdhip64.so.6 /opt/rocm-*/lib/libamdhip64.so.6.1.60100 /opt/rocm-*/lib/libhipblas.so /opt/rocm-*/lib/libhipblas.so.2 /opt/rocm-*/lib/libhipblas.so.2.1.60100 /opt/rocm-*/lib/librocblas.so /opt/rocm-*/lib/librocblas.so.4 /opt/rocm-*/lib/librocblas.so.4.1.60100 /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/x86_64-linux-gnu/libOpenCL.so.1 /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0 /usr/lib/x86_64-linux-gnu/libm.so.6 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 /usr/lib/x86_64-linux-gnu/libc.so.6 /usr/lib/x86_64-linux-gnu/librt.so.1 /usr/local/cuda-*/targets/x86_64-linux/lib/libcublas.so /usr/local/cuda-*/targets/x86_64-linux/lib/libcublasLt.so /usr/local/cuda-*/targets/x86_64-linux/lib/libcudart.so /usr/local/cuda-*/targets/x86_64-linux/lib/stubs/libcuda.so
211
+ - name: Build
212
+ id: build
213
+ run: |
214
+ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@1958fcbe2ca8bd93af633f11e97d44e567e945af
215
+ go install google.golang.org/protobuf/cmd/[email protected]
216
+ export PATH=$PATH:$GOPATH/bin
217
+ export PATH=/usr/local/cuda/bin:$PATH
218
+ export PATH=/opt/rocm/bin:$PATH
219
+ source /opt/intel/oneapi/setvars.sh
220
+ sudo cp /lib64/ld-linux-x86-64.so.2 ld.so
221
+ BACKEND_LIBS="./ld.so ./sources/go-piper/piper/build/fi/lib/libfmt.a ./sources/go-piper/piper-phonemize/pi/lib/libonnxruntime.so.1.14.1 ./sources/go-piper/piper-phonemize/pi/src/libespeak-ng/libespeak-ng.so /usr/lib/x86_64-linux-gnu/libdl.so.2 /usr/lib/x86_64-linux-gnu/librt.so.1 /usr/lib/x86_64-linux-gnu/libpthread.so.0 ./sources/go-piper/piper-phonemize/pi/lib/libpiper_phonemize.so.1 ./sources/go-piper/piper/build/si/lib/libspdlog.a ./sources/go-piper/espeak/ei/lib/libucd.so" \
222
+ make -j4 dist
223
+ - uses: actions/upload-artifact@v4
224
+ with:
225
+ name: LocalAI-linux
226
+ path: release/
227
+ - name: Release
228
+ uses: softprops/action-gh-release@v2
229
+ if: startsWith(github.ref, 'refs/tags/')
230
+ with:
231
+ files: |
232
+ release/*
233
+ - name: Setup tmate session if tests fail
234
+ if: ${{ failure() }}
235
+ uses: mxschmitt/[email protected]
236
+ with:
237
+ detached: true
238
+ connect-timeout-seconds: 180
239
+ limit-access-to-actor: true
240
+ build-stablediffusion:
241
+ runs-on: ubuntu-latest
242
+ steps:
243
+ - name: Clone
244
+ uses: actions/checkout@v4
245
+ with:
246
+ submodules: true
247
+ - uses: actions/setup-go@v5
248
+ with:
249
+ go-version: '1.21.x'
250
+ cache: false
251
+ - name: Dependencies
252
+ run: |
253
+ sudo apt-get update
254
+ sudo apt-get install -y --no-install-recommends libopencv-dev protobuf-compiler ccache upx-ucl
255
+ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@1958fcbe2ca8bd93af633f11e97d44e567e945af
256
+ go install google.golang.org/protobuf/cmd/[email protected]
257
+ - name: Build stablediffusion
258
+ run: |
259
+ export PATH=$PATH:$GOPATH/bin
260
+ make backend-assets/grpc/stablediffusion
261
+ mkdir -p release && cp backend-assets/grpc/stablediffusion release
262
+ env:
263
+ GO_TAGS: stablediffusion
264
+ - uses: actions/upload-artifact@v4
265
+ with:
266
+ name: stablediffusion
267
+ path: release/
268
+ - name: Release
269
+ uses: softprops/action-gh-release@v2
270
+ if: startsWith(github.ref, 'refs/tags/')
271
+ with:
272
+ files: |
273
+ release/*
274
+
275
+ build-macOS-x86_64:
276
+ runs-on: macos-13
277
+ steps:
278
+ - name: Clone
279
+ uses: actions/checkout@v4
280
+ with:
281
+ submodules: true
282
+ - uses: actions/setup-go@v5
283
+ with:
284
+ go-version: '1.21.x'
285
+ cache: false
286
+ - name: Dependencies
287
+ run: |
288
+ brew install protobuf grpc
289
+ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@8ba23be9613c672d40ae261d2a1335d639bdd59b
290
+ go install google.golang.org/protobuf/cmd/[email protected]
291
+ - name: Build
292
+ id: build
293
+ run: |
294
+ export C_INCLUDE_PATH=/usr/local/include
295
+ export CPLUS_INCLUDE_PATH=/usr/local/include
296
+ export PATH=$PATH:$GOPATH/bin
297
+
298
+ make dist
299
+ - uses: actions/upload-artifact@v4
300
+ with:
301
+ name: LocalAI-MacOS-x86_64
302
+ path: release/
303
+ - name: Release
304
+ uses: softprops/action-gh-release@v2
305
+ if: startsWith(github.ref, 'refs/tags/')
306
+ with:
307
+ files: |
308
+ release/*
309
+ - name: Setup tmate session if tests fail
310
+ if: ${{ failure() }}
311
+ uses: mxschmitt/[email protected]
312
+ with:
313
+ detached: true
314
+ connect-timeout-seconds: 180
315
+ limit-access-to-actor: true
316
+
317
+ build-macOS-arm64:
318
+ runs-on: macos-14
319
+ steps:
320
+ - name: Clone
321
+ uses: actions/checkout@v4
322
+ with:
323
+ submodules: true
324
+ - uses: actions/setup-go@v5
325
+ with:
326
+ go-version: '1.21.x'
327
+ cache: false
328
+ - name: Dependencies
329
+ run: |
330
+ brew install protobuf grpc
331
+ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@1958fcbe2ca8bd93af633f11e97d44e567e945af
332
+ go install google.golang.org/protobuf/cmd/[email protected]
333
+ - name: Build
334
+ id: build
335
+ run: |
336
+ export C_INCLUDE_PATH=/usr/local/include
337
+ export CPLUS_INCLUDE_PATH=/usr/local/include
338
+ export PATH=$PATH:$GOPATH/bin
339
+
340
+ make dist
341
+ - uses: actions/upload-artifact@v4
342
+ with:
343
+ name: LocalAI-MacOS-arm64
344
+ path: release/
345
+ - name: Release
346
+ uses: softprops/action-gh-release@v2
347
+ if: startsWith(github.ref, 'refs/tags/')
348
+ with:
349
+ files: |
350
+ release/*
351
+ - name: Setup tmate session if tests fail
352
+ if: ${{ failure() }}
353
+ uses: mxschmitt/[email protected]
354
+ with:
355
+ detached: true
356
+ connect-timeout-seconds: 180
357
+ limit-access-to-actor: true
.github/workflows/secscan.yaml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: "Security Scan"
2
+
3
+ # Run workflow each time code is pushed to your repository and on a schedule.
4
+ # The scheduled workflow runs every at 00:00 on Sunday UTC time.
5
+ on:
6
+ push:
7
+ schedule:
8
+ - cron: '0 0 * * 0'
9
+
10
+ jobs:
11
+ tests:
12
+ runs-on: ubuntu-latest
13
+ env:
14
+ GO111MODULE: on
15
+ steps:
16
+ - name: Checkout Source
17
+ uses: actions/checkout@v4
18
+ if: ${{ github.actor != 'dependabot[bot]' }}
19
+ - name: Run Gosec Security Scanner
20
+ if: ${{ github.actor != 'dependabot[bot]' }}
21
+ uses: securego/gosec@master
22
+ with:
23
+ # we let the report trigger content trigger a failure using the GitHub Security features.
24
+ args: '-no-fail -fmt sarif -out results.sarif ./...'
25
+ - name: Upload SARIF file
26
+ if: ${{ github.actor != 'dependabot[bot]' }}
27
+ uses: github/codeql-action/upload-sarif@v3
28
+ with:
29
+ # Path to SARIF file relative to the root of the repository
30
+ sarif_file: results.sarif
.github/workflows/test-extra.yml ADDED
@@ -0,0 +1,321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: 'Tests extras backends'
3
+
4
+ on:
5
+ pull_request:
6
+ push:
7
+ branches:
8
+ - master
9
+ tags:
10
+ - '*'
11
+
12
+ concurrency:
13
+ group: ci-tests-extra-${{ github.head_ref || github.ref }}-${{ github.repository }}
14
+ cancel-in-progress: true
15
+
16
+ jobs:
17
+ tests-transformers:
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - name: Clone
21
+ uses: actions/checkout@v4
22
+ with:
23
+ submodules: true
24
+ - name: Dependencies
25
+ run: |
26
+ sudo apt-get update
27
+ sudo apt-get install build-essential ffmpeg
28
+ # Install UV
29
+ curl -LsSf https://astral.sh/uv/install.sh | sh
30
+ sudo apt-get install -y ca-certificates cmake curl patch python3-pip
31
+ sudo apt-get install -y libopencv-dev
32
+ pip install --user --no-cache-dir grpcio-tools==1.64.1
33
+
34
+ - name: Test transformers
35
+ run: |
36
+ make --jobs=5 --output-sync=target -C backend/python/transformers
37
+ make --jobs=5 --output-sync=target -C backend/python/transformers test
38
+
39
+ tests-sentencetransformers:
40
+ runs-on: ubuntu-latest
41
+ steps:
42
+ - name: Clone
43
+ uses: actions/checkout@v4
44
+ with:
45
+ submodules: true
46
+ - name: Dependencies
47
+ run: |
48
+ sudo apt-get update
49
+ sudo apt-get install build-essential ffmpeg
50
+ # Install UV
51
+ curl -LsSf https://astral.sh/uv/install.sh | sh
52
+ sudo apt-get install -y ca-certificates cmake curl patch python3-pip
53
+ sudo apt-get install -y libopencv-dev
54
+ pip install --user --no-cache-dir grpcio-tools==1.64.1
55
+
56
+ - name: Test sentencetransformers
57
+ run: |
58
+ make --jobs=5 --output-sync=target -C backend/python/sentencetransformers
59
+ make --jobs=5 --output-sync=target -C backend/python/sentencetransformers test
60
+
61
+
62
+ tests-rerankers:
63
+ runs-on: ubuntu-latest
64
+ steps:
65
+ - name: Clone
66
+ uses: actions/checkout@v4
67
+ with:
68
+ submodules: true
69
+ - name: Dependencies
70
+ run: |
71
+ sudo apt-get update
72
+ sudo apt-get install build-essential ffmpeg
73
+ # Install UV
74
+ curl -LsSf https://astral.sh/uv/install.sh | sh
75
+ sudo apt-get install -y ca-certificates cmake curl patch python3-pip
76
+ sudo apt-get install -y libopencv-dev
77
+ pip install --user --no-cache-dir grpcio-tools==1.64.1
78
+
79
+ - name: Test rerankers
80
+ run: |
81
+ make --jobs=5 --output-sync=target -C backend/python/rerankers
82
+ make --jobs=5 --output-sync=target -C backend/python/rerankers test
83
+
84
+ tests-diffusers:
85
+ runs-on: ubuntu-latest
86
+ steps:
87
+ - name: Clone
88
+ uses: actions/checkout@v4
89
+ with:
90
+ submodules: true
91
+ - name: Dependencies
92
+ run: |
93
+ sudo apt-get update
94
+ sudo apt-get install -y build-essential ffmpeg
95
+ sudo apt-get install -y ca-certificates cmake curl patch python3-pip
96
+ sudo apt-get install -y libopencv-dev
97
+ # Install UV
98
+ curl -LsSf https://astral.sh/uv/install.sh | sh
99
+ pip install --user --no-cache-dir grpcio-tools==1.64.1
100
+ - name: Test diffusers
101
+ run: |
102
+ make --jobs=5 --output-sync=target -C backend/python/diffusers
103
+ make --jobs=5 --output-sync=target -C backend/python/diffusers test
104
+
105
+ tests-parler-tts:
106
+ runs-on: ubuntu-latest
107
+ steps:
108
+ - name: Clone
109
+ uses: actions/checkout@v4
110
+ with:
111
+ submodules: true
112
+ - name: Dependencies
113
+ run: |
114
+ sudo apt-get update
115
+ sudo apt-get install build-essential ffmpeg
116
+ # Install UV
117
+ curl -LsSf https://astral.sh/uv/install.sh | sh
118
+ sudo apt-get install -y ca-certificates cmake curl patch python3-pip
119
+ sudo apt-get install -y libopencv-dev
120
+ pip install --user --no-cache-dir grpcio-tools==1.64.1
121
+
122
+ - name: Test parler-tts
123
+ run: |
124
+ make --jobs=5 --output-sync=target -C backend/python/parler-tts
125
+ make --jobs=5 --output-sync=target -C backend/python/parler-tts test
126
+
127
+ tests-openvoice:
128
+ runs-on: ubuntu-latest
129
+ steps:
130
+ - name: Clone
131
+ uses: actions/checkout@v4
132
+ with:
133
+ submodules: true
134
+ - name: Dependencies
135
+ run: |
136
+ sudo apt-get update
137
+ sudo apt-get install build-essential ffmpeg
138
+ # Install UV
139
+ curl -LsSf https://astral.sh/uv/install.sh | sh
140
+ sudo apt-get install -y ca-certificates cmake curl patch python3-pip
141
+ sudo apt-get install -y libopencv-dev
142
+ pip install --user --no-cache-dir grpcio-tools==1.64.1
143
+
144
+ - name: Test openvoice
145
+ run: |
146
+ make --jobs=5 --output-sync=target -C backend/python/openvoice
147
+ make --jobs=5 --output-sync=target -C backend/python/openvoice test
148
+
149
+ tests-transformers-musicgen:
150
+ runs-on: ubuntu-latest
151
+ steps:
152
+ - name: Clone
153
+ uses: actions/checkout@v4
154
+ with:
155
+ submodules: true
156
+ - name: Dependencies
157
+ run: |
158
+ sudo apt-get update
159
+ sudo apt-get install build-essential ffmpeg
160
+ # Install UV
161
+ curl -LsSf https://astral.sh/uv/install.sh | sh
162
+ sudo apt-get install -y ca-certificates cmake curl patch python3-pip
163
+ sudo apt-get install -y libopencv-dev
164
+ pip install --user --no-cache-dir grpcio-tools==1.64.1
165
+
166
+ - name: Test transformers-musicgen
167
+ run: |
168
+ make --jobs=5 --output-sync=target -C backend/python/transformers-musicgen
169
+ make --jobs=5 --output-sync=target -C backend/python/transformers-musicgen test
170
+
171
+
172
+
173
+ # tests-petals:
174
+ # runs-on: ubuntu-latest
175
+ # steps:
176
+ # - name: Clone
177
+ # uses: actions/checkout@v4
178
+ # with:
179
+ # submodules: true
180
+ # - name: Dependencies
181
+ # run: |
182
+ # sudo apt-get update
183
+ # sudo apt-get install build-essential ffmpeg
184
+ # # Install UV
185
+ # curl -LsSf https://astral.sh/uv/install.sh | sh
186
+ # sudo apt-get install -y ca-certificates cmake curl patch python3-pip
187
+ # sudo apt-get install -y libopencv-dev
188
+ # pip install --user --no-cache-dir grpcio-tools==1.64.1
189
+
190
+ # - name: Test petals
191
+ # run: |
192
+ # make --jobs=5 --output-sync=target -C backend/python/petals
193
+ # make --jobs=5 --output-sync=target -C backend/python/petals test
194
+
195
+
196
+
197
+ # tests-bark:
198
+ # runs-on: ubuntu-latest
199
+ # steps:
200
+ # - name: Release space from worker
201
+ # run: |
202
+ # echo "Listing top largest packages"
203
+ # pkgs=$(dpkg-query -Wf '${Installed-Size}\t${Package}\t${Status}\n' | awk '$NF == "installed"{print $1 "\t" $2}' | sort -nr)
204
+ # head -n 30 <<< "${pkgs}"
205
+ # echo
206
+ # df -h
207
+ # echo
208
+ # sudo apt-get remove -y '^llvm-.*|^libllvm.*' || true
209
+ # sudo apt-get remove --auto-remove android-sdk-platform-tools || true
210
+ # sudo apt-get purge --auto-remove android-sdk-platform-tools || true
211
+ # sudo rm -rf /usr/local/lib/android
212
+ # sudo apt-get remove -y '^dotnet-.*|^aspnetcore-.*' || true
213
+ # sudo rm -rf /usr/share/dotnet
214
+ # sudo apt-get remove -y '^mono-.*' || true
215
+ # sudo apt-get remove -y '^ghc-.*' || true
216
+ # sudo apt-get remove -y '.*jdk.*|.*jre.*' || true
217
+ # sudo apt-get remove -y 'php.*' || true
218
+ # sudo apt-get remove -y hhvm powershell firefox monodoc-manual msbuild || true
219
+ # sudo apt-get remove -y '^google-.*' || true
220
+ # sudo apt-get remove -y azure-cli || true
221
+ # sudo apt-get remove -y '^mongo.*-.*|^postgresql-.*|^mysql-.*|^mssql-.*' || true
222
+ # sudo apt-get remove -y '^gfortran-.*' || true
223
+ # sudo apt-get remove -y microsoft-edge-stable || true
224
+ # sudo apt-get remove -y firefox || true
225
+ # sudo apt-get remove -y powershell || true
226
+ # sudo apt-get remove -y r-base-core || true
227
+ # sudo apt-get autoremove -y
228
+ # sudo apt-get clean
229
+ # echo
230
+ # echo "Listing top largest packages"
231
+ # pkgs=$(dpkg-query -Wf '${Installed-Size}\t${Package}\t${Status}\n' | awk '$NF == "installed"{print $1 "\t" $2}' | sort -nr)
232
+ # head -n 30 <<< "${pkgs}"
233
+ # echo
234
+ # sudo rm -rfv build || true
235
+ # sudo rm -rf /usr/share/dotnet || true
236
+ # sudo rm -rf /opt/ghc || true
237
+ # sudo rm -rf "/usr/local/share/boost" || true
238
+ # sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true
239
+ # df -h
240
+ # - name: Clone
241
+ # uses: actions/checkout@v4
242
+ # with:
243
+ # submodules: true
244
+ # - name: Dependencies
245
+ # run: |
246
+ # sudo apt-get update
247
+ # sudo apt-get install build-essential ffmpeg
248
+ # # Install UV
249
+ # curl -LsSf https://astral.sh/uv/install.sh | sh
250
+ # sudo apt-get install -y ca-certificates cmake curl patch python3-pip
251
+ # sudo apt-get install -y libopencv-dev
252
+ # pip install --user --no-cache-dir grpcio-tools==1.64.1
253
+
254
+ # - name: Test bark
255
+ # run: |
256
+ # make --jobs=5 --output-sync=target -C backend/python/bark
257
+ # make --jobs=5 --output-sync=target -C backend/python/bark test
258
+
259
+
260
+ # Below tests needs GPU. Commented out for now
261
+ # TODO: Re-enable as soon as we have GPU nodes
262
+ # tests-vllm:
263
+ # runs-on: ubuntu-latest
264
+ # steps:
265
+ # - name: Clone
266
+ # uses: actions/checkout@v4
267
+ # with:
268
+ # submodules: true
269
+ # - name: Dependencies
270
+ # run: |
271
+ # sudo apt-get update
272
+ # sudo apt-get install build-essential ffmpeg
273
+ # # Install UV
274
+ # curl -LsSf https://astral.sh/uv/install.sh | sh
275
+ # sudo apt-get install -y ca-certificates cmake curl patch python3-pip
276
+ # sudo apt-get install -y libopencv-dev
277
+ # pip install --user --no-cache-dir grpcio-tools==1.64.1
278
+ # - name: Test vllm
279
+ # run: |
280
+ # make --jobs=5 --output-sync=target -C backend/python/vllm
281
+ # make --jobs=5 --output-sync=target -C backend/python/vllm test
282
+ tests-vallex:
283
+ runs-on: ubuntu-latest
284
+ steps:
285
+ - name: Clone
286
+ uses: actions/checkout@v4
287
+ with:
288
+ submodules: true
289
+ - name: Dependencies
290
+ run: |
291
+ sudo apt-get update
292
+ sudo apt-get install build-essential ffmpeg
293
+ # Install UV
294
+ curl -LsSf https://astral.sh/uv/install.sh | sh
295
+ sudo apt-get install -y ca-certificates cmake curl patch python3-pip
296
+ sudo apt-get install -y libopencv-dev
297
+ pip install --user --no-cache-dir grpcio-tools==1.64.1
298
+ - name: Test vall-e-x
299
+ run: |
300
+ make --jobs=5 --output-sync=target -C backend/python/vall-e-x
301
+ make --jobs=5 --output-sync=target -C backend/python/vall-e-x test
302
+
303
+ tests-coqui:
304
+ runs-on: ubuntu-latest
305
+ steps:
306
+ - name: Clone
307
+ uses: actions/checkout@v4
308
+ with:
309
+ submodules: true
310
+ - name: Dependencies
311
+ run: |
312
+ sudo apt-get update
313
+ sudo apt-get install build-essential ffmpeg
314
+ sudo apt-get install -y ca-certificates cmake curl patch espeak espeak-ng python3-pip
315
+ # Install UV
316
+ curl -LsSf https://astral.sh/uv/install.sh | sh
317
+ pip install --user --no-cache-dir grpcio-tools==1.64.1
318
+ - name: Test coqui
319
+ run: |
320
+ make --jobs=5 --output-sync=target -C backend/python/coqui
321
+ make --jobs=5 --output-sync=target -C backend/python/coqui test
.github/workflows/test.yml ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: 'tests'
3
+
4
+ on:
5
+ pull_request:
6
+ push:
7
+ branches:
8
+ - master
9
+ tags:
10
+ - '*'
11
+
12
+ env:
13
+ GRPC_VERSION: v1.65.0
14
+
15
+ concurrency:
16
+ group: ci-tests-${{ github.head_ref || github.ref }}-${{ github.repository }}
17
+ cancel-in-progress: true
18
+
19
+ jobs:
20
+ tests-linux:
21
+ runs-on: ubuntu-latest
22
+ strategy:
23
+ matrix:
24
+ go-version: ['1.21.x']
25
+ steps:
26
+ - name: Release space from worker
27
+ run: |
28
+ echo "Listing top largest packages"
29
+ pkgs=$(dpkg-query -Wf '${Installed-Size}\t${Package}\t${Status}\n' | awk '$NF == "installed"{print $1 "\t" $2}' | sort -nr)
30
+ head -n 30 <<< "${pkgs}"
31
+ echo
32
+ df -h
33
+ echo
34
+ sudo apt-get remove -y '^llvm-.*|^libllvm.*' || true
35
+ sudo apt-get remove --auto-remove android-sdk-platform-tools || true
36
+ sudo apt-get purge --auto-remove android-sdk-platform-tools || true
37
+ sudo rm -rf /usr/local/lib/android
38
+ sudo apt-get remove -y '^dotnet-.*|^aspnetcore-.*' || true
39
+ sudo rm -rf /usr/share/dotnet
40
+ sudo apt-get remove -y '^mono-.*' || true
41
+ sudo apt-get remove -y '^ghc-.*' || true
42
+ sudo apt-get remove -y '.*jdk.*|.*jre.*' || true
43
+ sudo apt-get remove -y 'php.*' || true
44
+ sudo apt-get remove -y hhvm powershell firefox monodoc-manual msbuild || true
45
+ sudo apt-get remove -y '^google-.*' || true
46
+ sudo apt-get remove -y azure-cli || true
47
+ sudo apt-get remove -y '^mongo.*-.*|^postgresql-.*|^mysql-.*|^mssql-.*' || true
48
+ sudo apt-get remove -y '^gfortran-.*' || true
49
+ sudo apt-get autoremove -y
50
+ sudo apt-get clean
51
+ echo
52
+ echo "Listing top largest packages"
53
+ pkgs=$(dpkg-query -Wf '${Installed-Size}\t${Package}\t${Status}\n' | awk '$NF == "installed"{print $1 "\t" $2}' | sort -nr)
54
+ head -n 30 <<< "${pkgs}"
55
+ echo
56
+ sudo rm -rfv build || true
57
+ df -h
58
+ - name: Clone
59
+ uses: actions/checkout@v4
60
+ with:
61
+ submodules: true
62
+ - name: Setup Go ${{ matrix.go-version }}
63
+ uses: actions/setup-go@v5
64
+ with:
65
+ go-version: ${{ matrix.go-version }}
66
+ cache: false
67
+ # You can test your matrix by printing the current Go version
68
+ - name: Display Go version
69
+ run: go version
70
+ - name: Dependencies
71
+ run: |
72
+ sudo apt-get update
73
+ sudo apt-get install build-essential ccache upx-ucl curl ffmpeg
74
+ sudo apt-get install -y libgmock-dev
75
+ curl https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > conda.gpg && \
76
+ sudo install -o root -g root -m 644 conda.gpg /usr/share/keyrings/conda-archive-keyring.gpg && \
77
+ gpg --keyring /usr/share/keyrings/conda-archive-keyring.gpg --no-default-keyring --fingerprint 34161F5BF5EB1D4BFBBB8F0A8AEB4F8B29D82806 && \
78
+ sudo /bin/bash -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" > /etc/apt/sources.list.d/conda.list' && \
79
+ sudo /bin/bash -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" | tee -a /etc/apt/sources.list.d/conda.list' && \
80
+ sudo apt-get update && \
81
+ sudo apt-get install -y conda
82
+ # Install UV
83
+ curl -LsSf https://astral.sh/uv/install.sh | sh
84
+ sudo apt-get install -y ca-certificates cmake patch python3-pip unzip
85
+ sudo apt-get install -y libopencv-dev
86
+
87
+ curl -L -s https://github.com/protocolbuffers/protobuf/releases/download/v26.1/protoc-26.1-linux-x86_64.zip -o protoc.zip && \
88
+ unzip -j -d /usr/local/bin protoc.zip bin/protoc && \
89
+ rm protoc.zip
90
+
91
+ curl -O https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
92
+ sudo dpkg -i cuda-keyring_1.1-1_all.deb
93
+ sudo apt-get update
94
+ sudo apt-get install -y cuda-nvcc-${CUDA_VERSION} libcublas-dev-${CUDA_VERSION}
95
+ export CUDACXX=/usr/local/cuda/bin/nvcc
96
+
97
+ go install google.golang.org/protobuf/cmd/[email protected]
98
+ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@1958fcbe2ca8bd93af633f11e97d44e567e945af
99
+
100
+ # The python3-grpc-tools package in 22.04 is too old
101
+ pip install --user grpcio-tools
102
+
103
+ sudo rm -rfv /usr/bin/conda || true
104
+ PATH=$PATH:/opt/conda/bin make -C backend/python/sentencetransformers
105
+
106
+ # Pre-build piper before we start tests in order to have shared libraries in place
107
+ make sources/go-piper && \
108
+ GO_TAGS="tts" make -C sources/go-piper piper.o && \
109
+ sudo cp -rfv sources/go-piper/piper-phonemize/pi/lib/. /usr/lib/ && \
110
+ # Pre-build stable diffusion before we install a newer version of abseil (not compatible with stablediffusion-ncn)
111
+ PATH="$PATH:/root/go/bin" GO_TAGS="stablediffusion tts" GRPC_BACKENDS=backend-assets/grpc/stablediffusion make build
112
+ env:
113
+ CUDA_VERSION: 12-4
114
+ - name: Cache grpc
115
+ id: cache-grpc
116
+ uses: actions/cache@v4
117
+ with:
118
+ path: grpc
119
+ key: ${{ runner.os }}-grpc-${{ env.GRPC_VERSION }}
120
+ - name: Build grpc
121
+ if: steps.cache-grpc.outputs.cache-hit != 'true'
122
+ run: |
123
+ git clone --recurse-submodules -b ${{ env.GRPC_VERSION }} --depth 1 --jobs 5 --shallow-submodules https://github.com/grpc/grpc && \
124
+ cd grpc && sed -i "216i\ TESTONLY" "third_party/abseil-cpp/absl/container/CMakeLists.txt" && mkdir -p cmake/build && cd cmake/build && \
125
+ cmake -DgRPC_INSTALL=ON \
126
+ -DgRPC_BUILD_TESTS=OFF \
127
+ ../.. && sudo make --jobs 5
128
+ - name: Install gRPC
129
+ run: |
130
+ cd grpc && cd cmake/build && sudo make --jobs 5 install
131
+ - name: Test
132
+ run: |
133
+ PATH="$PATH:/root/go/bin" GO_TAGS="stablediffusion tts" make --jobs 5 --output-sync=target test
134
+ - name: Setup tmate session if tests fail
135
+ if: ${{ failure() }}
136
+ uses: mxschmitt/[email protected]
137
+ with:
138
+ detached: true
139
+ connect-timeout-seconds: 180
140
+ limit-access-to-actor: true
141
+
142
+ tests-aio-container:
143
+ runs-on: ubuntu-latest
144
+ steps:
145
+ - name: Release space from worker
146
+ run: |
147
+ echo "Listing top largest packages"
148
+ pkgs=$(dpkg-query -Wf '${Installed-Size}\t${Package}\t${Status}\n' | awk '$NF == "installed"{print $1 "\t" $2}' | sort -nr)
149
+ head -n 30 <<< "${pkgs}"
150
+ echo
151
+ df -h
152
+ echo
153
+ sudo apt-get remove -y '^llvm-.*|^libllvm.*' || true
154
+ sudo apt-get remove --auto-remove android-sdk-platform-tools || true
155
+ sudo apt-get purge --auto-remove android-sdk-platform-tools || true
156
+ sudo rm -rf /usr/local/lib/android
157
+ sudo apt-get remove -y '^dotnet-.*|^aspnetcore-.*' || true
158
+ sudo rm -rf /usr/share/dotnet
159
+ sudo apt-get remove -y '^mono-.*' || true
160
+ sudo apt-get remove -y '^ghc-.*' || true
161
+ sudo apt-get remove -y '.*jdk.*|.*jre.*' || true
162
+ sudo apt-get remove -y 'php.*' || true
163
+ sudo apt-get remove -y hhvm powershell firefox monodoc-manual msbuild || true
164
+ sudo apt-get remove -y '^google-.*' || true
165
+ sudo apt-get remove -y azure-cli || true
166
+ sudo apt-get remove -y '^mongo.*-.*|^postgresql-.*|^mysql-.*|^mssql-.*' || true
167
+ sudo apt-get remove -y '^gfortran-.*' || true
168
+ sudo apt-get autoremove -y
169
+ sudo apt-get clean
170
+ echo
171
+ echo "Listing top largest packages"
172
+ pkgs=$(dpkg-query -Wf '${Installed-Size}\t${Package}\t${Status}\n' | awk '$NF == "installed"{print $1 "\t" $2}' | sort -nr)
173
+ head -n 30 <<< "${pkgs}"
174
+ echo
175
+ sudo rm -rfv build || true
176
+ df -h
177
+ - name: Clone
178
+ uses: actions/checkout@v4
179
+ with:
180
+ submodules: true
181
+ - name: Build images
182
+ run: |
183
+ docker build --build-arg FFMPEG=true --build-arg IMAGE_TYPE=extras --build-arg EXTRA_BACKENDS=rerankers --build-arg MAKEFLAGS="--jobs=5 --output-sync=target" -t local-ai:tests -f Dockerfile .
184
+ BASE_IMAGE=local-ai:tests DOCKER_AIO_IMAGE=local-ai-aio:test make docker-aio
185
+ - name: Test
186
+ run: |
187
+ LOCALAI_MODELS_DIR=$PWD/models LOCALAI_IMAGE_TAG=test LOCALAI_IMAGE=local-ai-aio \
188
+ make run-e2e-aio
189
+ - name: Setup tmate session if tests fail
190
+ if: ${{ failure() }}
191
+ uses: mxschmitt/[email protected]
192
+ with:
193
+ detached: true
194
+ connect-timeout-seconds: 180
195
+ limit-access-to-actor: true
196
+
197
+ tests-apple:
198
+ runs-on: macOS-14
199
+ strategy:
200
+ matrix:
201
+ go-version: ['1.21.x']
202
+ steps:
203
+ - name: Clone
204
+ uses: actions/checkout@v4
205
+ with:
206
+ submodules: true
207
+ - name: Setup Go ${{ matrix.go-version }}
208
+ uses: actions/setup-go@v5
209
+ with:
210
+ go-version: ${{ matrix.go-version }}
211
+ cache: false
212
+ # You can test your matrix by printing the current Go version
213
+ - name: Display Go version
214
+ run: go version
215
+ - name: Dependencies
216
+ run: |
217
+ brew install protobuf grpc make protoc-gen-go protoc-gen-go-grpc
218
+ pip install --user --no-cache-dir grpcio-tools==1.64.1
219
+ - name: Test
220
+ run: |
221
+ export C_INCLUDE_PATH=/usr/local/include
222
+ export CPLUS_INCLUDE_PATH=/usr/local/include
223
+ # Used to run the newer GNUMake version from brew that supports --output-sync
224
+ export PATH="/opt/homebrew/opt/make/libexec/gnubin:$PATH"
225
+ BUILD_TYPE="GITHUB_CI_HAS_BROKEN_METAL" CMAKE_ARGS="-DGGML_F16C=OFF -DGGML_AVX512=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF" make --jobs 4 --output-sync=target test
226
+ - name: Setup tmate session if tests fail
227
+ if: ${{ failure() }}
228
+ uses: mxschmitt/[email protected]
229
+ with:
230
+ detached: true
231
+ connect-timeout-seconds: 180
232
+ limit-access-to-actor: true
.github/workflows/update_swagger.yaml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Update swagger
2
+ on:
3
+ schedule:
4
+ - cron: 0 20 * * *
5
+ workflow_dispatch:
6
+ jobs:
7
+ swagger:
8
+ strategy:
9
+ fail-fast: false
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-go@v5
14
+ with:
15
+ go-version: 'stable'
16
+ - name: Dependencies
17
+ run: |
18
+ sudo apt-get update
19
+ sudo apt-get install protobuf-compiler
20
+ - run: |
21
+ go install github.com/swaggo/swag/cmd/swag@latest
22
+ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@1958fcbe2ca8bd93af633f11e97d44e567e945af
23
+ go install google.golang.org/protobuf/cmd/[email protected]
24
+ - name: Bump swagger 🔧
25
+ run: |
26
+ make protogen-go swagger
27
+ - name: Create Pull Request
28
+ uses: peter-evans/create-pull-request@v6
29
+ with:
30
+ token: ${{ secrets.UPDATE_BOT_TOKEN }}
31
+ push-to-fork: ci-forks/LocalAI
32
+ commit-message: 'feat(swagger): update swagger'
33
+ title: 'feat(swagger): update swagger'
34
+ branch: "update/swagger"
35
+ body: Update swagger
36
+ signoff: true
37
+
.github/workflows/yaml-check.yml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 'Yamllint GitHub Actions'
2
+ on:
3
+ - pull_request
4
+ jobs:
5
+ yamllint:
6
+ name: 'Yamllint'
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - name: 'Checkout'
10
+ uses: actions/checkout@master
11
+ - name: 'Yamllint'
12
+ uses: karancode/yamllint-github-action@master
13
+ with:
14
+ yamllint_file_or_dir: 'gallery'
15
+ yamllint_strict: false
16
+ yamllint_comment: true
17
+ env:
18
+ GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
.gitignore ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # go-llama build artifacts
2
+ /sources/
3
+ __pycache__/
4
+ *.a
5
+ get-sources
6
+ prepare-sources
7
+ /backend/cpp/llama/grpc-server
8
+ /backend/cpp/llama/llama.cpp
9
+ /backend/cpp/llama-*
10
+
11
+ *.log
12
+
13
+ go-ggml-transformers
14
+ go-gpt2
15
+ go-rwkv
16
+ whisper.cpp
17
+ /bloomz
18
+ go-bert
19
+
20
+ # LocalAI build binary
21
+ LocalAI
22
+ local-ai
23
+ # prevent above rules from omitting the helm chart
24
+ !charts/*
25
+ # prevent above rules from omitting the api/localai folder
26
+ !api/localai
27
+ !core/**/localai
28
+
29
+ # Ignore models
30
+ models/*
31
+ test-models/
32
+ test-dir/
33
+
34
+ release/
35
+
36
+ # just in case
37
+ .DS_Store
38
+ .idea
39
+
40
+ # Generated during build
41
+ backend-assets/*
42
+ !backend-assets/.keep
43
+ prepare
44
+ /ggml-metal.metal
45
+ docs/static/gallery.html
46
+
47
+ # Protobuf generated files
48
+ *.pb.go
49
+ *pb2.py
50
+ *pb2_grpc.py
51
+
52
+ # SonarQube
53
+ .scannerwork
54
+
55
+ # backend virtual environments
56
+ **/venv
.gitmodules ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ [submodule "docs/themes/hugo-theme-relearn"]
2
+ path = docs/themes/hugo-theme-relearn
3
+ url = https://github.com/McShelby/hugo-theme-relearn.git
4
+ [submodule "docs/themes/lotusdocs"]
5
+ path = docs/themes/lotusdocs
6
+ url = https://github.com/colinwilson/lotusdocs
.vscode/extensions.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "recommendations": [
3
+ "golang.go"
4
+ ]
5
+ }
.vscode/launch.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "name": "Python: Current File",
6
+ "type": "python",
7
+ "request": "launch",
8
+ "program": "${file}",
9
+ "console": "integratedTerminal",
10
+ "justMyCode": false,
11
+ "cwd": "${workspaceFolder}/examples/langchain-chroma",
12
+ "env": {
13
+ "OPENAI_API_BASE": "http://localhost:8080/v1",
14
+ "OPENAI_API_KEY": "abc"
15
+ }
16
+ },
17
+ {
18
+ "name": "Launch LocalAI API",
19
+ "type": "go",
20
+ "request": "launch",
21
+ "mode": "debug",
22
+ "program": "${workspaceFolder}/main.go",
23
+ "args": [
24
+ "api"
25
+ ],
26
+ "env": {
27
+ "C_INCLUDE_PATH": "${workspaceFolder}/go-llama:${workspaceFolder}/go-stable-diffusion/:${workspaceFolder}/gpt4all/gpt4all-bindings/golang/:${workspaceFolder}/go-gpt2:${workspaceFolder}/go-rwkv:${workspaceFolder}/whisper.cpp:${workspaceFolder}/go-bert:${workspaceFolder}/bloomz",
28
+ "LIBRARY_PATH": "${workspaceFolder}/go-llama:${workspaceFolder}/go-stable-diffusion/:${workspaceFolder}/gpt4all/gpt4all-bindings/golang/:${workspaceFolder}/go-gpt2:${workspaceFolder}/go-rwkv:${workspaceFolder}/whisper.cpp:${workspaceFolder}/go-bert:${workspaceFolder}/bloomz",
29
+ "DEBUG": "true"
30
+ }
31
+ }
32
+ ]
33
+ }
.yamllint ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ extends: default
2
+
3
+ rules:
4
+ line-length: disable
CONTRIBUTING.md ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributing to LocalAI
2
+
3
+ Thank you for your interest in contributing to LocalAI! We appreciate your time and effort in helping to improve our project. Before you get started, please take a moment to review these guidelines.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Getting Started](#getting-started)
8
+ - [Prerequisites](#prerequisites)
9
+ - [Setting up the Development Environment](#setting-up-the-development-environment)
10
+ - [Contributing](#contributing)
11
+ - [Submitting an Issue](#submitting-an-issue)
12
+ - [Creating a Pull Request (PR)](#creating-a-pull-request-pr)
13
+ - [Coding Guidelines](#coding-guidelines)
14
+ - [Testing](#testing)
15
+ - [Documentation](#documentation)
16
+ - [Community and Communication](#community-and-communication)
17
+
18
+
19
+
20
+ ## Getting Started
21
+
22
+ ### Prerequisites
23
+
24
+ - Golang [1.21]
25
+ - Git
26
+ - macOS/Linux
27
+
28
+ ### Setting up the Development Environment and running localAI in the local environment
29
+
30
+ 1. Clone the repository: `git clone https://github.com/go-skynet/LocalAI.git`
31
+ 2. Navigate to the project directory: `cd LocalAI`
32
+ 3. Install the required dependencies ( see https://localai.io/basics/build/#build-localai-locally )
33
+ 4. Build LocalAI: `make build`
34
+ 5. Run LocalAI: `./local-ai`
35
+
36
+ ## Contributing
37
+
38
+ We welcome contributions from everyone! To get started, follow these steps:
39
+
40
+ ### Submitting an Issue
41
+
42
+ If you find a bug, have a feature request, or encounter any issues, please check the [issue tracker](https://github.com/go-skynet/LocalAI/issues) to see if a similar issue has already been reported. If not, feel free to [create a new issue](https://github.com/go-skynet/LocalAI/issues/new) and provide as much detail as possible.
43
+
44
+ ### Creating a Pull Request (PR)
45
+
46
+ 1. Fork the repository.
47
+ 2. Create a new branch with a descriptive name: `git checkout -b [branch name]`
48
+ 3. Make your changes and commit them.
49
+ 4. Push the changes to your fork: `git push origin [branch name]`
50
+ 5. Create a new pull request from your branch to the main project's `main` or `master` branch.
51
+ 6. Provide a clear description of your changes in the pull request.
52
+ 7. Make any requested changes during the review process.
53
+ 8. Once your PR is approved, it will be merged into the main project.
54
+
55
+ ## Coding Guidelines
56
+
57
+ - No specific coding guidelines at the moment. Please make sure the code can be tested. The most popular lint tools like []`golangci-lint`](https://golangci-lint.run) can help you here.
58
+
59
+ ## Testing
60
+
61
+ `make test` cannot handle all the model now. Please be sure to add a test case for the new features or the part was changed.
62
+
63
+ ### Running AIO tests
64
+
65
+ All-In-One images has a set of tests that automatically verifies that most of the endpoints works correctly, a flow can be :
66
+
67
+ ```bash
68
+ # Build the LocalAI docker image
69
+ make DOCKER_IMAGE=local-ai docker
70
+
71
+ # Build the corresponding AIO image
72
+ BASE_IMAGE=local-ai DOCKER_AIO_IMAGE=local-ai-aio:test make docker-aio
73
+
74
+ # Run the AIO e2e tests
75
+ LOCALAI_IMAGE_TAG=test LOCALAI_IMAGE=local-ai-aio make run-e2e-aio
76
+ ```
77
+
78
+ ## Documentation
79
+
80
+ We are welcome the contribution of the documents, please open new PR or create a new issue. The documentation is available under `docs/` https://github.com/mudler/LocalAI/tree/master/docs
81
+
82
+ ## Community and Communication
83
+
84
+ - You can reach out via the Github issue tracker.
85
+ - Open a new discussion at [Discussion](https://github.com/go-skynet/LocalAI/discussions)
86
+ - Join the Discord channel [Discord](https://discord.gg/uJAeKSAGDy)
87
+
88
+ ---
Dockerfile ADDED
@@ -0,0 +1,397 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ARG IMAGE_TYPE=extras
2
+ ARG BASE_IMAGE=ubuntu:22.04
3
+ ARG GRPC_BASE_IMAGE=${BASE_IMAGE}
4
+ ARG INTEL_BASE_IMAGE=${BASE_IMAGE}
5
+
6
+ # The requirements-core target is common to all images. It should not be placed in requirements-core unless every single build will use it.
7
+ FROM ${BASE_IMAGE} AS requirements-core
8
+
9
+ USER root
10
+
11
+ ARG GO_VERSION=1.22.5
12
+ ARG TARGETARCH
13
+ ARG TARGETVARIANT
14
+
15
+ ENV DEBIAN_FRONTEND=noninteractive
16
+ ENV EXTERNAL_GRPC_BACKENDS="coqui:/build/backend/python/coqui/run.sh,huggingface-embeddings:/build/backend/python/sentencetransformers/run.sh,petals:/build/backend/python/petals/run.sh,transformers:/build/backend/python/transformers/run.sh,sentencetransformers:/build/backend/python/sentencetransformers/run.sh,rerankers:/build/backend/python/rerankers/run.sh,autogptq:/build/backend/python/autogptq/run.sh,bark:/build/backend/python/bark/run.sh,diffusers:/build/backend/python/diffusers/run.sh,exllama:/build/backend/python/exllama/run.sh,openvoice:/build/backend/python/openvoice/run.sh,vall-e-x:/build/backend/python/vall-e-x/run.sh,vllm:/build/backend/python/vllm/run.sh,mamba:/build/backend/python/mamba/run.sh,exllama2:/build/backend/python/exllama2/run.sh,transformers-musicgen:/build/backend/python/transformers-musicgen/run.sh,parler-tts:/build/backend/python/parler-tts/run.sh"
17
+
18
+
19
+ RUN apt-get update && \
20
+ apt-get install -y --no-install-recommends \
21
+ build-essential \
22
+ ccache \
23
+ ca-certificates \
24
+ cmake \
25
+ curl \
26
+ git \
27
+ unzip upx-ucl && \
28
+ apt-get clean && \
29
+ rm -rf /var/lib/apt/lists/*
30
+
31
+ # Install Go
32
+ RUN curl -L -s https://go.dev/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz | tar -C /usr/local -xz
33
+ ENV PATH $PATH:/root/go/bin:/usr/local/go/bin
34
+
35
+ # Install grpc compilers
36
+ RUN go install google.golang.org/protobuf/cmd/[email protected] && \
37
+ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@1958fcbe2ca8bd93af633f11e97d44e567e945af
38
+
39
+ COPY --chmod=644 custom-ca-certs/* /usr/local/share/ca-certificates/
40
+ RUN update-ca-certificates
41
+
42
+ # Use the variables in subsequent instructions
43
+ RUN echo "Target Architecture: $TARGETARCH"
44
+ RUN echo "Target Variant: $TARGETVARIANT"
45
+
46
+ # Cuda
47
+ ENV PATH /usr/local/cuda/bin:${PATH}
48
+
49
+ # HipBLAS requirements
50
+ ENV PATH /opt/rocm/bin:${PATH}
51
+
52
+ # OpenBLAS requirements and stable diffusion
53
+ RUN apt-get update && \
54
+ apt-get install -y --no-install-recommends \
55
+ libopenblas-dev \
56
+ libopencv-dev && \
57
+ apt-get clean && \
58
+ rm -rf /var/lib/apt/lists/*
59
+
60
+ # Set up OpenCV
61
+ RUN ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
62
+
63
+ WORKDIR /build
64
+
65
+ RUN test -n "$TARGETARCH" \
66
+ || (echo 'warn: missing $TARGETARCH, either set this `ARG` manually, or run using `docker buildkit`')
67
+
68
+ ###################################
69
+ ###################################
70
+
71
+ # The requirements-extras target is for any builds with IMAGE_TYPE=extras. It should not be placed in this target unless every IMAGE_TYPE=extras build will use it
72
+ FROM requirements-core AS requirements-extras
73
+
74
+ RUN curl -LsSf https://astral.sh/uv/install.sh | sh
75
+ ENV PATH="/root/.cargo/bin:${PATH}"
76
+
77
+ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
78
+ RUN apt-get update && \
79
+ apt-get install -y --no-install-recommends \
80
+ espeak-ng \
81
+ espeak \
82
+ python3-pip \
83
+ python-is-python3 \
84
+ python3-dev \
85
+ python3-venv && \
86
+ apt-get clean && \
87
+ rm -rf /var/lib/apt/lists/* && \
88
+ pip install --upgrade pip
89
+
90
+ # Install grpcio-tools (the version in 22.04 is too old)
91
+ RUN pip install --user grpcio-tools
92
+
93
+ ###################################
94
+ ###################################
95
+
96
+ # The requirements-drivers target is for BUILD_TYPE specific items. If you need to install something specific to CUDA, or specific to ROCM, it goes here.
97
+ # This target will be built on top of requirements-core or requirements-extras as retermined by the IMAGE_TYPE build-arg
98
+ FROM requirements-${IMAGE_TYPE} AS requirements-drivers
99
+
100
+ ARG BUILD_TYPE
101
+ ARG CUDA_MAJOR_VERSION=12
102
+ ARG CUDA_MINOR_VERSION=0
103
+
104
+ ENV BUILD_TYPE=${BUILD_TYPE}
105
+
106
+ # Vulkan requirements
107
+ RUN <<EOT bash
108
+ if [ "${BUILD_TYPE}" = "vulkan" ]; then
109
+ apt-get update && \
110
+ apt-get install -y --no-install-recommends \
111
+ software-properties-common pciutils wget gpg-agent && \
112
+ wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | apt-key add - && \
113
+ wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list && \
114
+ apt-get update && \
115
+ apt-get install -y \
116
+ vulkan-sdk && \
117
+ apt-get clean && \
118
+ rm -rf /var/lib/apt/lists/*
119
+ fi
120
+ EOT
121
+
122
+ # CuBLAS requirements
123
+ RUN <<EOT bash
124
+ if [ "${BUILD_TYPE}" = "cublas" ]; then
125
+ apt-get update && \
126
+ apt-get install -y --no-install-recommends \
127
+ software-properties-common pciutils
128
+ if [ "amd64" = "$TARGETARCH" ]; then
129
+ curl -O https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
130
+ fi
131
+ if [ "arm64" = "$TARGETARCH" ]; then
132
+ curl -O https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/arm64/cuda-keyring_1.1-1_all.deb
133
+ fi
134
+ dpkg -i cuda-keyring_1.1-1_all.deb && \
135
+ rm -f cuda-keyring_1.1-1_all.deb && \
136
+ apt-get update && \
137
+ apt-get install -y --no-install-recommends \
138
+ cuda-nvcc-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
139
+ libcufft-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
140
+ libcurand-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
141
+ libcublas-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
142
+ libcusparse-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
143
+ libcusolver-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} && \
144
+ apt-get clean && \
145
+ rm -rf /var/lib/apt/lists/*
146
+ fi
147
+ EOT
148
+
149
+ # If we are building with clblas support, we need the libraries for the builds
150
+ RUN if [ "${BUILD_TYPE}" = "clblas" ]; then \
151
+ apt-get update && \
152
+ apt-get install -y --no-install-recommends \
153
+ libclblast-dev && \
154
+ apt-get clean && \
155
+ rm -rf /var/lib/apt/lists/* \
156
+ ; fi
157
+
158
+ RUN if [ "${BUILD_TYPE}" = "hipblas" ]; then \
159
+ apt-get update && \
160
+ apt-get install -y --no-install-recommends \
161
+ hipblas-dev \
162
+ rocblas-dev && \
163
+ apt-get clean && \
164
+ rm -rf /var/lib/apt/lists/* && \
165
+ # I have no idea why, but the ROCM lib packages don't trigger ldconfig after they install, which results in local-ai and others not being able
166
+ # to locate the libraries. We run ldconfig ourselves to work around this packaging deficiency
167
+ ldconfig \
168
+ ; fi
169
+
170
+ ###################################
171
+ ###################################
172
+
173
+ # Temporary workaround for Intel's repository to work correctly
174
+ # https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/APT-Repository-not-working-signatures-invalid/m-p/1599436/highlight/true#M36143
175
+ # This is a temporary workaround until Intel fixes their repository
176
+ FROM ${INTEL_BASE_IMAGE} AS intel
177
+ RUN wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | \
178
+ gpg --yes --dearmor --output /usr/share/keyrings/intel-graphics.gpg
179
+ RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu jammy/lts/2350 unified" > /etc/apt/sources.list.d/intel-graphics.list
180
+
181
+ ###################################
182
+ ###################################
183
+
184
+ # The grpc target does one thing, it builds and installs GRPC. This is in it's own layer so that it can be effectively cached by CI.
185
+ # You probably don't need to change anything here, and if you do, make sure that CI is adjusted so that the cache continues to work.
186
+ FROM ${GRPC_BASE_IMAGE} AS grpc
187
+
188
+ # This is a bit of a hack, but it's required in order to be able to effectively cache this layer in CI
189
+ ARG GRPC_MAKEFLAGS="-j4 -Otarget"
190
+ ARG GRPC_VERSION=v1.65.0
191
+
192
+ ENV MAKEFLAGS=${GRPC_MAKEFLAGS}
193
+
194
+ WORKDIR /build
195
+
196
+ RUN apt-get update && \
197
+ apt-get install -y --no-install-recommends \
198
+ ca-certificates \
199
+ build-essential \
200
+ cmake \
201
+ git && \
202
+ apt-get clean && \
203
+ rm -rf /var/lib/apt/lists/*
204
+
205
+ # We install GRPC to a different prefix here so that we can copy in only the build artifacts later
206
+ # saves several hundred MB on the final docker image size vs copying in the entire GRPC source tree
207
+ # and running make install in the target container
208
+ RUN git clone --recurse-submodules --jobs 4 -b ${GRPC_VERSION} --depth 1 --shallow-submodules https://github.com/grpc/grpc && \
209
+ mkdir -p /build/grpc/cmake/build && \
210
+ cd /build/grpc/cmake/build && \
211
+ sed -i "216i\ TESTONLY" "../../third_party/abseil-cpp/absl/container/CMakeLists.txt" && \
212
+ cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX:PATH=/opt/grpc ../.. && \
213
+ make && \
214
+ make install && \
215
+ rm -rf /build
216
+
217
+ ###################################
218
+ ###################################
219
+
220
+ # The builder target compiles LocalAI. This target is not the target that will be uploaded to the registry.
221
+ # Adjustments to the build process should likely be made here.
222
+ FROM requirements-drivers AS builder
223
+
224
+ ARG GO_TAGS="stablediffusion tts p2p"
225
+ ARG GRPC_BACKENDS
226
+ ARG MAKEFLAGS
227
+
228
+ ENV GRPC_BACKENDS=${GRPC_BACKENDS}
229
+ ENV GO_TAGS=${GO_TAGS}
230
+ ENV MAKEFLAGS=${MAKEFLAGS}
231
+ ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
232
+ ENV NVIDIA_REQUIRE_CUDA="cuda>=${CUDA_MAJOR_VERSION}.0"
233
+ ENV NVIDIA_VISIBLE_DEVICES=all
234
+
235
+ WORKDIR /build
236
+
237
+ COPY . .
238
+ COPY .git .
239
+ RUN echo "GO_TAGS: $GO_TAGS"
240
+
241
+ RUN make prepare
242
+
243
+ # We need protoc installed, and the version in 22.04 is too old. We will create one as part installing the GRPC build below
244
+ # but that will also being in a newer version of absl which stablediffusion cannot compile with. This version of protoc is only
245
+ # here so that we can generate the grpc code for the stablediffusion build
246
+ RUN <<EOT bash
247
+ if [ "amd64" = "$TARGETARCH" ]; then
248
+ curl -L -s https://github.com/protocolbuffers/protobuf/releases/download/v27.1/protoc-27.1-linux-x86_64.zip -o protoc.zip && \
249
+ unzip -j -d /usr/local/bin protoc.zip bin/protoc && \
250
+ rm protoc.zip
251
+ fi
252
+ if [ "arm64" = "$TARGETARCH" ]; then
253
+ curl -L -s https://github.com/protocolbuffers/protobuf/releases/download/v27.1/protoc-27.1-linux-aarch_64.zip -o protoc.zip && \
254
+ unzip -j -d /usr/local/bin protoc.zip bin/protoc && \
255
+ rm protoc.zip
256
+ fi
257
+ EOT
258
+
259
+ # stablediffusion does not tolerate a newer version of abseil, build it first
260
+ RUN GRPC_BACKENDS=backend-assets/grpc/stablediffusion make build
261
+
262
+ # Install the pre-built GRPC
263
+ COPY --from=grpc /opt/grpc /usr/local
264
+
265
+ # Rebuild with defaults backends
266
+ WORKDIR /build
267
+
268
+ ## Build the binary
269
+ RUN make build
270
+
271
+ RUN if [ ! -d "/build/sources/go-piper/piper-phonemize/pi/lib/" ]; then \
272
+ mkdir -p /build/sources/go-piper/piper-phonemize/pi/lib/ \
273
+ touch /build/sources/go-piper/piper-phonemize/pi/lib/keep \
274
+ ; fi
275
+
276
+ ###################################
277
+ ###################################
278
+
279
+ # This is the final target. The result of this target will be the image uploaded to the registry.
280
+ # If you cannot find a more suitable place for an addition, this layer is a suitable place for it.
281
+ FROM requirements-drivers
282
+
283
+ ARG FFMPEG
284
+ ARG BUILD_TYPE
285
+ ARG TARGETARCH
286
+ ARG IMAGE_TYPE=extras
287
+ ARG EXTRA_BACKENDS
288
+ ARG MAKEFLAGS
289
+
290
+ ENV BUILD_TYPE=${BUILD_TYPE}
291
+ ENV REBUILD=false
292
+ ENV HEALTHCHECK_ENDPOINT=http://localhost:8080/readyz
293
+ ENV MAKEFLAGS=${MAKEFLAGS}
294
+
295
+ ARG CUDA_MAJOR_VERSION=12
296
+ ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
297
+ ENV NVIDIA_REQUIRE_CUDA="cuda>=${CUDA_MAJOR_VERSION}.0"
298
+ ENV NVIDIA_VISIBLE_DEVICES=all
299
+
300
+ # Add FFmpeg
301
+ RUN if [ "${FFMPEG}" = "true" ]; then \
302
+ apt-get update && \
303
+ apt-get install -y --no-install-recommends \
304
+ ffmpeg && \
305
+ apt-get clean && \
306
+ rm -rf /var/lib/apt/lists/* \
307
+ ; fi
308
+
309
+ WORKDIR /build
310
+
311
+ # we start fresh & re-copy all assets because `make build` does not clean up nicely after itself
312
+ # so when `entrypoint.sh` runs `make build` again (which it does by default), the build would fail
313
+ # see https://github.com/go-skynet/LocalAI/pull/658#discussion_r1241971626 and
314
+ # https://github.com/go-skynet/LocalAI/pull/434
315
+ COPY . .
316
+
317
+ COPY --from=builder /build/sources ./sources/
318
+ COPY --from=grpc /opt/grpc /usr/local
319
+
320
+ RUN make prepare-sources
321
+
322
+ # Copy the binary
323
+ COPY --from=builder /build/local-ai ./
324
+
325
+ # Copy shared libraries for piper
326
+ COPY --from=builder /build/sources/go-piper/piper-phonemize/pi/lib/* /usr/lib/
327
+
328
+ # do not let stablediffusion rebuild (requires an older version of absl)
329
+ COPY --from=builder /build/backend-assets/grpc/stablediffusion ./backend-assets/grpc/stablediffusion
330
+
331
+ # Change the shell to bash so we can use [[ tests below
332
+ SHELL ["/bin/bash", "-c"]
333
+ # We try to strike a balance between individual layer size (as that affects total push time) and total image size
334
+ # Splitting the backends into more groups with fewer items results in a larger image, but a smaller size for the largest layer
335
+ # Splitting the backends into fewer groups with more items results in a smaller image, but a larger size for the largest layer
336
+
337
+ RUN if [[ ( "${EXTRA_BACKENDS}" =~ "coqui" || -z "${EXTRA_BACKENDS}" ) && "$IMAGE_TYPE" == "extras" ]]; then \
338
+ make -C backend/python/coqui \
339
+ ; fi && \
340
+ if [[ ( "${EXTRA_BACKENDS}" =~ "parler-tts" || -z "${EXTRA_BACKENDS}" ) && "$IMAGE_TYPE" == "extras" ]]; then \
341
+ make -C backend/python/parler-tts \
342
+ ; fi && \
343
+ if [[ ( "${EXTRA_BACKENDS}" =~ "diffusers" || -z "${EXTRA_BACKENDS}" ) && "$IMAGE_TYPE" == "extras" ]]; then \
344
+ make -C backend/python/diffusers \
345
+ ; fi && \
346
+ if [[ ( "${EXTRA_BACKENDS}" =~ "transformers-musicgen" || -z "${EXTRA_BACKENDS}" ) && "$IMAGE_TYPE" == "extras" ]]; then \
347
+ make -C backend/python/transformers-musicgen \
348
+ ; fi && \
349
+ if [[ ( "${EXTRA_BACKENDS}" =~ "exllama1" || -z "${EXTRA_BACKENDS}" ) && "$IMAGE_TYPE" == "extras" ]]; then \
350
+ make -C backend/python/exllama \
351
+ ; fi
352
+
353
+ RUN if [[ ( "${EXTRA_BACKENDS}" =~ "vall-e-x" || -z "${EXTRA_BACKENDS}" ) && "$IMAGE_TYPE" == "extras" ]]; then \
354
+ make -C backend/python/vall-e-x \
355
+ ; fi && \
356
+ if [[ ( "${EXTRA_BACKENDS}" =~ "openvoice" || -z "${EXTRA_BACKENDS}" ) && "$IMAGE_TYPE" == "extras" ]]; then \
357
+ make -C backend/python/openvoice \
358
+ ; fi && \
359
+ if [[ ( "${EXTRA_BACKENDS}" =~ "petals" || -z "${EXTRA_BACKENDS}" ) && "$IMAGE_TYPE" == "extras" ]]; then \
360
+ make -C backend/python/petals \
361
+ ; fi && \
362
+ if [[ ( "${EXTRA_BACKENDS}" =~ "sentencetransformers" || -z "${EXTRA_BACKENDS}" ) && "$IMAGE_TYPE" == "extras" ]]; then \
363
+ make -C backend/python/sentencetransformers \
364
+ ; fi && \
365
+ if [[ ( "${EXTRA_BACKENDS}" =~ "exllama2" || -z "${EXTRA_BACKENDS}" ) && "$IMAGE_TYPE" == "extras" ]]; then \
366
+ make -C backend/python/exllama2 \
367
+ ; fi && \
368
+ if [[ ( "${EXTRA_BACKENDS}" =~ "transformers" || -z "${EXTRA_BACKENDS}" ) && "$IMAGE_TYPE" == "extras" ]]; then \
369
+ make -C backend/python/transformers \
370
+ ; fi
371
+
372
+ RUN if [[ ( "${EXTRA_BACKENDS}" =~ "vllm" || -z "${EXTRA_BACKENDS}" ) && "$IMAGE_TYPE" == "extras" ]]; then \
373
+ make -C backend/python/vllm \
374
+ ; fi && \
375
+ if [[ ( "${EXTRA_BACKENDS}" =~ "autogptq" || -z "${EXTRA_BACKENDS}" ) && "$IMAGE_TYPE" == "extras" ]]; then \
376
+ make -C backend/python/autogptq \
377
+ ; fi && \
378
+ if [[ ( "${EXTRA_BACKENDS}" =~ "bark" || -z "${EXTRA_BACKENDS}" ) && "$IMAGE_TYPE" == "extras" ]]; then \
379
+ make -C backend/python/bark \
380
+ ; fi && \
381
+ if [[ ( "${EXTRA_BACKENDS}" =~ "rerankers" || -z "${EXTRA_BACKENDS}" ) && "$IMAGE_TYPE" == "extras" ]]; then \
382
+ make -C backend/python/rerankers \
383
+ ; fi && \
384
+ if [[ ( "${EXTRA_BACKENDS}" =~ "mamba" || -z "${EXTRA_BACKENDS}" ) && "$IMAGE_TYPE" == "extras" ]]; then \
385
+ make -C backend/python/mamba \
386
+ ; fi
387
+
388
+ # Make sure the models directory exists
389
+ RUN mkdir -p /build/models
390
+
391
+ # Define the health check command
392
+ HEALTHCHECK --interval=1m --timeout=10m --retries=10 \
393
+ CMD curl -f ${HEALTHCHECK_ENDPOINT} || exit 1
394
+
395
+ VOLUME /build/models
396
+ EXPOSE 8080
397
+ ENTRYPOINT [ "/build/entrypoint.sh" ]
Dockerfile.aio ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ ARG BASE_IMAGE=ubuntu:22.04
2
+
3
+ FROM ${BASE_IMAGE}
4
+
5
+ RUN apt-get update && apt-get install -y pciutils && apt-get clean
6
+
7
+ COPY aio/ /aio
8
+ ENTRYPOINT [ "/aio/entrypoint.sh" ]
Earthfile ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ VERSION 0.7
2
+
3
+ build:
4
+ FROM DOCKERFILE -f Dockerfile .
5
+ SAVE ARTIFACT /usr/bin/local-ai AS LOCAL local-ai
Entitlements.plist ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>com.apple.security.network.client</key>
6
+ <true/>
7
+ <key>com.apple.security.network.server</key>
8
+ <true/>
9
+ </dict>
10
+ </plist>
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023-2024 Ettore Di Giacinto ([email protected])
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.