Skip to content

Commit 5434201

Browse files
committed
feature #608 [Platform][Gemini+OpenAI] Show error details to simplify localization of the cause (Guite)
This PR was squashed before being merged into the main branch. Discussion ---------- [Platform][Gemini+OpenAI] Show error details to simplify localization of the cause | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Docs? | no | Issues | | License | MIT Instead of always showing `Response does not contain any content.` or `Response does not contain choices.`, this MR exposes the original error message from Gemini/OpeNAI. For example: `Error 400 - INVALID_ARGUMENT: A schema in GenerationConfig in the request exceeds the maximum allowed nesting depth.`. Commits ------- 42ec4d3 [Platform][Gemini+OpenAI] Show error details to simplify localization of the cause
2 parents 948e670 + 42ec4d3 commit 5434201

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/platform/src/Bridge/Gemini/Gemini/ResultConverter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public function convert(RawResultInterface|RawHttpResult $result, array $options
5656
$data = $result->getData();
5757

5858
if (!isset($data['candidates'][0]['content']['parts'][0])) {
59+
if (isset($data['error'])) {
60+
throw new RuntimeException(\sprintf('Error "%s" - "%s": "%s".', $data['error']['code'], $data['error']['status'], $data['error']['message']));
61+
}
62+
5963
throw new RuntimeException('Response does not contain any content.');
6064
}
6165

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ public function convert(RawResultInterface|RawHttpResult $result, array $options
7979
throw new ContentFilterException($data['error']['message']);
8080
}
8181

82+
if (isset($data['error'])) {
83+
throw new RuntimeException(\sprintf('Error "%s"-%s (%s): "%s".', $data['error']['code'], $data['error']['type'], $data['error']['param'], $data['error']['message']));
84+
}
85+
8286
if (!isset($data['choices'])) {
8387
throw new RuntimeException('Response does not contain choices.');
8488
}

0 commit comments

Comments
 (0)