Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\AI\Platform\Bridge\DockerModelRunner\Completions;
use Symfony\AI\Platform\Exception\ContentFilterException;
use Symfony\AI\Platform\Exception\ExceedContextSizeException;
use Symfony\AI\Platform\Exception\ModelNotFoundException;
use Symfony\AI\Platform\Exception\RuntimeException;
use Symfony\AI\Platform\Model;
use Symfony\AI\Platform\Result\ChoiceResult;
Expand Down Expand Up @@ -46,6 +47,11 @@ public function convert(RawResultInterface|RawHttpResult $result, array $options
return new StreamResult($this->convertStream($result->getObject()));
}

if (404 === $result->getObject()->getStatusCode()
&& str_contains(strtolower($result->getObject()->getContent(false)), 'model not found')) {
throw new ModelNotFoundException($result->getObject()->getContent(false));
}

$data = $result->getData();

if (isset($data['error']['type']) && 'exceed_context_size_error' === $data['error']['type']) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\AI\Platform\Bridge\DockerModelRunner\Embeddings;

use Symfony\AI\Platform\Bridge\DockerModelRunner\Embeddings;
use Symfony\AI\Platform\Exception\ModelNotFoundException;
use Symfony\AI\Platform\Exception\RuntimeException;
use Symfony\AI\Platform\Model;
use Symfony\AI\Platform\Result\RawResultInterface;
Expand All @@ -31,6 +32,11 @@ public function supports(Model $model): bool

public function convert(RawResultInterface $result, array $options = []): VectorResult
{
if (404 === $result->getObject()->getStatusCode()
&& str_contains(strtolower($result->getObject()->getContent(false)), 'model not found')) {
throw new ModelNotFoundException($result->getObject()->getContent(false));
}

$data = $result->getData();

if (!isset($data['data'])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
/**
* @author Mathieu Santostefano <msantostefano@proton.me>
*/
class ExceedContextSizeException extends InvalidArgumentException
class ExceedContextSizeException extends InvalidArgumentException implements ExceptionInterface
{
}
19 changes: 19 additions & 0 deletions src/platform/src/Exception/ModelNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\AI\Platform\Exception;

/**
* @author Mathieu Santostefano <msantostefano@proton.me>
*/
class ModelNotFoundException extends \InvalidArgumentException implements ExceptionInterface
{
}