Skip to content

Commit 894dde9

Browse files
committed
Merge remote-tracking branch 'localagent/master' into rewrite
2 parents 446908b + 18364d1 commit 894dde9

File tree

182 files changed

+26522
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+26522
-0
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
models/
2+
data/
3+
volumes/

.github/workflows/goreleaser.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Add this line to trigger the workflow on tag pushes that match 'v*'
7+
8+
permissions:
9+
id-token: write
10+
contents: read
11+
12+
jobs:
13+
goreleaser:
14+
permissions:
15+
contents: write
16+
runs-on: arc-runner-localagent
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
- name: Set up Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version: 1.22
26+
- name: Run GoReleaser
27+
uses: goreleaser/goreleaser-action@v6
28+
with:
29+
version: '~> v2'
30+
args: release --clean
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/image.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
name: 'build container images'
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- '*'
9+
concurrency:
10+
group: ci-image-${{ github.head_ref || github.ref }}-${{ github.repository }}
11+
cancel-in-progress: true
12+
jobs:
13+
containerImages:
14+
runs-on: arc-runner-localagent
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Prepare
20+
id: prep
21+
run: |
22+
DOCKER_IMAGE=quay.io/mudler/localagi
23+
# Use branch name as default
24+
VERSION=${GITHUB_REF#refs/heads/}
25+
BINARY_VERSION=$(git describe --always --tags --dirty)
26+
SHORTREF=${GITHUB_SHA::8}
27+
# If this is git tag, use the tag name as a docker tag
28+
if [[ $GITHUB_REF == refs/tags/* ]]; then
29+
VERSION=${GITHUB_REF#refs/tags/}
30+
fi
31+
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${SHORTREF}"
32+
# If the VERSION looks like a version number, assume that
33+
# this is the most recent version of the image and also
34+
# tag it 'latest'.
35+
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
36+
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
37+
fi
38+
# Set output parameters.
39+
echo ::set-output name=binary_version::${BINARY_VERSION}
40+
echo ::set-output name=tags::${TAGS}
41+
echo ::set-output name=docker_image::${DOCKER_IMAGE}
42+
- name: Set up QEMU
43+
uses: docker/setup-qemu-action@master
44+
with:
45+
platforms: all
46+
47+
- name: Set up Docker Buildx
48+
id: buildx
49+
uses: docker/setup-buildx-action@master
50+
51+
- name: Login to DockerHub
52+
if: github.event_name != 'pull_request'
53+
uses: docker/login-action@v3
54+
with:
55+
registry: quay.io
56+
username: ${{ secrets.DOCKER_USERNAME }}
57+
password: ${{ secrets.DOCKER_PASSWORD }}
58+
- name: Extract metadata (tags, labels) for Docker
59+
id: meta
60+
uses: docker/metadata-action@2a4836ac76fe8f5d0ee3a0d89aa12a80cc552ad3
61+
with:
62+
images: quay.io/mudler/localagi
63+
tags: |
64+
type=ref,event=branch,suffix=-{{date 'YYYYMMDDHHmmss'}}
65+
type=semver,pattern={{raw}}
66+
type=sha,suffix=-{{date 'YYYYMMDDHHmmss'}}
67+
type=ref,event=branch
68+
flavor: |
69+
latest=auto
70+
prefix=
71+
suffix=
72+
73+
- name: Build
74+
uses: docker/build-push-action@v6
75+
with:
76+
builder: ${{ steps.buildx.outputs.name }}
77+
build-args: |
78+
VERSION=${{ steps.prep.outputs.binary_version }}
79+
context: ./
80+
file: ./Dockerfile.webui
81+
#platforms: linux/amd64,linux/arm64
82+
platforms: linux/amd64
83+
push: true
84+
#tags: ${{ steps.prep.outputs.tags }}
85+
tags: ${{ steps.meta.outputs.tags }}
86+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/tests.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Run Go Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
pull_request:
8+
branches:
9+
- '**'
10+
concurrency:
11+
group: ci-tests-${{ github.head_ref || github.ref }}-${{ github.repository }}
12+
cancel-in-progress: true
13+
jobs:
14+
test:
15+
runs-on: arc-runner-localagent
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v2
19+
- run: |
20+
# Add Docker's official GPG key:
21+
sudo apt-get update
22+
sudo apt-get install ca-certificates curl
23+
sudo install -m 0755 -d /etc/apt/keyrings
24+
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
25+
sudo chmod a+r /etc/apt/keyrings/docker.asc
26+
27+
# Add the repository to Apt sources:
28+
echo \
29+
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
30+
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
31+
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
32+
sudo apt-get update
33+
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
34+
docker version
35+
36+
docker run --rm hello-world
37+
- uses: actions/setup-go@v5
38+
with:
39+
go-version: '>=1.17.0'
40+
- name: Run tests
41+
run: |
42+
sudo apt-get update && sudo apt-get install -y make
43+
make tests
44+
#sudo mv coverage/coverage.txt coverage.txt
45+
#sudo chmod 777 coverage.txt
46+
47+
# - name: Upload coverage to Codecov
48+
# uses: codecov/codecov-action@v4
49+
# with:
50+
# token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
models/
2+
data/
3+
pool
4+
uploads/
5+
local-agent-framework
6+
localagent
7+
LocalAgent
8+
**/.env
9+
.vscode

.goreleaser.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Make sure to check the documentation at http://goreleaser.com
2+
version: 2
3+
builds:
4+
- main: ./
5+
id: "localagent"
6+
binary: localagent
7+
ldflags:
8+
- -w -s
9+
# - -X github.com/internal.Version={{.Tag}}
10+
# - -X github.com/internal.Commit={{.Commit}}
11+
env:
12+
- CGO_ENABLED=0
13+
goos:
14+
- linux
15+
- windows
16+
- darwin
17+
- freebsd
18+
goarch:
19+
- amd64
20+
- arm
21+
- arm64
22+
source:
23+
enabled: true
24+
name_template: '{{ .ProjectName }}-{{ .Tag }}-source'
25+
archives:
26+
# Default template uses underscores instead of -
27+
- name_template: >-
28+
{{ .ProjectName }}-{{ .Tag }}-
29+
{{- if eq .Os "freebsd" }}FreeBSD
30+
{{- else }}{{- title .Os }}{{end}}-
31+
{{- if eq .Arch "amd64" }}x86_64
32+
{{- else if eq .Arch "386" }}i386
33+
{{- else }}{{ .Arch }}{{end}}
34+
{{- if .Arm }}v{{ .Arm }}{{ end }}
35+
checksum:
36+
name_template: '{{ .ProjectName }}-{{ .Tag }}-checksums.txt'
37+
snapshot:
38+
name_template: "{{ .Tag }}-next"
39+
changelog:
40+
use: github-native

Dockerfile.realtimesst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# python
2+
FROM python:3.10-slim
3+
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
RUN apt-get update && apt-get install -y python3-dev portaudio19-dev ffmpeg build-essential
6+
7+
RUN pip install RealtimeSTT
8+
9+
#COPY ./example/realtimesst /app
10+
# https://github.com/KoljaB/RealtimeSTT/blob/master/RealtimeSTT_server/README.md#server-usage
11+
ENTRYPOINT ["stt-server"]
12+
#ENTRYPOINT [ "/app/main.py" ]

Dockerfile.webui

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Define argument for linker flags
2+
ARG LDFLAGS=-s -w
3+
4+
# Use Bun container for building the React UI
5+
FROM oven/bun:1 as ui-builder
6+
7+
# Set the working directory for the React UI
8+
WORKDIR /app
9+
10+
# Copy package.json and bun.lockb (if exists)
11+
COPY webui/react-ui/package.json webui/react-ui/bun.lockb* ./
12+
13+
# Install dependencies
14+
RUN bun install --frozen-lockfile
15+
16+
# Copy the rest of the React UI source code
17+
COPY webui/react-ui/ ./
18+
19+
# Build the React UI
20+
RUN bun run build
21+
22+
# Use a temporary build image based on Golang 1.22-alpine
23+
FROM golang:1.22-alpine as builder
24+
25+
# Set environment variables: linker flags and disable CGO
26+
ENV LDFLAGS=$LDFLAGS CGO_ENABLED=0
27+
28+
# Install git
29+
RUN apk add --no-cache git
30+
RUN rm -rf /tmp/* /var/cache/apk/*
31+
32+
# Set the working directory
33+
WORKDIR /work
34+
35+
# Copy go.mod and go.sum files first to leverage Docker cache
36+
COPY go.mod go.sum ./
37+
38+
# Download dependencies - this layer will be cached as long as go.mod and go.sum don't change
39+
RUN go mod download
40+
41+
# Now copy the rest of the source code
42+
COPY . .
43+
44+
# Copy the built React UI from the ui-builder stage
45+
COPY --from=ui-builder /app/dist /work/webui/react-ui/dist
46+
47+
# Build the application
48+
RUN go build -ldflags="$LDFLAGS" -o localagent ./
49+
50+
FROM scratch
51+
52+
# Copy the webui binary from the builder stage to the final image
53+
COPY --from=builder /work/localagent /localagent
54+
COPY --from=builder /etc/ssl/ /etc/ssl/
55+
COPY --from=builder /tmp /tmp
56+
57+
# Define the command that will be run when the container is started
58+
ENTRYPOINT ["/localagent"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023-2025 Ettore Di Giacinto (mudler@localai.io)
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.

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
GOCMD?=go
2+
IMAGE_NAME?=webui
3+
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
4+
5+
prepare-tests:
6+
docker compose up -d
7+
8+
cleanup-tests:
9+
docker compose down
10+
11+
tests: prepare-tests
12+
LOCALAGENT_MODEL="arcee-agent" LOCALAI_API_URL="http://localhost:8081" LOCALAGENT_API_URL="http://localhost:8080" $(GOCMD) run github.com/onsi/ginkgo/v2/ginkgo --fail-fast -v -r ./...
13+
14+
run-nokb:
15+
$(MAKE) run KBDISABLEINDEX=true
16+
17+
webui/react-ui/dist:
18+
docker run --entrypoint /bin/bash -v $(ROOT_DIR):/app oven/bun:1 -c "cd /app/webui/react-ui && bun install && bun run build"
19+
20+
.PHONY: build
21+
build: webui/react-ui/dist
22+
$(GOCMD) build -o localagent ./
23+
24+
.PHONY: run
25+
run: webui/react-ui/dist
26+
$(GOCMD) run ./
27+
28+
build-image:
29+
docker build -t $(IMAGE_NAME) -f Dockerfile.webui .
30+
31+
image-push:
32+
docker push $(IMAGE_NAME)

0 commit comments

Comments
 (0)