Skip to content

Commit 39497ea

Browse files
committed
[OpenAi][ResultConverter] Enhance the exception message if possible
1 parent 59f1422 commit 39497ea

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/platform/src/Bridge/OpenAi/Embeddings/ResultConverter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\AI\Platform\Bridge\OpenAi\Embeddings;
1515
use Symfony\AI\Platform\Exception\RuntimeException;
1616
use Symfony\AI\Platform\Model;
17+
use Symfony\AI\Platform\Result\RawHttpResult;
1718
use Symfony\AI\Platform\Result\RawResultInterface;
1819
use Symfony\AI\Platform\Result\VectorResult;
1920
use Symfony\AI\Platform\ResultConverterInterface;
@@ -34,6 +35,10 @@ public function convert(RawResultInterface $result, array $options = []): Vector
3435
$data = $result->getData();
3536

3637
if (!isset($data['data'])) {
38+
if ($result instanceof RawHttpResult) {
39+
throw new RuntimeException(\sprintf('Response from OpenAI API does not contain "data" key. StatusCode: "%s". Response: "%s".', $result->getObject()->getStatusCode(), json_encode($result->getData(), \JSON_THROW_ON_ERROR)));
40+
}
41+
3742
throw new RuntimeException('Response does not contain data.');
3843
}
3944

0 commit comments

Comments
 (0)