Skip to content

Commit b193d1e

Browse files
authored
チャット機能のエラーハンドリング強化(添付ファイル送信時の UI フリーズ・会話継続不能を修正) (#1468)
1 parent 491806b commit b193d1e

13 files changed

Lines changed: 369 additions & 247 deletions

File tree

packages/cdk/lambda/utils/bedrockAgentApi.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -388,27 +388,27 @@ const bedrockAgentApi: ApiInterface = {
388388
}
389389
}
390390
} catch (e) {
391+
console.error(e);
391392
if (
392393
e instanceof ThrottlingException ||
393394
e instanceof ServiceQuotaExceededException
394395
) {
395396
yield streamingChunk({
396-
text: 'The server is currently experiencing high access. Please try again later.',
397+
text: '',
397398
stopReason: 'error',
399+
errorCode: 'THROTTLING',
398400
});
399401
} else if (e instanceof DependencyFailedException) {
400-
const modelAccessURL = `https://${process.env.MODEL_REGION}.console.aws.amazon.com/bedrock/home?region=${process.env.MODEL_REGION}#/modelaccess`;
401402
yield streamingChunk({
402-
text: `The selected model is not enabled. Please enable the model in the [Bedrock console Model Access screen](${modelAccessURL}).`,
403+
text: '',
403404
stopReason: 'error',
405+
errorCode: 'ACCESS_DENIED',
404406
});
405407
} else {
406-
console.error(e);
407408
yield streamingChunk({
408-
text:
409-
'An error occurred. Please report the following error to the administrator.\n' +
410-
e,
409+
text: '',
411410
stopReason: 'error',
411+
errorCode: 'UNKNOWN_ERROR',
412412
});
413413
}
414414
}

packages/cdk/lambda/utils/bedrockApi.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,27 +152,27 @@ const bedrockApi: Omit<ApiInterface, 'invokeFlow'> = {
152152
}
153153
}
154154
} catch (e) {
155+
console.error(e);
155156
if (
156157
e instanceof ThrottlingException ||
157158
e instanceof ServiceQuotaExceededException
158159
) {
159160
yield streamingChunk({
160-
text: 'The server is currently experiencing high access. Please try again later.',
161+
text: '',
161162
stopReason: 'error',
163+
errorCode: 'THROTTLING',
162164
});
163165
} else if (e instanceof AccessDeniedException) {
164-
const modelAccessURL = `https://${region}.console.aws.amazon.com/bedrock/home?region=${region}#/modelaccess`;
165166
yield streamingChunk({
166-
text: `The selected model is not enabled. Please enable the model in the [Bedrock console Model Access screen](${modelAccessURL}).`,
167+
text: '',
167168
stopReason: 'error',
169+
errorCode: 'ACCESS_DENIED',
168170
});
169171
} else {
170-
console.error(e);
171172
yield streamingChunk({
172-
text:
173-
'An error occurred. Please report the following error to the administrator.\n' +
174-
e,
173+
text: '',
175174
stopReason: 'error',
175+
errorCode: 'UNKNOWN_ERROR',
176176
});
177177
}
178178
}

packages/cdk/lambda/utils/bedrockKbApi.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,27 +319,27 @@ $output_format_instructions$`;
319319
});
320320
}
321321
} catch (e) {
322+
console.error(e);
322323
if (
323324
e instanceof ThrottlingException ||
324325
e instanceof ServiceQuotaExceededException
325326
) {
326327
yield streamingChunk({
327-
text: 'The server is currently experiencing high access. Please try again later.',
328+
text: '',
328329
stopReason: 'error',
330+
errorCode: 'THROTTLING',
329331
});
330332
} else if (e instanceof DependencyFailedException) {
331-
const modelAccessURL = `https://${process.env.MODEL_REGION}.console.aws.amazon.com/bedrock/home?region=${process.env.MODEL_REGION}#/modelaccess`;
332333
yield streamingChunk({
333-
text: `The selected model is not enabled. Please enable the model in the [Bedrock console Model Access screen](${modelAccessURL}).`,
334+
text: '',
334335
stopReason: 'error',
336+
errorCode: 'ACCESS_DENIED',
335337
});
336338
} else {
337-
console.error(e);
338339
yield streamingChunk({
339-
text:
340-
'An error occurred. Please report the following error to the administrator.\n' +
341-
e,
340+
text: '',
342341
stopReason: 'error',
342+
errorCode: 'UNKNOWN_ERROR',
343343
});
344344
}
345345
}

packages/types/src/protocol.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,18 @@ import { GenerateVideoParams, VideoJob } from './video';
2121
import { ShareId, UserIdAndChatId } from './share';
2222
import { MeetingMinutesCustomPrompt } from './meetingMinutesCustomPrompt';
2323

24+
export type StreamingErrorCode =
25+
| 'THROTTLING'
26+
| 'ACCESS_DENIED'
27+
| 'UNKNOWN_ERROR';
28+
2429
export type StreamingChunk = {
2530
text: string;
2631
trace?: string;
2732
metadata?: Metadata;
2833
stopReason?: StopReason | 'error';
2934
sessionId?: string;
35+
errorCode?: StreamingErrorCode;
3036
};
3137

3238
export type Pagination<T> = {

packages/web/public/locales/translation/en.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,12 @@ drawer:
453453
generative_ai: Generative AI
454454
tools: Tools
455455
use_cases: Use Cases
456+
error:
457+
streamingError:
458+
ACCESS_DENIED: The selected model is not enabled. Please enable the model in the Amazon Bedrock console.
459+
PAYLOAD_TOO_LARGE: The attached file is too large. Please reduce the file size or number of attachments and try again.
460+
THROTTLING: The server is currently experiencing high traffic. Please try again later.
461+
UNKNOWN_ERROR: An error occurred. Please try again or contact the administrator.
456462
feedback:
457463
additional_feedback: If you have any additional feedback, please enter it here. (optional)
458464
reason_error: Please select a reason.

packages/web/public/locales/translation/ja.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,12 @@ drawer:
391391
generative_ai: (生成 AI)
392392
tools: ツール
393393
use_cases: ユースケース
394+
error:
395+
streamingError:
396+
ACCESS_DENIED: 選択されたモデルが有効化されていません。Amazon Bedrock コンソールでモデルを有効化してください。
397+
PAYLOAD_TOO_LARGE: 添付ファイルのサイズが大きすぎます。ファイルサイズまたは添付数を減らして再度お試しください。
398+
THROTTLING: サーバーが混み合っています。しばらく待ってから再度お試しください。
399+
UNKNOWN_ERROR: エラーが発生しました。再度お試しいただくか、管理者にお問い合わせください。
394400
feedback:
395401
additional_feedback: 他にフィードバックがありましたら、入力してください。(任意)
396402
reason_error: 理由を選択してください。

packages/web/public/locales/translation/ko.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,12 @@ drawer:
305305
generative_ai: 생성형 AI
306306
tools: 도구
307307
use_cases: 사용 사례
308+
error:
309+
streamingError:
310+
ACCESS_DENIED: 선택한 모델이 활성화되어 있지 않습니다. Amazon Bedrock 콘솔에서 모델을 활성화해 주세요.
311+
PAYLOAD_TOO_LARGE: 첨부 파일의 크기가 너무 큽니다. 파일 크기 또는 첨부 파일 수를 줄이고 다시 시도해 주세요.
312+
THROTTLING: 서버에 트래픽이 집중되고 있습니다. 잠시 후 다시 시도해 주세요.
313+
UNKNOWN_ERROR: 오류가 발생했습니다. 다시 시도하거나 관리자에게 문의해 주세요.
308314
feedback:
309315
additional_feedback: 추가 피드백이 있으시면 여기에 입력해주세요. (선택사항)
310316
reason_error: 이유를 선택해주세요.

packages/web/public/locales/translation/th.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,12 @@ drawer:
317317
generative_ai: Generative AI
318318
tools: เครื่องมือ
319319
use_cases: Use cases
320+
error:
321+
streamingError:
322+
ACCESS_DENIED: โมเดลที่เลือกยังไม่ได้เปิดใช้งาน กรุณาเปิดใช้งานโมเดลในคอนโซล Amazon Bedrock
323+
PAYLOAD_TOO_LARGE: ไฟล์แนบมีขนาดใหญ่เกินไป กรุณาลดขนาดไฟล์หรือจำนวนไฟล์แนบแล้วลองใหม่อีกครั้ง
324+
THROTTLING: เซิร์ฟเวอร์มีการใช้งานหนาแน่นในขณะนี้ กรุณาลองใหม่อีกครั้งในภายหลัง
325+
UNKNOWN_ERROR: เกิดข้อผิดพลาด กรุณาลองใหม่อีกครั้งหรือติดต่อผู้ดูแลระบบ
320326
feedback:
321327
additional_feedback: หากคุณมีข้อเสนอแนะเพิ่มเติม โปรดป้อนที่นี่ (ไม่บังคับ)
322328
reason_error: โปรดเลือกเหตุผล

packages/web/public/locales/translation/vi.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,12 @@ drawer:
316316
generative_ai: (Generative AI)
317317
tools: Công cụ
318318
use_cases: Use case
319+
error:
320+
streamingError:
321+
ACCESS_DENIED: Mô hình được chọn chưa được kích hoạt. Vui lòng kích hoạt mô hình trong bảng điều khiển Amazon Bedrock.
322+
PAYLOAD_TOO_LARGE: Tệp đính kèm quá lớn. Vui lòng giảm kích thước tệp hoặc số lượng tệp đính kèm và thử lại.
323+
THROTTLING: Máy chủ hiện đang có lưu lượng truy cập cao. Vui lòng thử lại sau.
324+
UNKNOWN_ERROR: Đã xảy ra lỗi. Vui lòng thử lại hoặc liên hệ quản trị viên.
319325
feedback:
320326
additional_feedback: Nếu bạn có phản hồi khác, vui lòng nhập. (tùy chọn)
321327
reason_error: Vui lòng chọn lý do.

packages/web/public/locales/translation/zh.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ drawer:
241241
generative_ai: (生成式 AI)
242242
tools: 工具
243243
use_cases: 用例
244+
error:
245+
streamingError:
246+
ACCESS_DENIED: 所选模型尚未启用。请在 Amazon Bedrock 控制台中启用该模型。
247+
PAYLOAD_TOO_LARGE: 附件文件过大。请减小文件大小或附件数量后重试。
248+
THROTTLING: 服务器当前流量较高。请稍后重试。
249+
UNKNOWN_ERROR: 发生错误。请重试或联系管理员。
244250
feedback:
245251
additional_feedback: 如果您有其他反馈,请输入。(可选)
246252
reason_error: 请选择原因。

0 commit comments

Comments
 (0)