Commit f40fcda
committed
minor #199 [OpenAi][ResultConverter] Enhance the exception message if possible (lyrixx)
This PR was merged into the main branch.
Discussion
----------
[OpenAi][ResultConverter] Enhance the exception message if possible
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| Docs? |
| Issues |
| License | MIT
Before:
```
"exception" => Symfony\AI\Platform\Exception\RuntimeException^ {#736
#message: "Response does not contain data"
#code: 0
#file: "/home/gregoire/dev/github.com/symfony/ai/src/platform/src/Bridge/OpenAI/Embeddings/ResultConverter.php"
#line: 37
trace: {
/home/gregoire/dev/github.com/symfony/ai/src/platform/src/Bridge/OpenAI/Embeddings/ResultConverter.php:37 {
Symfony\AI\Platform\Bridge\OpenAI\Embeddings\ResultConverter->convert(RawResultInterface $result, array $options = []): VectorResult^
› if (!isset($data['data'])) {
› throw new RuntimeException('Response does not contain data');
› }
}
/home/gregoire/dev/github.com/symfony/ai/src/platform/src/Result/ResultPromise.php:48 { …}
/home/gregoire/dev/github.com/symfony/ai/src/platform/src/Result/ResultPromise.php:37 { …}
/home/gregoire/dev/github.com/symfony/ai/src/platform/src/Result/ResultPromise.php:111 { …}
/home/gregoire/dev/github.com/symfony/ai/src/platform/src/Result/ResultPromise.php:90 { …}
./index.php:181 { …}
./index.php:229 { …}
./index.php:259 { …}
}
}
```
After
```
"exception" => Symfony\AI\Platform\Exception\RuntimeException^ {#736
#message: "Response from OpenAI API does not contain "data" key. StatusCode: "429". Response: {"error":{"message":"You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https:\/\/platform.openai.com\/docs\/guides\/error-codes\/api-errors.","type":"insufficient_quota","param":null,"code":"insufficient_quota"}}"
#code: 0
#file: "/home/gregoire/dev/github.com/symfony/ai/src/platform/src/Bridge/OpenAI/Embeddings/ResultConverter.php"
#line: 39
trace: {
/home/gregoire/dev/github.com/symfony/ai/src/platform/src/Bridge/OpenAI/Embeddings/ResultConverter.php:39 {
Symfony\AI\Platform\Bridge\OpenAI\Embeddings\ResultConverter->convert(RawResultInterface $result, array $options = []): VectorResult^
› if ($result instanceof RawHttpResult) {
› throw new RuntimeException(sprintf(
› 'Response from OpenAI API does not contain "data" key. StatusCode: "%s". Response: %s',
}
/home/gregoire/dev/github.com/symfony/ai/src/platform/src/Result/ResultPromise.php:48 { …}
/home/gregoire/dev/github.com/symfony/ai/src/platform/src/Result/ResultPromise.php:37 { …}
/home/gregoire/dev/github.com/symfony/ai/src/platform/src/Result/ResultPromise.php:111 { …}
/home/gregoire/dev/github.com/symfony/ai/src/platform/src/Result/ResultPromise.php:90 { …}
./index.php:181 { …}
./index.php:229 { …}
./index.php:259 { …}
}
}
```
Commits
-------
39497ea [OpenAi][ResultConverter] Enhance the exception message if possibleFile tree
1 file changed
+5
-0
lines changed- src/platform/src/Bridge/OpenAi/Embeddings
1 file changed
+5
-0
lines changedLines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
37 | 42 | | |
38 | 43 | | |
39 | 44 | | |
| |||
0 commit comments