mirror of
https://github.com/mudler/LocalAI.git
synced 2025-12-30 22:20:20 -06:00
- Add a system backend path - Refactor and consolidate system information in system state - Use system state in all the components to figure out the system paths to used whenever needed - Refactor BackendConfig -> ModelConfig. This was otherway misleading as now we do have a backend configuration which is not the model config. Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
35 lines
707 B
Go
35 lines
707 B
Go
package backend
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/mudler/LocalAI/core/config"
|
|
"github.com/mudler/LocalAI/pkg/grpc/proto"
|
|
"github.com/mudler/LocalAI/pkg/model"
|
|
)
|
|
|
|
func Detection(
|
|
sourceFile string,
|
|
loader *model.ModelLoader,
|
|
appConfig *config.ApplicationConfig,
|
|
modelConfig config.ModelConfig,
|
|
) (*proto.DetectResponse, error) {
|
|
opts := ModelOptions(modelConfig, appConfig)
|
|
detectionModel, err := loader.Load(opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer loader.Close()
|
|
|
|
if detectionModel == nil {
|
|
return nil, fmt.Errorf("could not load detection model")
|
|
}
|
|
|
|
res, err := detectionModel.Detect(context.Background(), &proto.DetectOptions{
|
|
Src: sourceFile,
|
|
})
|
|
|
|
return res, err
|
|
}
|