We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a4370dd commit cdf8a43Copy full SHA for cdf8a43
src/v1/chat/completions.ts
@@ -189,8 +189,18 @@ class ChatCompletionsHandler {
189
try {
190
return await operation();
191
} catch (err: any) {
192
- const is_hit_err = retry_error.some((x) => err instanceof x);
193
- if (is_hit_err === false) {
+ let need_retry = true;
+ if (retry_error.some((x) => err instanceof x)) {
194
+ need_retry = false;
195
+ }
196
+ if (
197
+ err instanceof GoogleGenerativeAIResponseError &&
198
+ err.response.promptFeedback.blockReason
199
+ ) {
200
+ // NOTE: 如果 block 了直接退出不需要retry
201
202
203
+ if (need_retry === false) {
204
bail(err);
205
if (err) err.bail = true;
206
}
0 commit comments