Committing too many files but the app runs possibly with a new model.
This commit is contained in:
@@ -93,17 +93,29 @@ public class EmbeddingService : IEmbeddingService
|
||||
var modelFileName = modelName switch
|
||||
{
|
||||
"sentence-transformers/all-MiniLM-L6-v2" => "all-MiniLM-L6-v2.onnx",
|
||||
"jarredparrett/all-MiniLM-L6-v2_tuned_on_deepparse_address_mutations_comb_3" => "address-embedding-model.onnx",
|
||||
"custom-all-MiniLM-L6-v2-address" => "address-embedding-model.onnx",
|
||||
_ => throw new NotSupportedException($"Model '{modelName}' is not supported for local inference")
|
||||
};
|
||||
|
||||
var modelPath = Path.Combine(AppContext.BaseDirectory, "Models", modelFileName);
|
||||
|
||||
if (!File.Exists(modelPath))
|
||||
// Check multiple possible locations for the model file
|
||||
var possiblePaths = new[]
|
||||
{
|
||||
modelPath = Path.Combine("Models", modelFileName);
|
||||
Path.Combine(AppContext.BaseDirectory, "Models", modelFileName),
|
||||
Path.Combine(AppContext.BaseDirectory, "Models", "Models", modelFileName),
|
||||
Path.Combine("Models", modelFileName),
|
||||
Path.Combine("Models", "Models", modelFileName)
|
||||
};
|
||||
|
||||
foreach (var modelPath in possiblePaths)
|
||||
{
|
||||
if (File.Exists(modelPath))
|
||||
{
|
||||
return modelPath;
|
||||
}
|
||||
}
|
||||
|
||||
return modelPath;
|
||||
throw new FileNotFoundException($"Model file '{modelFileName}' not found. Searched in: {string.Join(", ", possiblePaths)}");
|
||||
}
|
||||
|
||||
public Task<float[]> GenerateEmbeddingAsync(string text, CancellationToken cancellationToken = default)
|
||||
|
||||
Reference in New Issue
Block a user