Skip to content

Commit 65ba3ca

Browse files
committed
refactor: move main close to implementation for every backend
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent d02f6bf commit 65ba3ca

File tree

32 files changed

+118
-135
lines changed

32 files changed

+118
-135
lines changed

Makefile

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ backend-assets/grpc:
403403
backend-assets/grpc/llama: backend-assets/grpc go-llama/libbinding.a
404404
$(GOCMD) mod edit -replace github.com/go-skynet/go-llama.cpp=$(shell pwd)/go-llama
405405
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-llama LIBRARY_PATH=$(shell pwd)/go-llama \
406-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/llama ./cmd/grpc/llama/
406+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/llama ./backend/go/llm/llama/
407407
# TODO: every binary should have its own folder instead, so can have different metal implementations
408408
ifeq ($(BUILD_TYPE),metal)
409409
cp go-llama/build/bin/ggml-metal.metal backend-assets/grpc/
@@ -443,68 +443,68 @@ endif
443443
backend-assets/grpc/llama-stable: backend-assets/grpc go-llama-stable/libbinding.a
444444
$(GOCMD) mod edit -replace github.com/go-skynet/go-llama.cpp=$(shell pwd)/go-llama-stable
445445
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-llama-stable LIBRARY_PATH=$(shell pwd)/go-llama \
446-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/llama-stable ./cmd/grpc/llama-stable/
446+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/llama-stable ./backend/go/llm/llama-stable/
447447

448448
backend-assets/grpc/gpt4all: backend-assets/grpc backend-assets/gpt4all gpt4all/gpt4all-bindings/golang/libgpt4all.a
449449
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/gpt4all/gpt4all-bindings/golang/ LIBRARY_PATH=$(shell pwd)/gpt4all/gpt4all-bindings/golang/ \
450-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/gpt4all ./cmd/grpc/gpt4all/
450+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/gpt4all ./backend/go/llm/gpt4all/
451451

452452
backend-assets/grpc/dolly: backend-assets/grpc go-ggml-transformers/libtransformers.a
453453
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers \
454-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/dolly ./cmd/grpc/dolly/
454+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/dolly ./backend/go/llm/dolly/
455455

456456
backend-assets/grpc/gpt2: backend-assets/grpc go-ggml-transformers/libtransformers.a
457457
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers \
458-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/gpt2 ./cmd/grpc/gpt2/
458+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/gpt2 ./backend/go/llm/gpt2/
459459

460460
backend-assets/grpc/gptj: backend-assets/grpc go-ggml-transformers/libtransformers.a
461461
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers \
462-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/gptj ./cmd/grpc/gptj/
462+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/gptj ./backend/go/llm/gptj/
463463

464464
backend-assets/grpc/gptneox: backend-assets/grpc go-ggml-transformers/libtransformers.a
465465
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers \
466-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/gptneox ./cmd/grpc/gptneox/
466+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/gptneox ./backend/go/llm/gptneox/
467467

468468
backend-assets/grpc/mpt: backend-assets/grpc go-ggml-transformers/libtransformers.a
469469
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers \
470-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/mpt ./cmd/grpc/mpt/
470+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/mpt ./backend/go/llm/mpt/
471471

472472
backend-assets/grpc/replit: backend-assets/grpc go-ggml-transformers/libtransformers.a
473473
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers \
474-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/replit ./cmd/grpc/replit/
474+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/replit ./backend/go/llm/replit/
475475

476476
backend-assets/grpc/falcon-ggml: backend-assets/grpc go-ggml-transformers/libtransformers.a
477477
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers \
478-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/falcon-ggml ./cmd/grpc/falcon-ggml/
478+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/falcon-ggml ./backend/go/llm/falcon-ggml/
479479

480480
backend-assets/grpc/starcoder: backend-assets/grpc go-ggml-transformers/libtransformers.a
481481
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers \
482-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/starcoder ./cmd/grpc/starcoder/
482+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/starcoder ./backend/go/llm/starcoder/
483483

484484
backend-assets/grpc/rwkv: backend-assets/grpc go-rwkv/librwkv.a
485485
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-rwkv LIBRARY_PATH=$(shell pwd)/go-rwkv \
486-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/rwkv ./cmd/grpc/rwkv/
486+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/rwkv ./backend/go/llm/rwkv
487487

488488
backend-assets/grpc/bert-embeddings: backend-assets/grpc go-bert/libgobert.a
489489
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-bert LIBRARY_PATH=$(shell pwd)/go-bert \
490-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/bert-embeddings ./cmd/grpc/bert-embeddings/
490+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/bert-embeddings ./backend/go/llm/bert/
491491

492492
backend-assets/grpc/langchain-huggingface: backend-assets/grpc
493-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/langchain-huggingface ./cmd/grpc/langchain-huggingface/
493+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/langchain-huggingface ./backend/go/llm/langchain/
494494

495495
backend-assets/grpc/stablediffusion: backend-assets/grpc
496496
if [ ! -f backend-assets/grpc/stablediffusion ]; then \
497497
$(MAKE) go-stable-diffusion/libstablediffusion.a; \
498498
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-stable-diffusion/ LIBRARY_PATH=$(shell pwd)/go-stable-diffusion/ \
499-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/stablediffusion ./cmd/grpc/stablediffusion/; \
499+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/stablediffusion ./backend/go/image/; \
500500
fi
501501

502502
backend-assets/grpc/piper: backend-assets/grpc backend-assets/espeak-ng-data go-piper/libpiper_binding.a
503503
CGO_CXXFLAGS="$(PIPER_CGO_CXXFLAGS)" CGO_LDFLAGS="$(PIPER_CGO_LDFLAGS)" LIBRARY_PATH=$(shell pwd)/go-piper \
504-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/piper ./cmd/grpc/piper/
504+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/piper ./backend/go/tts/piper/
505505

506506
backend-assets/grpc/whisper: backend-assets/grpc whisper.cpp/libwhisper.a
507507
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/whisper.cpp LIBRARY_PATH=$(shell pwd)/whisper.cpp \
508-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/whisper ./cmd/grpc/whisper/
508+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/whisper ./backend/go/transcribe/
509509

510510
grpcs: prepare $(GRPC_BACKENDS)

cmd/grpc/bert-embeddings/main.go renamed to backend/go/image/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package main
55
import (
66
"flag"
77

8-
bert "github.com/go-skynet/LocalAI/backend/go/llm/bert"
98
grpc "github.com/go-skynet/LocalAI/pkg/grpc"
109
)
1110

@@ -16,7 +15,7 @@ var (
1615
func main() {
1716
flag.Parse()
1817

19-
if err := grpc.StartServer(*addr, &bert.Embeddings{}); err != nil {
18+
if err := grpc.StartServer(*addr, &StableDiffusion{}); err != nil {
2019
panic(err)
2120
}
2221
}

backend/go/image/stablediffusion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package image
1+
package main
22

33
// This is a wrapper to statisfy the GRPC service interface
44
// It is meant to be used by the main executable that is the server for the specific backend type (falcon, gpt3, etc)

backend/go/llm/bert/bert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package bert
1+
package main
22

33
// This is a wrapper to statisfy the GRPC service interface
44
// It is meant to be used by the main executable that is the server for the specific backend type (falcon, gpt3, etc)

cmd/grpc/rwkv/main.go renamed to backend/go/llm/bert/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ package main
55
import (
66
"flag"
77

8-
rwkv "github.com/go-skynet/LocalAI/backend/go/llm/rwkv"
9-
108
grpc "github.com/go-skynet/LocalAI/pkg/grpc"
119
)
1210

@@ -17,7 +15,7 @@ var (
1715
func main() {
1816
flag.Parse()
1917

20-
if err := grpc.StartServer(*addr, &rwkv.LLM{}); err != nil {
18+
if err := grpc.StartServer(*addr, &Embeddings{}); err != nil {
2119
panic(err)
2220
}
2321
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

backend/go/llm/gpt4all/gpt4all.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gpt4all
1+
package main
22

33
// This is a wrapper to statisfy the GRPC service interface
44
// It is meant to be used by the main executable that is the server for the specific backend type (falcon, gpt3, etc)

cmd/grpc/gpt4all/main.go renamed to backend/go/llm/gpt4all/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ package main
55
import (
66
"flag"
77

8-
gpt4all "github.com/go-skynet/LocalAI/backend/go/llm/gpt4all"
9-
108
grpc "github.com/go-skynet/LocalAI/pkg/grpc"
119
)
1210

@@ -17,7 +15,7 @@ var (
1715
func main() {
1816
flag.Parse()
1917

20-
if err := grpc.StartServer(*addr, &gpt4all.LLM{}); err != nil {
18+
if err := grpc.StartServer(*addr, &LLM{}); err != nil {
2119
panic(err)
2220
}
2321
}

0 commit comments

Comments
 (0)