Skip to content

Commit c1f30ba

Browse files
committed
squash past, centralize request middleware PR
Signed-off-by: Dave Lee <[email protected]>
1 parent 28a1310 commit c1f30ba

Some content is hidden

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

55 files changed

+481026
-820
lines changed

.bruno/LocalAI Test Requests/vad/vad test audio.bru

Lines changed: 240024 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
meta {
2+
name: vad test too few
3+
type: http
4+
seq: 1
5+
}
6+
7+
post {
8+
url: {{PROTOCOL}}{{HOST}}:{{PORT}}/vad
9+
body: json
10+
auth: none
11+
}
12+
13+
headers {
14+
Content-Type: application/json
15+
}
16+
17+
body:json {
18+
{
19+
"model": "silero-vad",
20+
"audio": []
21+
}
22+
}

aio/cpu/vad.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
backend: silero-vad
2+
name: silero-vad
3+
parameters:
4+
model: silero-vad.onnx
5+
download_files:
6+
- filename: silero-vad.onnx
7+
uri: https://huggingface.co/onnx-community/silero-vad/resolve/main/onnx/model.onnx
8+
sha256: a4a068cd6cf1ea8355b84327595838ca748ec29a25bc91fc82e6c299ccdc5808

aio/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ detect_gpu
129129
detect_gpu_size
130130

131131
PROFILE="${PROFILE:-$GPU_SIZE}" # default to cpu
132-
export MODELS="${MODELS:-/aio/${PROFILE}/embeddings.yaml,/aio/${PROFILE}/rerank.yaml,/aio/${PROFILE}/text-to-speech.yaml,/aio/${PROFILE}/image-gen.yaml,/aio/${PROFILE}/text-to-text.yaml,/aio/${PROFILE}/speech-to-text.yaml,/aio/${PROFILE}/vision.yaml}"
132+
export MODELS="${MODELS:-/aio/${PROFILE}/embeddings.yaml,/aio/${PROFILE}/rerank.yaml,/aio/${PROFILE}/text-to-speech.yaml,/aio/${PROFILE}/image-gen.yaml,/aio/${PROFILE}/text-to-text.yaml,/aio/${PROFILE}/speech-to-text.yaml,/aio/${PROFILE}/vad.yaml,/aio/${PROFILE}/vision.yaml}"
133133

134134
check_vars
135135

aio/gpu-8g/vad.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
backend: silero-vad
2+
name: silero-vad
3+
parameters:
4+
model: silero-vad.onnx
5+
download_files:
6+
- filename: silero-vad.onnx
7+
uri: https://huggingface.co/onnx-community/silero-vad/resolve/main/onnx/model.onnx
8+
sha256: a4a068cd6cf1ea8355b84327595838ca748ec29a25bc91fc82e6c299ccdc5808

aio/intel/vad.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
backend: silero-vad
2+
name: silero-vad
3+
parameters:
4+
model: silero-vad.onnx
5+
download_files:
6+
- filename: silero-vad.onnx
7+
uri: https://huggingface.co/onnx-community/silero-vad/resolve/main/onnx/model.onnx
8+
sha256: a4a068cd6cf1ea8355b84327595838ca748ec29a25bc91fc82e6c299ccdc5808

core/application/startup.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,7 @@ func New(opts ...config.AppOption) (*Application, error) {
145145

146146
if options.LoadToMemory != nil {
147147
for _, m := range options.LoadToMemory {
148-
cfg, err := application.BackendLoader().LoadBackendConfigFileByName(m, options.ModelPath,
149-
config.LoadOptionDebug(options.Debug),
150-
config.LoadOptionThreads(options.Threads),
151-
config.LoadOptionContextSize(options.ContextSize),
152-
config.LoadOptionF16(options.F16),
153-
config.ModelPath(options.ModelPath),
154-
)
148+
cfg, err := application.BackendLoader().LoadBackendConfigFileByNameDefaultOptions(m, options)
155149
if err != nil {
156150
return nil, err
157151
}

core/backend/llm.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type TokenUsage struct {
3333
TimingTokenGeneration float64
3434
}
3535

36-
func ModelInference(ctx context.Context, s string, messages []schema.Message, images, videos, audios []string, loader *model.ModelLoader, c config.BackendConfig, o *config.ApplicationConfig, tokenCallback func(string, TokenUsage) bool) (func() (LLMResponse, error), error) {
36+
func ModelInference(ctx context.Context, s string, messages []schema.Message, images, videos, audios []string, loader *model.ModelLoader, c *config.BackendConfig, o *config.ApplicationConfig, tokenCallback func(string, TokenUsage) bool) (func() (LLMResponse, error), error) {
3737
modelFile := c.Model
3838

3939
// Check if the modelFile exists, if it doesn't try to load it from the gallery
@@ -48,7 +48,7 @@ func ModelInference(ctx context.Context, s string, messages []schema.Message, im
4848
}
4949
}
5050

51-
opts := ModelOptions(c, o)
51+
opts := ModelOptions(*c, o)
5252
inferenceModel, err := loader.Load(opts...)
5353
if err != nil {
5454
return nil, err
@@ -84,7 +84,7 @@ func ModelInference(ctx context.Context, s string, messages []schema.Message, im
8484

8585
// in GRPC, the backend is supposed to answer to 1 single token if stream is not supported
8686
fn := func() (LLMResponse, error) {
87-
opts := gRPCPredictOpts(c, loader.ModelPath)
87+
opts := gRPCPredictOpts(*c, loader.ModelPath)
8888
opts.Prompt = s
8989
opts.Messages = protoMessages
9090
opts.UseTokenizerTemplate = c.TemplateConfig.UseTokenizerTemplate

core/backend/rerank.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99
model "github.com/mudler/LocalAI/pkg/model"
1010
)
1111

12-
func Rerank(modelFile string, request *proto.RerankRequest, loader *model.ModelLoader, appConfig *config.ApplicationConfig, backendConfig config.BackendConfig) (*proto.RerankResult, error) {
13-
14-
opts := ModelOptions(backendConfig, appConfig, model.WithModel(modelFile))
12+
func Rerank(request *proto.RerankRequest, loader *model.ModelLoader, appConfig *config.ApplicationConfig, backendConfig config.BackendConfig) (*proto.RerankResult, error) {
13+
opts := ModelOptions(backendConfig, appConfig)
1514
rerankModel, err := loader.Load(opts...)
15+
1616
if err != nil {
1717
return nil, err
1818
}

core/backend/soundgeneration.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
)
1414

1515
func SoundGeneration(
16-
modelFile string,
1716
text string,
1817
duration *float32,
1918
temperature *float32,
@@ -25,8 +24,9 @@ func SoundGeneration(
2524
backendConfig config.BackendConfig,
2625
) (string, *proto.Result, error) {
2726

28-
opts := ModelOptions(backendConfig, appConfig, model.WithModel(modelFile))
27+
opts := ModelOptions(backendConfig, appConfig)
2928
soundGenModel, err := loader.Load(opts...)
29+
3030
if err != nil {
3131
return "", nil, err
3232
}
@@ -44,7 +44,7 @@ func SoundGeneration(
4444

4545
res, err := soundGenModel.SoundGeneration(context.Background(), &proto.SoundGenerationRequest{
4646
Text: text,
47-
Model: modelFile,
47+
Model: backendConfig.Model,
4848
Dst: filePath,
4949
Sample: doSample,
5050
Duration: duration,

0 commit comments

Comments
 (0)