Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bfaf51f
chore(deps): bump fastify from 4.8.1 to 4.10.2 (#707)
dependabot[bot] Aug 22, 2024
a0604cc
Revert "chore(deps): bump fastify from 4.8.1 to 4.10.2 (#707)"
Sep 2, 2024
e5ee060
feat: add user agreement about agree collect RTC data (#851)
hqer927 Sep 9, 2024
b5b0039
fix: modify about collect data by batch rtc_uuid (#852)
hqer927 Sep 9, 2024
cec8c64
fix: modify about collect data by batch rtc_uuid (#853)
hqer927 Sep 9, 2024
61658c8
fix: fix when empty userUuids can not query IN (#854)
hqer927 Sep 10, 2024
ac986f1
update: change request parameter
hqer927 Sep 11, 2024
9581bb4
update: change request parameter (#855)
hqer927 Sep 11, 2024
c31de1f
feat: add RoomType.AIClass
hqer927 Dec 17, 2024
a2156b1
Merge branch 'netless-io:main' into main
hqer927 Dec 17, 2024
167ad91
feat: add RoomType.AIClass (#862)
hqer927 Dec 17, 2024
bea4738
Merge branch 'netless-io:main' into main
hqer927 Dec 18, 2024
1679997
Revert "feat: add RoomType.AIClass (#862)"
hqer927 Dec 18, 2024
d35076d
feat: room table add `is_ai` column
hqer927 Dec 18, 2024
fdc6ae3
feat: room table add `is_ai` column (#863)
hqer927 Dec 18, 2024
736e67c
Merge branch 'netless-io:main' into main
hqer927 Dec 18, 2024
fe49576
fix: isAI is non-required
hqer927 Dec 18, 2024
76b5e40
fix: isAI is non-required
hqer927 Dec 26, 2024
993815f
feat: add grade from Use ratings for flat AI room
hqer927 Jan 6, 2025
35984fc
Merge remote-tracking branch 'origin/main'
hqer927 Jan 6, 2025
2d72ae9
Revert "feat: add grade from Use ratings for flat AI room"
hqer927 Jan 6, 2025
ddeaa3e
feat: add grade from Use ratings for flat AI room
hqer927 Jan 6, 2025
64fa32a
feat: add timber_type and config product AI server
hqer927 Jan 14, 2025
99ec1d3
feat: add timber_type and config product AI server (#867)
hqer927 Jan 14, 2025
c4b1cd0
Merge branch 'netless-io:main' into main
hqer927 Jan 16, 2025
f171719
fix: update ai server api result format
hqer927 Jan 16, 2025
e5ebf85
fix: update ai server api result format & extend room list api about …
hqer927 Jan 16, 2025
e80e1b6
fix: fix Status import path
hqer927 Jan 17, 2025
4b70d12
Merge remote-tracking branch 'origin/main'
hqer927 Jan 17, 2025
16410f9
fix: fix ai server processing bug
hqer927 Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ agora:
- productID:
eventType:
secret:
ai:
server_cn: "http://43.131.39.44:8082"
server_en: "http://43.131.39.44:8081"

whiteboard:
app_id:
Expand Down
2 changes: 2 additions & 0 deletions config/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ agora:
- productID:
eventType:
secret:
ai:
server: "http://106.13.114.185:8081"

whiteboard:
app_id: "test/flat-server"
Expand Down
4 changes: 4 additions & 0 deletions src/constants/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ export const Agora = {
enable: config.agora.messageNotification.enable,
events: config.agora.messageNotification.events,
},
ai: {
server_cn: config.agora.ai.server_cn,
server_en: config.agora.ai.server_en,
}
};

export const JWT = {
Expand Down
3 changes: 3 additions & 0 deletions src/dao/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { UserPhoneModel } from "../model/user/Phone";
import { UserSensitiveModel } from "../model/user/Sensitive";
import { UserEmailModel } from "../model/user/Email";
import { UserPmiModel } from "../model/user/Pmi";
import { UserAgreementModel } from "../model/user/Agreement";

export const UserDAO = DAOImplement(UserModel) as ReturnType<DAO<UserModel>>;

Expand All @@ -42,6 +43,8 @@ export const UserSensitiveDAO = DAOImplement(UserSensitiveModel) as ReturnType<

export const UserPmiDAO = DAOImplement(UserPmiModel) as ReturnType<DAO<UserPmiModel>>;

export const UserAgreementDAO = DAOImplement(UserAgreementModel) as ReturnType<DAO<UserAgreementModel>>;

export const RoomDAO = DAOImplement(RoomModel) as ReturnType<DAO<RoomModel>>;

export const RoomUserDAO = DAOImplement(RoomUserModel) as ReturnType<DAO<RoomUserModel>>;
Expand Down
2 changes: 2 additions & 0 deletions src/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { OAuthUsersModel } from "./oauth/oauth-users";
import { UserSensitiveModel } from "./user/Sensitive";
import { UserEmailModel } from "./user/Email";
import { UserPmiModel } from "./user/Pmi";
import { UserAgreementModel } from "./user/Agreement";
import { PartnerModel } from "./partner/Partner";
import { PartnerRoomModel } from "./partner/PartnerRoom";

Expand All @@ -34,6 +35,7 @@ export type Model =
| UserEmailModel
| UserSensitiveModel
| UserPmiModel
| UserAgreementModel
| RoomModel
| RoomUserModel
| RoomPeriodicConfigModel
Expand Down
5 changes: 5 additions & 0 deletions src/model/room/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,9 @@ export class RoomModel extends Content {
default: false,
})
has_record: boolean;

@Column({
default: false,
})
is_ai: boolean;
}
6 changes: 6 additions & 0 deletions src/model/room/RoomUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ export class RoomUserModel extends Content {
})
rtc_uid: string;

@Column({
default: -1,
type: "int",
})
grade: number;

@Index("room_users_is_delete_index")
@Column({
default: false,
Expand Down
26 changes: 26 additions & 0 deletions src/model/user/Agreement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Column, Entity, Index } from "typeorm";
import { Content } from "../Content";

@Entity({
name: "user_agreement",
})
export class UserAgreementModel extends Content {
@Index("user_agreement_user_uuid_uindex", {
unique: true,
})
@Column({
length: 40,
})
user_uuid: string;

@Column({
default: false,
})
is_agree_collect_data: boolean;

@Index("user_agreement_is_delete_index")
@Column({
default: false,
})
is_delete: boolean;
}
2 changes: 2 additions & 0 deletions src/thirdPartyService/TypeORMService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { OAuthSecretsModel } from "../model/oauth/oauth-secrets";
import { OAuthUsersModel } from "../model/oauth/oauth-users";
import { UserEmailModel } from "../model/user/Email";
import { UserPmiModel } from "../model/user/Pmi";
import { UserAgreementModel } from "../model/user/Agreement";
import { PartnerModel } from "../model/partner/Partner";
import { PartnerRoomModel } from "../model/partner/PartnerRoom";

Expand All @@ -44,6 +45,7 @@ export const dataSource = new DataSource({
UserEmailModel,
UserSensitiveModel,
UserPmiModel,
UserAgreementModel,
RoomModel,
RoomUserModel,
RoomPeriodicConfigModel,
Expand Down
4 changes: 4 additions & 0 deletions src/utils/ParseConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ type Config = {
secret: string;
}>;
};
ai: {
server_cn: string;
server_en: string;
}
};
whiteboard: {
app_id: string;
Expand Down
6 changes: 6 additions & 0 deletions src/v1/controller/agora/Router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ import { GenerateRTM } from "./token/RTM";
import { ControllerClass } from "../../../abstract/controller";
import { MessageCallback } from "./message/Callback";
import { RTMCensor } from "./rtm/censor";
import { AgoraAIPing } from "./ai/ping";
import { AgoraAIStart } from "./ai/start";
import { AgoraAIStop } from "./ai/stop";

export const agoraRouters: Readonly<Array<ControllerClass<any, any>>> = Object.freeze([
GenerateRTC,
GenerateRTM,
MessageCallback,
RTMCensor,
AgoraAIPing,
AgoraAIStart,
AgoraAIStop
]);
4 changes: 4 additions & 0 deletions src/v1/controller/agora/ai/const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Agora } from "../../../../constants/Config";

export const AI_SERVER_URL_CN = Agora.ai.server_cn || "http://43.131.39.44:8082";
export const AI_SERVER_URL_EN = Agora.ai.server_en || "http://43.131.39.44:8081";
63 changes: 63 additions & 0 deletions src/v1/controller/agora/ai/ping.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { FastifySchema, Response, ResponseError } from "../../../../types/Server";
import { ax } from "../../../utils/Axios";
import { AbstractController } from "../../../../abstract/controller";
import { Controller } from "../../../../decorator/Controller";
import { AI_SERVER_URL_CN, AI_SERVER_URL_EN } from "./const";
import { Status } from "../../../../constants/Project";

@Controller<RequestType, any>({
method: "post",
path: "agora/ai/ping",
auth: true,
})
export class AgoraAIPing extends AbstractController<RequestType, any> {
public static readonly schema: FastifySchema<RequestType> = {
body: {
type: "object",
required: ["request_id", "channel_name", "language"],
properties: {
request_id: {
type: "string",
},
channel_name: {
type: "string",
},
language: {
type: "string",
}
},
},
};

public async execute(): Promise<Response<any>> {
const { request_id, channel_name, language } = this.body;
const api = language === "zh" ? AI_SERVER_URL_CN : AI_SERVER_URL_EN;
const res = await ax.post<any>(`${api}/ping`, {
request_id,
channel_name
},
{
headers: {
"Content-Type": "application/json"
}
}
)
return {
status: Status.Success,
data: res.data,
}

}

public errorHandler(error: Error): ResponseError {
return this.autoHandlerError(error);
}
}

interface RequestType {
body: {
request_id: string;
channel_name: string;
language: string;
};
}
72 changes: 72 additions & 0 deletions src/v1/controller/agora/ai/start.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { FastifySchema, Response, ResponseError } from "../../../../types/Server";
import { ax } from "../../../utils/Axios";
import { AbstractController } from "../../../../abstract/controller";
import { Controller } from "../../../../decorator/Controller";
import { AI_SERVER_URL_CN, AI_SERVER_URL_EN } from "./const";
import { Status } from "../../../../constants/Project";
@Controller<RequestType, any>({
method: "post",
path: "agora/ai/start",
auth: true,
})
export class AgoraAIStart extends AbstractController<RequestType, any> {
public static readonly schema: FastifySchema<RequestType> = {
body: {
type: "object",
required: ["request_id", "channel_name", "user_uid", "language", "role"],
properties: {
request_id: {
type: "string",
},
channel_name: {
type: "string",
},
user_uid: {
type: "number",
},
language: {
type: "string",
},
role: {
type: "string",
},
},
},
};

public async execute(): Promise<Response<any>> {
const { request_id, channel_name, user_uid, language, role } = this.body;
const api = language === "zh" ? AI_SERVER_URL_CN : AI_SERVER_URL_EN;
const res = await ax.post<any>(`${api}/start`, {
request_id,
channel_name,
user_uid,
timbre_type: role
},
{
headers: {
"Content-Type": "application/json"
}
}
)

return {
status: Status.Success,
data: res.data,
}
}

public errorHandler(error: Error): ResponseError {
return this.autoHandlerError(error);
}
}

interface RequestType {
body: {
request_id: string;
channel_name: string;
user_uid: number;
language: string;
role: string;
};
}
62 changes: 62 additions & 0 deletions src/v1/controller/agora/ai/stop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { FastifySchema, Response, ResponseError } from "../../../../types/Server";
import { ax } from "../../../utils/Axios";
import { AbstractController } from "../../../../abstract/controller";
import { Controller } from "../../../../decorator/Controller";
import { AI_SERVER_URL_CN, AI_SERVER_URL_EN } from "./const";
import { Status } from "../../../../constants/Project";

@Controller<RequestType, any>({
method: "post",
path: "agora/ai/stop",
auth: true,
})
export class AgoraAIStop extends AbstractController<RequestType, any> {
public static readonly schema: FastifySchema<RequestType> = {
body: {
type: "object",
required: ["request_id", "channel_name", "language"],
properties: {
request_id: {
type: "string",
},
channel_name: {
type: "string",
},
language: {
type: "string",
}
},
},
};

public async execute(): Promise<Response<any>> {
const { request_id, channel_name, language } = this.body;
const api = language === "zh" ? AI_SERVER_URL_CN : AI_SERVER_URL_EN;
const res = await ax.post<any>(`${api}/start`, {
request_id,
channel_name,
},
{
headers: {
"Content-Type": "application/json"
}
}
)
return {
status: Status.Success,
data: res.data,
}
}

public errorHandler(error: Error): ResponseError {
return this.autoHandlerError(error);
}
}

interface RequestType {
body: {
request_id: string;
channel_name: string;
language: string;
};
}
4 changes: 4 additions & 0 deletions src/v1/controller/room/Router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { UpdatePeriodic } from "./update/Periodic";
import { RecordStarted } from "./record/Started";
import { RecordStopped } from "./record/Stopped";
import { ControllerClass } from "../../../abstract/controller";
import { SetGrade } from "./grade/Set";
import { GetGrade } from "./grade/Get";

export const roomRouters: Readonly<Array<ControllerClass<any, any>>> = Object.freeze([
CreateOrdinary,
Expand Down Expand Up @@ -53,4 +55,6 @@ export const roomRouters: Readonly<Array<ControllerClass<any, any>>> = Object.fr
RecordAgoraUpdateLayout,
RecordAgoraStopped,
RecordInfo,
SetGrade,
GetGrade
]);
5 changes: 5 additions & 0 deletions src/v1/controller/room/create/Ordinary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export class CreateOrdinary extends AbstractController<RequestType, ResponseType
type: "boolean",
nullable: true,
},
isAI: {
type: "boolean",
nullable: true,
},
},
},
};
Expand Down Expand Up @@ -183,6 +187,7 @@ export interface RequestType {
endTime?: number;
region?: Region;
pmi?: boolean;
isAI?: boolean;
};
}

Expand Down
Loading