mirror of
https://github.com/mudler/LocalAI.git
synced 2026-09-12 22:33:54 -04:00
feat: bound backend admission and expose running traces Add process-wide backend execution admission without blocking UI or administrative HTTP work. Represent backend operations while they are in flight, surface running traces with immediate log links, and tie streaming admission leases to the gRPC receive lifecycle. Assisted-by: OpenAI Codex: GPT-5 Signed-off-by: Richard Palethorpe <io@richiejp.com>
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package backend
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/mudler/LocalAI/core/config"
|
|
"github.com/mudler/LocalAI/pkg/grpc/proto"
|
|
model "github.com/mudler/LocalAI/pkg/model"
|
|
)
|
|
|
|
// ImageUpscale loads the model specified in modelConfig and calls UpscaleImage
|
|
// on the backend, writing the result to dst.
|
|
func ImageUpscale(ctx context.Context, src, dst string, scale int, loader *model.ModelLoader, modelConfig config.ModelConfig, appConfig *config.ApplicationConfig) (func() error, error) {
|
|
opts := ModelOptions(modelConfig, appConfig, model.WithContext(ctx))
|
|
inferenceModel, err := loader.Load(opts...)
|
|
if err != nil {
|
|
recordModelLoadFailure(appConfig, modelConfig.Name, modelConfig.Backend, err, nil)
|
|
return nil, err
|
|
}
|
|
|
|
fn := func() error {
|
|
release, err := AcquireGlobalBackendSlot()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer release()
|
|
_, err = inferenceModel.UpscaleImage(
|
|
ctx,
|
|
&proto.UpscaleImageRequest{
|
|
Src: src,
|
|
Dst: dst,
|
|
Scale: int32(scale),
|
|
},
|
|
)
|
|
return err
|
|
}
|
|
|
|
return fn, nil
|
|
}
|
|
|
|
// ImageUpscaleFunc is a test-friendly indirection.
|
|
var ImageUpscaleFunc = ImageUpscale
|