mirror of
https://github.com/mudler/LocalAI.git
synced 2025-06-17 06:28:07 +00:00
Some checks failed
Explorer deployment / build-linux (push) Has been cancelled
GPU tests / ubuntu-latest (1.21.x) (push) Has been cancelled
generate and publish intel docker caches / generate_caches (intel/oneapi-basekit:2025.1.0-0-devel-ubuntu22.04, linux/amd64, ubuntu-latest) (push) Has been cancelled
build container images / hipblas-jobs (-aio-gpu-hipblas, rocm/dev-ubuntu-22.04:6.1, hipblas, true, ubuntu:22.04, extras, latest-gpu-hipblas-extras, latest-aio-gpu-hipblas, --jobs=3 --output-sync=target, linux/amd64, arc-runner-set, auto, -hipblas-extras) (push) Has been cancelled
build container images / hipblas-jobs (rocm/dev-ubuntu-22.04:6.1, hipblas, true, ubuntu:22.04, core, latest-gpu-hipblas, --jobs=3 --output-sync=target, linux/amd64, arc-runner-set, false, -hipblas) (push) Has been cancelled
build container images / self-hosted-jobs (-aio-gpu-intel-f16, quay.io/go-skynet/intel-oneapi-base:latest, sycl_f16, true, ubuntu:22.04, extras, latest-gpu-intel-f16-extras, latest-aio-gpu-intel-f16, --jobs=3 --output-sync=target, linux/amd64, arc-runner-set, false, -sycl-f16-… (push) Has been cancelled
build container images / self-hosted-jobs (-aio-gpu-intel-f32, quay.io/go-skynet/intel-oneapi-base:latest, sycl_f32, true, ubuntu:22.04, extras, latest-gpu-intel-f32-extras, latest-aio-gpu-intel-f32, --jobs=3 --output-sync=target, linux/amd64, arc-runner-set, false, -sycl-f32-… (push) Has been cancelled
build container images / self-hosted-jobs (-aio-gpu-nvidia-cuda-11, ubuntu:22.04, cublas, 11, 7, true, extras, latest-gpu-nvidia-cuda-11-extras, latest-aio-gpu-nvidia-cuda-11, --jobs=3 --output-sync=target, linux/amd64, arc-runner-set, false, -cublas-cuda11-extras) (push) Has been cancelled
build container images / self-hosted-jobs (-aio-gpu-nvidia-cuda-12, ubuntu:22.04, cublas, 12, 0, true, extras, latest-gpu-nvidia-cuda-12-extras, latest-aio-gpu-nvidia-cuda-12, --jobs=3 --output-sync=target, linux/amd64, arc-runner-set, false, -cublas-cuda12-extras) (push) Has been cancelled
build container images / self-hosted-jobs (quay.io/go-skynet/intel-oneapi-base:latest, sycl_f16, true, ubuntu:22.04, core, latest-gpu-intel-f16, --jobs=3 --output-sync=target, linux/amd64, arc-runner-set, false, -sycl-f16) (push) Has been cancelled
build container images / self-hosted-jobs (quay.io/go-skynet/intel-oneapi-base:latest, sycl_f32, true, ubuntu:22.04, core, latest-gpu-intel-f32, --jobs=3 --output-sync=target, linux/amd64, arc-runner-set, false, -sycl-f32) (push) Has been cancelled
build container images / core-image-build (-aio-cpu, ubuntu:22.04, , true, core, latest-cpu, latest-aio-cpu, --jobs=4 --output-sync=target, linux/amd64,linux/arm64, arc-runner-set, false, auto, ) (push) Has been cancelled
build container images / core-image-build (ubuntu:22.04, cublas, 11, 7, true, core, latest-gpu-nvidia-cuda-12, --jobs=4 --output-sync=target, linux/amd64, arc-runner-set, false, false, -cublas-cuda11) (push) Has been cancelled
build container images / core-image-build (ubuntu:22.04, cublas, 12, 0, true, core, latest-gpu-nvidia-cuda-12, --jobs=4 --output-sync=target, linux/amd64, arc-runner-set, false, false, -cublas-cuda12) (push) Has been cancelled
build container images / core-image-build (ubuntu:22.04, vulkan, true, core, latest-gpu-vulkan, --jobs=4 --output-sync=target, linux/amd64, arc-runner-set, false, false, -vulkan) (push) Has been cancelled
build container images / gh-runner (nvcr.io/nvidia/l4t-jetpack:r36.4.0, cublas, 12, 0, true, core, latest-nvidia-l4t-arm64, --jobs=4 --output-sync=target, linux/arm64, ubuntu-24.04-arm, true, false, -nvidia-l4t-arm64) (push) Has been cancelled
Security Scan / tests (push) Has been cancelled
Tests extras backends / tests-transformers (push) Has been cancelled
Tests extras backends / tests-rerankers (push) Has been cancelled
Tests extras backends / tests-diffusers (push) Has been cancelled
Tests extras backends / tests-coqui (push) Has been cancelled
tests / tests-linux (1.21.x) (push) Has been cancelled
tests / tests-aio-container (push) Has been cancelled
tests / tests-apple (1.21.x) (push) Has been cancelled
generate and publish GRPC docker caches / generate_caches (ubuntu:22.04, linux/amd64,linux/arm64, arc-runner-set) (push) Has been cancelled
* Update initializers.go Signed-off-by: kilavvy <140459108+kilavvy@users.noreply.github.com> * Update base.go Signed-off-by: kilavvy <140459108+kilavvy@users.noreply.github.com> --------- Signed-off-by: kilavvy <140459108+kilavvy@users.noreply.github.com>
121 lines
3.1 KiB
Go
121 lines
3.1 KiB
Go
package base
|
|
|
|
// This is a wrapper to satisfy the GRPC service interface
|
|
// It is meant to be used by the main executable that is the server for the specific backend type (falcon, gpt3, etc)
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
pb "github.com/mudler/LocalAI/pkg/grpc/proto"
|
|
gopsutil "github.com/shirou/gopsutil/v3/process"
|
|
)
|
|
|
|
// Base is a base class for all backends to implement
|
|
// Note: the backends that does not support multiple requests
|
|
// should use SingleThread instead
|
|
type Base struct {
|
|
}
|
|
|
|
func (llm *Base) Locking() bool {
|
|
return false
|
|
}
|
|
|
|
func (llm *Base) Lock() {
|
|
panic("not implemented")
|
|
}
|
|
|
|
func (llm *Base) Unlock() {
|
|
panic("not implemented")
|
|
}
|
|
|
|
func (llm *Base) Busy() bool {
|
|
return false
|
|
}
|
|
|
|
func (llm *Base) Load(opts *pb.ModelOptions) error {
|
|
return fmt.Errorf("unimplemented")
|
|
}
|
|
|
|
func (llm *Base) Predict(opts *pb.PredictOptions) (string, error) {
|
|
return "", fmt.Errorf("unimplemented")
|
|
}
|
|
|
|
func (llm *Base) PredictStream(opts *pb.PredictOptions, results chan string) error {
|
|
close(results)
|
|
return fmt.Errorf("unimplemented")
|
|
}
|
|
|
|
func (llm *Base) Embeddings(opts *pb.PredictOptions) ([]float32, error) {
|
|
return []float32{}, fmt.Errorf("unimplemented")
|
|
}
|
|
|
|
func (llm *Base) GenerateImage(*pb.GenerateImageRequest) error {
|
|
return fmt.Errorf("unimplemented")
|
|
}
|
|
|
|
func (llm *Base) GenerateVideo(*pb.GenerateVideoRequest) error {
|
|
return fmt.Errorf("unimplemented")
|
|
}
|
|
|
|
func (llm *Base) AudioTranscription(*pb.TranscriptRequest) (pb.TranscriptResult, error) {
|
|
return pb.TranscriptResult{}, fmt.Errorf("unimplemented")
|
|
}
|
|
|
|
func (llm *Base) TTS(*pb.TTSRequest) error {
|
|
return fmt.Errorf("unimplemented")
|
|
}
|
|
|
|
func (llm *Base) SoundGeneration(*pb.SoundGenerationRequest) error {
|
|
return fmt.Errorf("unimplemented")
|
|
}
|
|
|
|
func (llm *Base) TokenizeString(opts *pb.PredictOptions) (pb.TokenizationResponse, error) {
|
|
return pb.TokenizationResponse{}, fmt.Errorf("unimplemented")
|
|
}
|
|
|
|
// backends may wish to call this to capture the gopsutil info, then enhance with additional memory usage details?
|
|
func (llm *Base) Status() (pb.StatusResponse, error) {
|
|
return pb.StatusResponse{
|
|
Memory: memoryUsage(),
|
|
}, nil
|
|
}
|
|
|
|
func (llm *Base) StoresSet(*pb.StoresSetOptions) error {
|
|
return fmt.Errorf("unimplemented")
|
|
}
|
|
|
|
func (llm *Base) StoresGet(*pb.StoresGetOptions) (pb.StoresGetResult, error) {
|
|
return pb.StoresGetResult{}, fmt.Errorf("unimplemented")
|
|
}
|
|
|
|
func (llm *Base) StoresDelete(*pb.StoresDeleteOptions) error {
|
|
return fmt.Errorf("unimplemented")
|
|
}
|
|
|
|
func (llm *Base) StoresFind(*pb.StoresFindOptions) (pb.StoresFindResult, error) {
|
|
return pb.StoresFindResult{}, fmt.Errorf("unimplemented")
|
|
}
|
|
|
|
func (llm *Base) VAD(*pb.VADRequest) (pb.VADResponse, error) {
|
|
return pb.VADResponse{}, fmt.Errorf("unimplemented")
|
|
}
|
|
|
|
func memoryUsage() *pb.MemoryUsageData {
|
|
mud := pb.MemoryUsageData{
|
|
Breakdown: make(map[string]uint64),
|
|
}
|
|
|
|
pid := int32(os.Getpid())
|
|
|
|
backendProcess, err := gopsutil.NewProcess(pid)
|
|
|
|
if err == nil {
|
|
memInfo, err := backendProcess.MemoryInfo()
|
|
if err == nil {
|
|
mud.Total = memInfo.VMS // TEST, but rss seems reasonable first guess. Does include swap, but we might care about that.
|
|
mud.Breakdown["gopsutil-RSS"] = memInfo.RSS
|
|
}
|
|
}
|
|
return &mud
|
|
}
|