Skip to content

Commit c60add4

Browse files
committed
feat: update ai server about new api
1 parent 5d393ac commit c60add4

File tree

5 files changed

+9145
-1317
lines changed

5 files changed

+9145
-1317
lines changed

packages/flat-server-api/src/agora.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,13 @@ export interface AgoraAIBasePayload {
355355
request_id: string;
356356
channel_name: string;
357357
language: string;
358+
is_new: boolean;
358359
}
359360
export interface AgoraAIStartPayload extends AgoraAIBasePayload {
360361
user_uid: number;
361362
scene: string;
362363
role: string;
364+
bot_id?: number;
363365
}
364366

365367
export interface AgoraAIResult {
@@ -368,36 +370,13 @@ export interface AgoraAIResult {
368370
msg: string;
369371
}
370372
export async function agoraAIStart(payload: AgoraAIStartPayload): Promise<AgoraAIResult> {
371-
// return await fetch("http://43.131.39.44:8082/start", {
372-
// method: "POST",
373-
// body: JSON.stringify({
374-
// request_id: payload.request_id,
375-
// channel_name: payload.channel_name,
376-
// user_uid: payload.user_uid,
377-
// timbre_type: payload.role,
378-
// }),
379-
// }).then(res => {
380-
// return res.json();
381-
// });
382373
return post<AgoraAIStartPayload, AgoraAIResult>("agora/ai/start", payload);
383374
}
384375

385376
export async function agoraAIPing(payload: AgoraAIBasePayload): Promise<any> {
386-
// return await fetch("http://43.131.39.44:8082/ping", {
387-
// method: "POST",
388-
// body: JSON.stringify(payload),
389-
// }).then(res => {
390-
// return res.json();
391-
// });
392377
return post<AgoraAIBasePayload, AgoraAIResult>("agora/ai/ping", payload);
393378
}
394379

395380
export async function agoraAIStop(payload: AgoraAIBasePayload): Promise<AgoraAIResult> {
396-
// return await fetch("http://43.131.39.44:8082/stop", {
397-
// method: "POST",
398-
// body: JSON.stringify(payload),
399-
// }).then(res => {
400-
// return res.json();
401-
// });
402381
return post<AgoraAIBasePayload, AgoraAIResult>("agora/ai/stop", payload);
403382
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { AIChatMsgUser, ChatMsg } from "flat-components";
22
import { makeAutoObservable, observable } from "mobx";
33
import { SideEffectManager } from "side-effect-manager";
4-
import { TIMEOUT_MS } from "./constants";
4+
import { AI_Chat_Bot_ID, TIMEOUT_MS } from "./constants";
55
import { FlatI18n } from "@netless/flat-i18n";
66
import {
77
agoraAIPing,
@@ -71,9 +71,11 @@ export class AIChatStore {
7171
request_id: this.config.ownerUUID,
7272
channel_name: this.config.roomUUID,
7373
user_uid: this.config.rtcUID,
74+
is_new: true,
7475
language,
7576
scene,
7677
role,
78+
bot_id: AI_Chat_Bot_ID,
7779
};
7880
const r = await this.ping();
7981
let bol = true;
@@ -107,6 +109,7 @@ export class AIChatStore {
107109
request_id: this.config.ownerUUID,
108110
channel_name: this.config.roomUUID,
109111
language: this.config.aiInfo.language,
112+
is_new: true,
110113
});
111114
}
112115

@@ -115,6 +118,7 @@ export class AIChatStore {
115118
request_id: this.config.ownerUUID,
116119
channel_name: this.config.roomUUID,
117120
language: this.config.aiInfo.language,
121+
is_new: true,
118122
});
119123
}
120124

packages/flat-stores/src/classroom-store/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ export enum RoomStatusLoadingType {
1111
}
1212

1313
export const TIMEOUT_MS = 5000; // Timeout for incomplete messages
14+
15+
// 历史原因,之前aiBotID是1234(在rtc服务端配置的),现在改成了前端配置.为了保持兼容性,这里保留了1234
16+
export const AI_Chat_Bot_ID = 1234;

0 commit comments

Comments
 (0)