mirror of
https://github.com/mudler/LocalAI.git
synced 2025-04-29 23:39:52 +00:00
fix(grpc): pass by modelpath (#4023)
Instead of trying to derive it from the model file. In backends that specify HF url this results in a fragile logic. Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
48d621c64e
commit
61c964dce7
@ -233,6 +233,8 @@ message ModelOptions {
|
|||||||
|
|
||||||
bool FlashAttention = 56;
|
bool FlashAttention = 56;
|
||||||
bool NoKVOffload = 57;
|
bool NoKVOffload = 57;
|
||||||
|
|
||||||
|
string ModelPath = 59;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Result {
|
message Result {
|
||||||
|
@ -301,13 +301,11 @@ class BackendServicer(backend_pb2_grpc.BackendServicer):
|
|||||||
self.pipe.controlnet = self.controlnet
|
self.pipe.controlnet = self.controlnet
|
||||||
else:
|
else:
|
||||||
self.controlnet = None
|
self.controlnet = None
|
||||||
# Assume directory from request.ModelFile.
|
|
||||||
# Only if request.LoraAdapter it's not an absolute path
|
if request.LoraAdapter and not os.path.isabs(request.LoraAdapter):
|
||||||
if request.LoraAdapter and request.ModelFile != "" and not os.path.isabs(request.LoraAdapter) and request.LoraAdapter:
|
|
||||||
# get base path of modelFile
|
|
||||||
modelFileBase = os.path.dirname(request.ModelFile)
|
|
||||||
# modify LoraAdapter to be relative to modelFileBase
|
# modify LoraAdapter to be relative to modelFileBase
|
||||||
request.LoraAdapter = os.path.join(modelFileBase, request.LoraAdapter)
|
request.LoraAdapter = os.path.join(request.ModelPath, request.LoraAdapter)
|
||||||
|
|
||||||
device = "cpu" if not request.CUDA else "cuda"
|
device = "cpu" if not request.CUDA else "cuda"
|
||||||
self.device = device
|
self.device = device
|
||||||
if request.LoraAdapter:
|
if request.LoraAdapter:
|
||||||
|
@ -425,6 +425,7 @@ func (ml *ModelLoader) grpcModel(backend string, autodetect bool, o *Options) fu
|
|||||||
options := *o.gRPCOptions
|
options := *o.gRPCOptions
|
||||||
options.Model = modelName
|
options.Model = modelName
|
||||||
options.ModelFile = modelFile
|
options.ModelFile = modelFile
|
||||||
|
options.ModelPath = ml.ModelPath
|
||||||
|
|
||||||
log.Debug().Msgf("GRPC: Loading model with options: %+v", options)
|
log.Debug().Msgf("GRPC: Loading model with options: %+v", options)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user