Skip to content

Commit 99ec1d3

Browse files
authored
feat: add timber_type and config product AI server (#867)
1 parent ddeaa3e commit 99ec1d3

File tree

7 files changed

+31
-18
lines changed

7 files changed

+31
-18
lines changed

config/defaults.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ agora:
183183
eventType:
184184
secret:
185185
ai:
186-
server: "http://106.13.114.185:8081"
186+
server_cn: "http://43.131.39.44:8082"
187+
server_en: "http://43.131.39.44:8081"
187188

188189
whiteboard:
189190
app_id:

src/constants/Config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ export const Agora = {
161161
events: config.agora.messageNotification.events,
162162
},
163163
ai: {
164-
server: config.agora.ai.server,
164+
server_cn: config.agora.ai.server_cn,
165+
server_en: config.agora.ai.server_en,
165166
}
166167
};
167168

src/utils/ParseConfig.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ type Config = {
203203
}>;
204204
};
205205
ai: {
206-
server: string;
206+
server_cn: string;
207+
server_en: string;
207208
}
208209
};
209210
whiteboard: {

src/v1/controller/agora/ai/const.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import { Agora } from "../../../../constants/Config";
22

3-
export const AI_SERVER_URL = Agora.ai.server || "http://106.13.114.185:8081";
3+
export const AI_SERVER_URL_CN = Agora.ai.server_cn || "http://43.131.39.44:8082";
4+
export const AI_SERVER_URL_EN = Agora.ai.server_en || "http://43.131.39.44:8081";

src/v1/controller/agora/ai/ping.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { FastifySchema, Response, ResponseError } from "../../../../types/Server
22
import { ax } from "../../../utils/Axios";
33
import { AbstractController } from "../../../../abstract/controller";
44
import { Controller } from "../../../../decorator/Controller";
5-
import { AI_SERVER_URL } from "./const";
5+
import { AI_SERVER_URL_CN, AI_SERVER_URL_EN } from "./const";
66

77
@Controller<RequestType, any>({
88
method: "post",
@@ -13,22 +13,25 @@ export class AgoraAIPing extends AbstractController<RequestType, any> {
1313
public static readonly schema: FastifySchema<RequestType> = {
1414
body: {
1515
type: "object",
16-
required: ["request_id", "channel_name"],
16+
required: ["request_id", "channel_name", "language"],
1717
properties: {
1818
request_id: {
1919
type: "string",
2020
},
2121
channel_name: {
2222
type: "string",
2323
},
24+
language: {
25+
type: "string",
26+
}
2427
},
2528
},
2629
};
2730

2831
public async execute(): Promise<Response<any>> {
29-
const { request_id, channel_name } = this.body;
30-
31-
const res = await ax.post<any>(`${AI_SERVER_URL}/ping`, {
32+
const { request_id, channel_name, language } = this.body;
33+
const api = language === "cn" ? AI_SERVER_URL_CN : AI_SERVER_URL_EN;
34+
const res = await ax.post<any>(`${api}/ping`, {
3235
request_id,
3336
channel_name
3437
},
@@ -51,5 +54,6 @@ interface RequestType {
5154
body: {
5255
request_id: string;
5356
channel_name: string;
57+
language: string;
5458
};
5559
}

src/v1/controller/agora/ai/start.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { FastifySchema, Response, ResponseError } from "../../../../types/Server
22
import { ax } from "../../../utils/Axios";
33
import { AbstractController } from "../../../../abstract/controller";
44
import { Controller } from "../../../../decorator/Controller";
5-
import { AI_SERVER_URL } from "./const";
5+
import { AI_SERVER_URL_CN, AI_SERVER_URL_EN } from "./const";
66

77
@Controller<RequestType, any>({
88
method: "post",
@@ -38,12 +38,13 @@ export class AgoraAIStart extends AbstractController<RequestType, any> {
3838
};
3939

4040
public async execute(): Promise<Response<any>> {
41-
const { request_id, channel_name, user_uid } = this.body;
42-
43-
const res = await ax.post<any>(`${AI_SERVER_URL}/start`, {
41+
const { request_id, channel_name, user_uid, language, role } = this.body;
42+
const api = language === "cn" ? AI_SERVER_URL_CN : AI_SERVER_URL_EN;
43+
const res = await ax.post<any>(`${api}/start`, {
4444
request_id,
4545
channel_name,
4646
user_uid,
47+
timber_type: role
4748
},
4849
{
4950
headers: {

src/v1/controller/agora/ai/stop.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { FastifySchema, Response, ResponseError } from "../../../../types/Server
22
import { ax } from "../../../utils/Axios";
33
import { AbstractController } from "../../../../abstract/controller";
44
import { Controller } from "../../../../decorator/Controller";
5-
import { AI_SERVER_URL } from "./const";
5+
import { AI_SERVER_URL_CN, AI_SERVER_URL_EN } from "./const";
66

77
@Controller<RequestType, any>({
88
method: "post",
@@ -13,22 +13,25 @@ export class AgoraAIStop extends AbstractController<RequestType, any> {
1313
public static readonly schema: FastifySchema<RequestType> = {
1414
body: {
1515
type: "object",
16-
required: ["request_id", "channel_name"],
16+
required: ["request_id", "channel_name", "language"],
1717
properties: {
1818
request_id: {
1919
type: "string",
2020
},
2121
channel_name: {
2222
type: "string",
2323
},
24+
language: {
25+
type: "string",
26+
}
2427
},
2528
},
2629
};
2730

2831
public async execute(): Promise<Response<any>> {
29-
const { request_id, channel_name } = this.body;
30-
31-
const res = await ax.post<any>(`${AI_SERVER_URL}/start`, {
32+
const { request_id, channel_name, language } = this.body;
33+
const api = language === "cn" ? AI_SERVER_URL_CN : AI_SERVER_URL_EN;
34+
const res = await ax.post<any>(`${api}/start`, {
3235
request_id,
3336
channel_name,
3437
},
@@ -50,5 +53,6 @@ interface RequestType {
5053
body: {
5154
request_id: string;
5255
channel_name: string;
56+
language: string;
5357
};
5458
}

0 commit comments

Comments
 (0)