Skip to content

Commit 26959ca

Browse files
fix: Throw the right exception when onnxruntime is not available
1 parent f536398 commit 26959ca

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Pipelines/Task.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Codewithkyrian\Transformers\Pipelines;
66

7+
use Codewithkyrian\Transformers\Exceptions\ModelExecutionException;
8+
use Codewithkyrian\Transformers\Exceptions\UnsupportedModelTypeException;
79
use Codewithkyrian\Transformers\Models\Auto\AutoModel;
810
use Codewithkyrian\Transformers\Models\Auto\AutoModelForAudioClassification;
911
use Codewithkyrian\Transformers\Models\Auto\AutoModelForCausalLM;
@@ -200,7 +202,7 @@ public function autoModel(
200202
self::AutomaticSpeechRecognition => (function () use ($modelNameOrPath, $quantized, $config, $cacheDir, $revision, $modelFilename, $onProgress) {
201203
try {
202204
return AutoModelForSpeechSeq2Seq::fromPretrained($modelNameOrPath, $quantized, $config, $cacheDir, $revision, $modelFilename, $onProgress);
203-
} catch (\Exception) {
205+
} catch (UnsupportedModelTypeException) {
204206
return AutoModelForCTC::fromPretrained($modelNameOrPath, $quantized, $config, $cacheDir, $revision, $modelFilename, $onProgress);
205207
}
206208
})(),

src/Utils/LibsChecker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static function check($event = null): void
1212
{
1313
$vendorDir = $event !== null ?
1414
$event->getComposer()->getConfig()->get('vendor-dir')
15-
: basePath('vendor');
15+
: 'vendor';
1616

1717
require $vendorDir.'/autoload.php';
1818

0 commit comments

Comments
 (0)