Skip to content

Commit 2ccda83

Browse files
committed
fix: when qps workers limit give user one friendly tips
1 parent 2d771bf commit 2ccda83

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

packages/flat-i18n/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@
132132
},
133133
"guidance": {
134134
"TurnOffWhiteboard": "Click again to close the whiteboard"
135+
},
136+
"message": {
137+
"100001": "AI conversation demand is too hot, please try again later"
135138
}
136139
},
137140
"room-status": {

packages/flat-i18n/locales/zh-CN.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@
132132
},
133133
"guidance": {
134134
"TurnOffWhiteboard": "再次点击可以关闭白板"
135+
},
136+
"message": {
137+
"10001": "AI对话需求过于火热,请稍后再试"
135138
}
136139
},
137140
"class-room-type": {

packages/flat-stores/src/classroom-store/ai-chat-store.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { AIChatMsgUser, ChatMsg } from "flat-components";
22
import { makeAutoObservable, observable } from "mobx";
33
import { SideEffectManager } from "side-effect-manager";
44
import { TIMEOUT_MS } from "./constants";
5+
import { FlatI18n } from "@netless/flat-i18n";
56
import {
67
agoraAIPing,
78
AgoraAIResult,
@@ -79,11 +80,19 @@ export class AIChatStore {
7980
if (r.code === "10002") {
8081
const res = await agoraAIStart(payload);
8182
if (res.code !== "0") {
82-
throw new Error(`AI service start failed: ${res.msg}`);
83+
if (res.code === "10001") {
84+
throw new Error(FlatI18n.t(`home-page-AI-teacher-class.message.${res.code}`));
85+
} else {
86+
throw new Error(`AI service start failed: ${res.msg}`);
87+
}
8388
}
8489
bol = false;
8590
} else if (r.code !== "0") {
86-
throw new Error(`AI service is ${r.msg}`);
91+
if (r.code === "10001") {
92+
throw new Error(FlatI18n.t(`home-page-AI-teacher-class.message.${r.code}`));
93+
} else {
94+
throw new Error(`AI service is ${r.msg}`);
95+
}
8796
}
8897
this.pingTasker();
8998
return bol;

0 commit comments

Comments
 (0)