Skip to content

Commit 617afee

Browse files
committed
feature #777 [Platform] Rename DynamicModelCatalog to FallbackModelCatalog (OskarStark)
This PR was merged into the main branch. Discussion ---------- [Platform] Rename `DynamicModelCatalog` to `FallbackModelCatalog` | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | Docs? | no | Issues | -- | License | MIT The class has been renamed from DynamicModelCatalog to FallbackModelCatalog to better reflect its purpose as a fallback catalog that accepts any model name when a specific catalog is not available. Commits ------- 0cc80b3 Rename DynamicModelCatalog to FallbackModelCatalog
2 parents 4834f03 + 0cc80b3 commit 617afee

File tree

11 files changed

+34
-34
lines changed

11 files changed

+34
-34
lines changed

src/platform/src/Bridge/HuggingFace/ModelCatalog.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
namespace Symfony\AI\Platform\Bridge\HuggingFace;
1313

14-
use Symfony\AI\Platform\ModelCatalog\DynamicModelCatalog;
14+
use Symfony\AI\Platform\ModelCatalog\FallbackModelCatalog;
1515

1616
/**
1717
* @author Oskar Stark <oskarstark@googlemail.com>
1818
*/
19-
final class ModelCatalog extends DynamicModelCatalog
19+
final class ModelCatalog extends FallbackModelCatalog
2020
{
2121
// HuggingFace supports a wide range of models dynamically
2222
// Models are identified by repository/model format (e.g., "microsoft/DialoGPT-medium")

src/platform/src/Bridge/LmStudio/ModelCatalog.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
namespace Symfony\AI\Platform\Bridge\LmStudio;
1313

14-
use Symfony\AI\Platform\ModelCatalog\DynamicModelCatalog;
14+
use Symfony\AI\Platform\ModelCatalog\FallbackModelCatalog;
1515

1616
/**
1717
* @author Oskar Stark <oskarstark@googlemail.com>
1818
*/
19-
final class ModelCatalog extends DynamicModelCatalog
19+
final class ModelCatalog extends FallbackModelCatalog
2020
{
2121
// LmStudio can use any model that is loaded locally
2222
// Models are dynamically available based on what's loaded in LmStudio

src/platform/src/Bridge/OpenRouter/ModelCatalog.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
namespace Symfony\AI\Platform\Bridge\OpenRouter;
1313

14-
use Symfony\AI\Platform\ModelCatalog\DynamicModelCatalog;
14+
use Symfony\AI\Platform\ModelCatalog\FallbackModelCatalog;
1515

1616
/**
1717
* @author Oskar Stark <oskarstark@googlemail.com>
1818
*/
19-
final class ModelCatalog extends DynamicModelCatalog
19+
final class ModelCatalog extends FallbackModelCatalog
2020
{
2121
// OpenRouter provides access to many different models from various providers
2222
// Models are dynamically available and identified by provider/model format

src/platform/src/Bridge/TransformersPhp/ModelCatalog.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
namespace Symfony\AI\Platform\Bridge\TransformersPhp;
1313

14-
use Symfony\AI\Platform\ModelCatalog\DynamicModelCatalog;
14+
use Symfony\AI\Platform\ModelCatalog\FallbackModelCatalog;
1515

1616
/**
1717
* @author Oskar Stark <oskarstark@googlemail.com>
1818
*/
19-
final class ModelCatalog extends DynamicModelCatalog
19+
final class ModelCatalog extends FallbackModelCatalog
2020
{
2121
// TransformersPhp can use various models from HuggingFace
2222
// dynamically loaded through transformers.php library

src/platform/src/ModelCatalog/DynamicModelCatalog.php renamed to src/platform/src/ModelCatalog/FallbackModelCatalog.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111

1212
namespace Symfony\AI\Platform\ModelCatalog;
1313

14-
/*
15-
* A dynamic model catalog that accepts any model name and creates models with all capabilities.
14+
use Symfony\AI\Platform\Capability;
15+
use Symfony\AI\Platform\Model;
16+
17+
/**
18+
* A fallback model catalog that accepts any model name and creates models with all capabilities.
1619
*
1720
* This class is useful for platforms that support a wide range of models dynamically
1821
* without needing to predefine them in a static catalog. Since we don't know what specific
1922
* capabilities each dynamic model supports, we provide all capabilities by default.
2023
*
2124
* @author Oskar Stark <oskarstark@googlemail.com>
2225
*/
23-
use Symfony\AI\Platform\Capability;
24-
use Symfony\AI\Platform\Model;
25-
26-
class DynamicModelCatalog extends AbstractModelCatalog
26+
class FallbackModelCatalog extends AbstractModelCatalog
2727
{
2828
public function __construct()
2929
{

src/platform/src/Test/InMemoryPlatform.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\AI\Platform\Test;
1313

1414
use Symfony\AI\Platform\Model;
15-
use Symfony\AI\Platform\ModelCatalog\DynamicModelCatalog;
15+
use Symfony\AI\Platform\ModelCatalog\FallbackModelCatalog;
1616
use Symfony\AI\Platform\ModelCatalog\ModelCatalogInterface;
1717
use Symfony\AI\Platform\PlatformInterface;
1818
use Symfony\AI\Platform\Result\DeferredResult;
@@ -37,7 +37,7 @@ class InMemoryPlatform implements PlatformInterface
3737
*/
3838
public function __construct(private readonly \Closure|string $mockResult)
3939
{
40-
$this->modelCatalog = new DynamicModelCatalog();
40+
$this->modelCatalog = new FallbackModelCatalog();
4141
}
4242

4343
public function invoke(string $model, array|string|object $input, array $options = []): DeferredResult

src/platform/src/Test/ModelCatalogTestCase.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\AI\Platform\Capability;
1717
use Symfony\AI\Platform\Exception\ModelNotFoundException;
1818
use Symfony\AI\Platform\Model;
19-
use Symfony\AI\Platform\ModelCatalog\DynamicModelCatalog;
19+
use Symfony\AI\Platform\ModelCatalog\FallbackModelCatalog;
2020
use Symfony\AI\Platform\ModelCatalog\ModelCatalogInterface;
2121

2222
/**
@@ -61,8 +61,8 @@ public function testGetModelThrowsExceptionForUnknownModel()
6161
{
6262
$catalog = $this->createModelCatalog();
6363

64-
// Skip this test for catalogs that accept any model (like DynamicModelCatalog)
65-
if ($catalog instanceof DynamicModelCatalog) {
64+
// Skip this test for catalogs that accept any model (like FallbackModelCatalog)
65+
if ($catalog instanceof FallbackModelCatalog) {
6666
$this->markTestSkipped('This catalog accepts any model name');
6767
}
6868

@@ -77,8 +77,8 @@ public function testGetModels()
7777
$catalog = $this->createModelCatalog();
7878
$models = $catalog->getModels();
7979

80-
// Skip this test for catalogs that accept any model (like DynamicModelCatalog)
81-
if ($catalog instanceof DynamicModelCatalog) {
80+
// Skip this test for catalogs that accept any model (like FallbackModelCatalog)
81+
if ($catalog instanceof FallbackModelCatalog) {
8282
$this->markTestSkipped('This catalog accepts any model name');
8383
}
8484

@@ -99,8 +99,8 @@ public function testAllModelsHaveValidClass()
9999
{
100100
$catalog = $this->createModelCatalog();
101101

102-
// Skip this test for catalogs that accept any model (like DynamicModelCatalog)
103-
if ($catalog instanceof DynamicModelCatalog) {
102+
// Skip this test for catalogs that accept any model (like FallbackModelCatalog)
103+
if ($catalog instanceof FallbackModelCatalog) {
104104
$this->markTestSkipped('This catalog accepts any model name');
105105
}
106106

src/platform/tests/Bridge/TransformersPhp/ModelCatalogTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class ModelCatalogTest extends ModelCatalogTestCase
2525
public static function modelsProvider(): iterable
2626
{
2727
// TransformersPhp can use various models from HuggingFace, so we test with example model names
28-
// Since it extends DynamicModelCatalog, all capabilities are provided
28+
// Since it extends FallbackModelCatalog, all capabilities are provided
2929
yield 'microsoft/DialoGPT-medium' => ['microsoft/DialoGPT-medium', Model::class, Capability::cases()];
3030
yield 'sentence-transformers/all-MiniLM-L6-v2' => ['sentence-transformers/all-MiniLM-L6-v2', Model::class, Capability::cases()];
3131
yield 'xenova/text-generation-webui' => ['xenova/text-generation-webui', Model::class, Capability::cases()];

src/platform/tests/DynamicModelCatalogTest.php renamed to src/platform/tests/FallbackModelCatalogTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
use PHPUnit\Framework\TestCase;
1616
use Symfony\AI\Platform\Capability;
1717
use Symfony\AI\Platform\Model;
18-
use Symfony\AI\Platform\ModelCatalog\DynamicModelCatalog;
18+
use Symfony\AI\Platform\ModelCatalog\FallbackModelCatalog;
1919

2020
/**
2121
* @author Oskar Stark <oskarstark@googlemail.com>
2222
*/
23-
final class DynamicModelCatalogTest extends TestCase
23+
final class FallbackModelCatalogTest extends TestCase
2424
{
2525
public function testGetModelReturnsModelWithAllCapabilities()
2626
{
27-
$catalog = new DynamicModelCatalog();
27+
$catalog = new FallbackModelCatalog();
2828
$model = $catalog->getModel('test-model');
2929

3030
$this->assertInstanceOf(Model::class, $model);
@@ -38,7 +38,7 @@ public function testGetModelReturnsModelWithAllCapabilities()
3838

3939
public function testGetModelWithOptions()
4040
{
41-
$catalog = new DynamicModelCatalog();
41+
$catalog = new FallbackModelCatalog();
4242
$model = $catalog->getModel('test-model?temperature=0.7&max_tokens=1000');
4343

4444
$this->assertInstanceOf(Model::class, $model);
@@ -59,7 +59,7 @@ public function testGetModelWithOptions()
5959
#[TestWith(['custom-local-model'])]
6060
public function testGetModelAcceptsAnyModelName(string $modelName)
6161
{
62-
$catalog = new DynamicModelCatalog();
62+
$catalog = new FallbackModelCatalog();
6363
$model = $catalog->getModel($modelName);
6464

6565
$this->assertInstanceOf(Model::class, $model);

src/store/tests/Document/VectorizerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Symfony\AI\Platform\Capability;
1919
use Symfony\AI\Platform\Model;
2020
use Symfony\AI\Platform\ModelCatalog\AbstractModelCatalog;
21-
use Symfony\AI\Platform\ModelCatalog\DynamicModelCatalog;
21+
use Symfony\AI\Platform\ModelCatalog\FallbackModelCatalog;
2222
use Symfony\AI\Platform\PlatformInterface;
2323
use Symfony\AI\Platform\Result\DeferredResult;
2424
use Symfony\AI\Platform\Result\RawResultInterface;
@@ -446,7 +446,7 @@ public function testVectorizeTextDocumentsPassesOptionsToInvoke()
446446
$vector = new Vector([0.1, 0.2, 0.3]);
447447
$options = ['max_tokens' => 1000, 'temperature' => 0.5];
448448

449-
// Use DynamicModelCatalog which provides all capabilities including INPUT_MULTIPLE
449+
// Use FallbackModelCatalog which provides all capabilities including INPUT_MULTIPLE
450450
// This ensures batch mode is used and the test expectation matches the behavior
451451
$platform = PlatformTestHandler::createPlatform(new VectorResult($vector));
452452
$vectorizer = new Vectorizer($platform, 'test-embedding-with-batch');
@@ -464,7 +464,7 @@ public function testVectorizeTextDocumentsWithEmptyOptions()
464464

465465
$vector = new Vector([0.1, 0.2, 0.3]);
466466

467-
// Use DynamicModelCatalog which provides all capabilities including INPUT_MULTIPLE
467+
// Use FallbackModelCatalog which provides all capabilities including INPUT_MULTIPLE
468468
// This ensures batch mode is used and the test expectation matches the behavior
469469
$platform = PlatformTestHandler::createPlatform(new VectorResult($vector));
470470
$vectorizer = new Vectorizer($platform, 'test-embedding-with-batch');

0 commit comments

Comments
 (0)