|
@@ -12,66 +12,66 @@ export class AgentServerService implements IAgentServerService {
|
|
|
constructor(private readonly httpService: AgentServerHttpService) {}
|
|
|
|
|
|
async listStaffs(): Promise<ServiceResponse<StaffsType[]>> {
|
|
|
- const res = await this.httpService.listStaffs()
|
|
|
- if (res.code !== HttpStatusCode.OK) {
|
|
|
+ const { code, data, msg } = await this.httpService.listStaffs()
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
return {
|
|
|
code: BusinessCode.BAD_REQUEST,
|
|
|
- msg: '获取客服列表失败',
|
|
|
+ msg: msg || '获取客服列表失败',
|
|
|
data: null
|
|
|
}
|
|
|
}
|
|
|
return {
|
|
|
code: BusinessCode.SUCCESS,
|
|
|
msg: '获取客服列表成功',
|
|
|
- data: res.data
|
|
|
+ data: data
|
|
|
}
|
|
|
}
|
|
|
|
|
|
async listScenes(): Promise<ServiceResponse<Scene[]>> {
|
|
|
- const res = await this.httpService.listScenes()
|
|
|
- if (res.code !== HttpStatusCode.OK) {
|
|
|
+ const { code, data, msg } = await this.httpService.listScenes()
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
return {
|
|
|
code: BusinessCode.BAD_REQUEST,
|
|
|
- msg: '获取场景列表失败',
|
|
|
+ msg: msg || '获取场景列表失败',
|
|
|
data: null
|
|
|
}
|
|
|
}
|
|
|
return {
|
|
|
code: BusinessCode.SUCCESS,
|
|
|
msg: '获取场景列表成功',
|
|
|
- data: res.data
|
|
|
+ data: data
|
|
|
}
|
|
|
}
|
|
|
|
|
|
async listModels(): Promise<ServiceResponse<Model[]>> {
|
|
|
- const res = await this.httpService.listModels()
|
|
|
- if (res.code !== HttpStatusCode.OK) {
|
|
|
+ const { code, data, msg } = await this.httpService.listModels()
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
return {
|
|
|
code: BusinessCode.BAD_REQUEST,
|
|
|
- msg: '获取模型列表失败',
|
|
|
+ msg: msg || '获取模型列表失败',
|
|
|
data: null
|
|
|
}
|
|
|
}
|
|
|
return {
|
|
|
code: BusinessCode.SUCCESS,
|
|
|
msg: '获取模型列表成功',
|
|
|
- data: res.data
|
|
|
+ data: data
|
|
|
}
|
|
|
}
|
|
|
|
|
|
async getBasePrompt(scene: string): Promise<ServiceResponse<string>> {
|
|
|
- const res = await this.httpService.getBasePrompt(scene)
|
|
|
- if (res.code !== HttpStatusCode.OK) {
|
|
|
+ const { code, data, msg } = await this.httpService.getBasePrompt(scene)
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
return {
|
|
|
code: BusinessCode.BAD_REQUEST,
|
|
|
- msg: '获取基础提示词失败',
|
|
|
+ msg: msg || '获取基础提示词失败',
|
|
|
data: null
|
|
|
}
|
|
|
}
|
|
|
return {
|
|
|
code: BusinessCode.SUCCESS,
|
|
|
msg: '获取基础提示词成功',
|
|
|
- data: res.data
|
|
|
+ data: data
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -139,41 +139,41 @@ export class AgentServerService implements IAgentServerService {
|
|
|
}
|
|
|
|
|
|
async getUserProfile(userId: string): Promise<ServiceResponse<UserProfile>> {
|
|
|
- const res = await this.httpService.getUserProfile(userId)
|
|
|
- if (res.code !== HttpStatusCode.OK) {
|
|
|
+ const { code, data, msg } = await this.httpService.getUserProfile(userId)
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
return {
|
|
|
code: BusinessCode.BAD_REQUEST,
|
|
|
- msg: '获取用户信息失败',
|
|
|
+ msg: msg || '获取用户信息失败',
|
|
|
data: null
|
|
|
}
|
|
|
}
|
|
|
return {
|
|
|
code: BusinessCode.SUCCESS,
|
|
|
msg: '获取用户信息成功',
|
|
|
- data: res.data
|
|
|
+ data: data
|
|
|
}
|
|
|
}
|
|
|
|
|
|
async getStaffProfile(
|
|
|
staffId: string
|
|
|
): Promise<ServiceResponse<StaffProfile>> {
|
|
|
- const res = await this.httpService.getStaffProfile(staffId)
|
|
|
- if (res.code !== HttpStatusCode.OK) {
|
|
|
+ const { code, data, msg } = await this.httpService.getStaffProfile(staffId)
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
return {
|
|
|
code: BusinessCode.BAD_REQUEST,
|
|
|
- msg: '获取客服信息失败',
|
|
|
+ msg: msg || '获取客服信息失败',
|
|
|
data: null
|
|
|
}
|
|
|
}
|
|
|
return {
|
|
|
code: BusinessCode.SUCCESS,
|
|
|
msg: '获取客服信息成功',
|
|
|
- data: res.data
|
|
|
+ data: data
|
|
|
}
|
|
|
}
|
|
|
|
|
|
async runPrompt(query: RunPromptDto): Promise<ServiceResponse<string>> {
|
|
|
- const res = await this.httpService.runPrompt({
|
|
|
+ const { code, data, msg } = await this.httpService.runPrompt({
|
|
|
scene: query.scene,
|
|
|
prompt: query.prompt,
|
|
|
staff_profile: query.staffProfile,
|
|
@@ -182,18 +182,18 @@ export class AgentServerService implements IAgentServerService {
|
|
|
model_name: query.modelName,
|
|
|
current_timestamp: query.currentTimestamp
|
|
|
})
|
|
|
- console.log(res)
|
|
|
- if (res.code !== HttpStatusCode.OK) {
|
|
|
+ console.log(code, data, msg)
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
return {
|
|
|
code: BusinessCode.BAD_REQUEST,
|
|
|
- msg: '运行提示词失败',
|
|
|
+ msg: msg || '运行提示词失败',
|
|
|
data: null
|
|
|
}
|
|
|
}
|
|
|
return {
|
|
|
code: BusinessCode.SUCCESS,
|
|
|
msg: '运行提示词成功',
|
|
|
- data: res.data
|
|
|
+ data: data
|
|
|
}
|
|
|
}
|
|
|
}
|