Skip to content

Commit 302953a

Browse files
committed
minor #1102 [Platform][LmStudio] Add tests (OskarStark)
This PR was merged into the main branch. Discussion ---------- [Platform][LmStudio] Add tests | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Docs? | no | Issues | -- | License | MIT Commits ------- 961481c Add tests for LmStudio platform
2 parents cc7881c + 961481c commit 302953a

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\AI\Platform\Tests\Bridge\LmStudio;
13+
14+
use Symfony\AI\Platform\Bridge\Generic\CompletionsModel;
15+
use Symfony\AI\Platform\Bridge\Generic\EmbeddingsModel;
16+
use Symfony\AI\Platform\Bridge\LmStudio\ModelCatalog;
17+
use Symfony\AI\Platform\Capability;
18+
use Symfony\AI\Platform\ModelCatalog\ModelCatalogInterface;
19+
use Symfony\AI\Platform\Test\ModelCatalogTestCase;
20+
21+
/**
22+
* @author Oskar Stark <[email protected]>
23+
*/
24+
final class ModelCatalogTest extends ModelCatalogTestCase
25+
{
26+
public static function modelsProvider(): iterable
27+
{
28+
yield 'gemma-3-4b-it-qat' => [
29+
'gemma-3-4b-it-qat',
30+
CompletionsModel::class,
31+
[
32+
Capability::INPUT_MESSAGES,
33+
Capability::INPUT_IMAGE,
34+
Capability::OUTPUT_TEXT,
35+
Capability::OUTPUT_STREAMING,
36+
Capability::TOOL_CALLING,
37+
],
38+
];
39+
40+
yield 'text-embedding-nomic-embed-text-v2-moe' => [
41+
'text-embedding-nomic-embed-text-v2-moe',
42+
EmbeddingsModel::class,
43+
[
44+
Capability::INPUT_TEXT,
45+
Capability::EMBEDDINGS,
46+
],
47+
];
48+
}
49+
50+
protected function createModelCatalog(): ModelCatalogInterface
51+
{
52+
return new ModelCatalog();
53+
}
54+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\AI\Platform\Tests\Bridge\LmStudio;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\AI\Platform\Bridge\LmStudio\PlatformFactory;
16+
use Symfony\AI\Platform\Platform;
17+
use Symfony\Component\HttpClient\EventSourceHttpClient;
18+
use Symfony\Component\HttpClient\MockHttpClient;
19+
20+
/**
21+
* @author Oskar Stark <[email protected]>
22+
*/
23+
final class PlatformFactoryTest extends TestCase
24+
{
25+
public function testItCreatesPlatformWithDefaultSettings()
26+
{
27+
$platform = PlatformFactory::create();
28+
29+
$this->assertInstanceOf(Platform::class, $platform);
30+
}
31+
32+
public function testItCreatesPlatformWithCustomBaseUrl()
33+
{
34+
$platform = PlatformFactory::create('http://localhost:8080');
35+
36+
$this->assertInstanceOf(Platform::class, $platform);
37+
}
38+
39+
public function testItCreatesPlatformWithCustomHttpClient()
40+
{
41+
$httpClient = new MockHttpClient();
42+
$platform = PlatformFactory::create('http://localhost:1234', $httpClient);
43+
44+
$this->assertInstanceOf(Platform::class, $platform);
45+
}
46+
47+
public function testItCreatesPlatformWithEventSourceHttpClient()
48+
{
49+
$httpClient = new EventSourceHttpClient(new MockHttpClient());
50+
$platform = PlatformFactory::create('http://localhost:1234', $httpClient);
51+
52+
$this->assertInstanceOf(Platform::class, $platform);
53+
}
54+
}

0 commit comments

Comments
 (0)