diff --git a/vetti-admin/src/main/java/com/vetti/socket/ChatWebSocketHandler.java b/vetti-admin/src/main/java/com/vetti/socket/ChatWebSocketHandler.java index c0e1c41..a0a52ca 100644 --- a/vetti-admin/src/main/java/com/vetti/socket/ChatWebSocketHandler.java +++ b/vetti-admin/src/main/java/com/vetti/socket/ChatWebSocketHandler.java @@ -179,7 +179,7 @@ public class ChatWebSocketHandler { } Map mapEntity = new HashMap<>(); mapEntity.put("role","system"); - mapEntity.put("content","You are an interviewer. Generate follow-up questions based on Construction Labourer candidate responses.Return Only One Question"); + mapEntity.put("content","You are an interviewer. Generate follow-up questions based on Construction Labourer candidate responses.Only return one question and do not repeat the previously returned questions \\n MPORTANT: Do not ask the same question again if the answer is incorrect"); List> list = new LinkedList(); list.add(mapEntity); promptJson = JSONUtil.toJsonStr(list); @@ -313,7 +313,7 @@ public class ChatWebSocketHandler { } log.info("结束AI提示词为:{}",promptJson); ChatGPTClient gptClient = SpringUtils.getBean(ChatGPTClient.class); - String resultMsg = gptClient.handleAiChat(promptJson); + String resultMsg = gptClient.handleAiChat(promptJson,"QA"); Map resultEntity = new HashMap<>(); resultEntity.put("msg", resultMsg); resultEntity.put("dataType","score"); diff --git a/vetti-admin/src/main/java/com/vetti/web/controller/ai/AiCommonController.java b/vetti-admin/src/main/java/com/vetti/web/controller/ai/AiCommonController.java index ebc1fa0..f55cda7 100644 --- a/vetti-admin/src/main/java/com/vetti/web/controller/ai/AiCommonController.java +++ b/vetti-admin/src/main/java/com/vetti/web/controller/ai/AiCommonController.java @@ -59,7 +59,7 @@ public class AiCommonController extends BaseController @GetMapping("/handleAiChat") public AjaxResult handleAiChat(@RequestParam String text) { - String resultMsg = chatGPTClient.handleAiChat(text); + String resultMsg = chatGPTClient.handleAiChat(text,"QA"); return AjaxResult.success(resultMsg); } diff --git a/vetti-admin/src/main/java/com/vetti/web/controller/system/SysProfileController.java b/vetti-admin/src/main/java/com/vetti/web/controller/system/SysProfileController.java index 5c052f7..46e2583 100644 --- a/vetti-admin/src/main/java/com/vetti/web/controller/system/SysProfileController.java +++ b/vetti-admin/src/main/java/com/vetti/web/controller/system/SysProfileController.java @@ -80,7 +80,7 @@ public class SysProfileController extends BaseController /** * 修改用户 */ - @ApiOperation("个人信息完善") + @ApiOperation("个人信息完善(按照步骤完善信息)") @Log(title = "个人信息完善", businessType = BusinessType.UPDATE) @PutMapping("/completeInfo") public R personalInfoProfile(@RequestBody SysUser user) @@ -107,12 +107,25 @@ public class SysProfileController extends BaseController currentUser.setSteps(user.getSteps()); if (userService.updateUserProfile(currentUser) > 0) { + loginUser.setUser(currentUser); // 更新缓存用户信息 tokenService.setLoginUser(loginUser); } return R.ok(); } + /** + * 个人信息修改 + */ + @ApiOperation("个人信息修改") + @Log(title = "个人信息修改", businessType = BusinessType.UPDATE) + @PutMapping("/updatePersonalInfo") + public R updatePersonalInfoProfile(@RequestBody SysUser user) + { + userService.updateUserProfile(user); + return R.ok(); + } + /** * 修改用户 diff --git a/vetti-admin/src/main/resources/application-druid.yml b/vetti-admin/src/main/resources/application-druid.yml index b1670f7..ebc82af 100644 --- a/vetti-admin/src/main/resources/application-druid.yml +++ b/vetti-admin/src/main/resources/application-druid.yml @@ -169,7 +169,8 @@ whisper: chatGpt: apiKey: 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 apiUrl: https://api.openai.com/v1/chat/completions - model: ft:gpt-3.5-turbo-0125:vetti:construction-labourer-test:CWKBNvE2 + model: ft:gpt-3.5-turbo-0125:vetti:construction-labourer-test:CTIvLD5n + modelCV: ft:gpt-3.5-turbo-0125:vetti:vetti-resume-test:CWPinJQq role: system diff --git a/vetti-admin/target/classes/application-druid.yml b/vetti-admin/target/classes/application-druid.yml index b1670f7..ebc82af 100644 --- a/vetti-admin/target/classes/application-druid.yml +++ b/vetti-admin/target/classes/application-druid.yml @@ -169,7 +169,8 @@ whisper: chatGpt: apiKey: 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 apiUrl: https://api.openai.com/v1/chat/completions - model: ft:gpt-3.5-turbo-0125:vetti:construction-labourer-test:CWKBNvE2 + model: ft:gpt-3.5-turbo-0125:vetti:construction-labourer-test:CTIvLD5n + modelCV: ft:gpt-3.5-turbo-0125:vetti:vetti-resume-test:CWPinJQq role: system diff --git a/vetti-common/src/main/java/com/vetti/common/ai/gpt/ChatGPTClient.java b/vetti-common/src/main/java/com/vetti/common/ai/gpt/ChatGPTClient.java index 46189f5..521a99f 100644 --- a/vetti-common/src/main/java/com/vetti/common/ai/gpt/ChatGPTClient.java +++ b/vetti-common/src/main/java/com/vetti/common/ai/gpt/ChatGPTClient.java @@ -33,6 +33,9 @@ public class ChatGPTClient { @Value("${chatGpt.model}") private String model; + @Value("${chatGpt.modelCV}") + private String modelCV; + @Value("${chatGpt.role}") private String role; @@ -42,7 +45,7 @@ public class ChatGPTClient { * @param promptText 文字提示信息 * @return */ - public String handleAiChat(String promptText) { + public String handleAiChat(String promptText,String type) { String resultText = ""; // 创建ChatGPT客户端 // HTTP客户端 @@ -54,7 +57,14 @@ public class ChatGPTClient { ObjectMapper objectMapper = new ObjectMapper();; // 单轮对话返回结果 try { - resultText = sendMessage(promptText, model,objectMapper,client,role); + if("CV".equals(type)){ + resultText = sendMessage(promptText, modelCV,objectMapper,client,role); + }else if("QA".equals(type)){ + resultText = sendMessage(promptText, "ft:gpt-3.5-turbo-0125:vetti:construction-labourer-test:CWKBNvE2",objectMapper,client,role); + } else { + resultText = sendMessage(promptText, model,objectMapper,client,role); + } + } catch (IOException | InterruptedException e) { System.err.println("单轮对话出错: " + e.getMessage()); } diff --git a/vetti-common/src/main/java/com/vetti/common/utils/readText/vo/PersonalInfo.java b/vetti-common/src/main/java/com/vetti/common/utils/readText/vo/PersonalInfo.java index de792d3..69dfef0 100644 --- a/vetti-common/src/main/java/com/vetti/common/utils/readText/vo/PersonalInfo.java +++ b/vetti-common/src/main/java/com/vetti/common/utils/readText/vo/PersonalInfo.java @@ -1,5 +1,6 @@ package com.vetti.common.utils.readText.vo; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.experimental.Accessors; @@ -15,8 +16,13 @@ import java.util.List; @Accessors(chain = true) public class PersonalInfo { + @ApiModelProperty("候选人姓名") private String name; + @ApiModelProperty("候选人职位") + private String position; + + @ApiModelProperty("工作年限") private int experienceYears; private List certifications; diff --git a/vetti-common/src/main/java/com/vetti/common/utils/readText/vo/ResumeData.java b/vetti-common/src/main/java/com/vetti/common/utils/readText/vo/ResumeData.java index 4533a5f..9023e34 100644 --- a/vetti-common/src/main/java/com/vetti/common/utils/readText/vo/ResumeData.java +++ b/vetti-common/src/main/java/com/vetti/common/utils/readText/vo/ResumeData.java @@ -1,5 +1,6 @@ package com.vetti.common.utils.readText.vo; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.experimental.Accessors; @@ -15,11 +16,15 @@ import java.util.List; @Accessors(chain = true) public class ResumeData { + @ApiModelProperty("候选人基础信息") private PersonalInfo personalInfo; + @ApiModelProperty("候选人工作经验") private List workExperience; + @ApiModelProperty("候选人技能") private List skills; + @ApiModelProperty("候选人教育经历") private List education; } diff --git a/vetti-hotakes/src/main/java/com/vetti/hotake/mapper/HotakeProblemBaseInfoMapper.java b/vetti-hotakes/src/main/java/com/vetti/hotake/mapper/HotakeProblemBaseInfoMapper.java index da8635f..25a2679 100644 --- a/vetti-hotakes/src/main/java/com/vetti/hotake/mapper/HotakeProblemBaseInfoMapper.java +++ b/vetti-hotakes/src/main/java/com/vetti/hotake/mapper/HotakeProblemBaseInfoMapper.java @@ -66,4 +66,12 @@ public interface HotakeProblemBaseInfoMapper */ public int batchInsertHotakeProblemBaseInfo(List hotakeProblemBaseInfoList); + /** + * 删除面试者问题库信息 + * + * @param userId 面试者ID + * @return 结果 + */ + public int deleteHotakeProblemBaseInfoByUserId(Long userId); + } diff --git a/vetti-hotakes/src/main/java/com/vetti/hotake/service/IHotakeProblemBaseInfoService.java b/vetti-hotakes/src/main/java/com/vetti/hotake/service/IHotakeProblemBaseInfoService.java index 4146e1f..b95a5a9 100644 --- a/vetti-hotakes/src/main/java/com/vetti/hotake/service/IHotakeProblemBaseInfoService.java +++ b/vetti-hotakes/src/main/java/com/vetti/hotake/service/IHotakeProblemBaseInfoService.java @@ -67,4 +67,12 @@ public interface IHotakeProblemBaseInfoService */ public int batchInsertHotakeProblemBaseInfo(List hotakeProblemBaseInfoList); + /** + * 删除面试者问题库信息信息 + * + * @param userId 面试者用户ID + * @return 结果 + */ + public int deleteHotakeProblemBaseInfoByUserId(Long userId); + } diff --git a/vetti-hotakes/src/main/java/com/vetti/hotake/service/impl/HotakeCvInfoServiceImpl.java b/vetti-hotakes/src/main/java/com/vetti/hotake/service/impl/HotakeCvInfoServiceImpl.java index 9d5de3e..aef84a4 100644 --- a/vetti-hotakes/src/main/java/com/vetti/hotake/service/impl/HotakeCvInfoServiceImpl.java +++ b/vetti-hotakes/src/main/java/com/vetti/hotake/service/impl/HotakeCvInfoServiceImpl.java @@ -3,14 +3,22 @@ package com.vetti.hotake.service.impl; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; +import java.util.HashMap; +import java.util.LinkedList; import java.util.List; +import java.util.Map; import cn.hutool.json.JSONUtil; +import com.vetti.common.ai.gpt.ChatGPTClient; import com.vetti.common.core.service.BaseServiceImpl; import com.vetti.common.enums.FillTypeEnum; import com.vetti.common.utils.DateUtils; +import com.vetti.common.utils.SecurityUtils; import com.vetti.common.utils.readFile.FileContentUtil; import com.vetti.common.utils.readText.ResumeTextExtractor; +import com.vetti.common.utils.readText.vo.ResumeData; +import com.vetti.hotake.domain.HotakeProblemBaseInfo; +import com.vetti.hotake.service.IHotakeProblemBaseInfoService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -34,6 +42,14 @@ public class HotakeCvInfoServiceImpl extends BaseServiceImpl implements IHotakeC @Autowired private HotakeCvInfoMapper hotakeCvInfoMapper; + @Autowired + private ChatGPTClient chatGPTClient; + + @Autowired + private IHotakeProblemBaseInfoService hotakeProblemBaseInfoService; + + + /** * 查询简历信息 * @@ -73,7 +89,7 @@ public class HotakeCvInfoServiceImpl extends BaseServiceImpl implements IHotakeC fill(FillTypeEnum.INSERT.getCode(),hotakeCvInfo); hotakeCvInfoMapper.insertHotakeCvInfo(hotakeCvInfo); //对简历数据进行处理生成相应的题库数据 -// handleHotakeCvInfo(hotakeCvInfo); + handleHotakeCvInfo(hotakeCvInfo); return hotakeCvInfo; } @@ -85,12 +101,49 @@ public class HotakeCvInfoServiceImpl extends BaseServiceImpl implements IHotakeC @Override public HotakeCvInfo handleHotakeCvInfo(HotakeCvInfo hotakeCvInfo) { try{ - InputStream inputStream = new FileInputStream("/Users/wangxiangshun/Desktop/管报数据/223/Abrar Mohammed Project Manager Resume.docx"); - String contents = FileContentUtil.readFileContent(inputStream,hotakeCvInfo.getCvFileType()); - //进行简历数据提取 - ResumeTextExtractor extractor = new ResumeTextExtractor(); - extractor.extractResumeData(contents,""); - log.info("返回简历基本内容:{}", JSONUtil.toJsonStr(extractor.extractResumeData(contents,""))); +// InputStream inputStream = new FileInputStream("/Users/wangxiangshun/Desktop/管报数据/223/Abrar Mohammed Project Manager Resume.docx"); +// String contents = FileContentUtil.readFileContent(inputStream,hotakeCvInfo.getCvFileType()); +// //进行简历数据提取 +// ResumeTextExtractor extractor = new ResumeTextExtractor(); +// ResumeData resumeData = extractor.extractResumeData(contents,""); +// log.info("返回简历基本内容:{}", resumeData); + //根据简历信息生成初始化问题集合 +// messages: [ +// { +// role: "system", +// content: "You are a construction industry HR expert. Evaluate resumes and provide a score (1-5) and brief recommendation for construction positions." +// }, +// { +// role: "user", +// content: `Position: ${resume.position}\nCandidate: ${resume.candidate}\nExperience: ${resume.experience}\nSkills: ${resume.skills}\nEducation: ${resume.education}\nCertifications: ${resume.certifications}\nSummary: ${resume.summary}` +// } +// ] + //调用AI大模型 +// List> list = new LinkedList(); +// Map mapEntity = new HashMap<>(); +// mapEntity.put("role","system"); +// mapEntity.put("content","You are a construction industry HR expert and experienced interviewer. Evaluate the resume and generate interview questions in one response. Use this exact format:\\n\\nEVALUATION:\\nScore: X/5\\nRecommendation: [recommendation]\\nStrengths: [strengths]\\nConcerns: [concerns]\\n\\nINTERVIEW QUESTIONS:\\nQuestion 1: [question]\\nCategory: [category]\\nReasoning: [reasoning]\\n\\nQuestion 2: [question]\\nCategory: [category]\\nReasoning: [reasoning]"); +// list.add(mapEntity); +// Map mapEntityOne = new HashMap<>(); +// mapEntityOne.put("role","user"); +// mapEntityOne.put("content","Position: Construction Labourer"+ +// "\\nCandidate: "+resumeData.getPersonalInfo().getName()+ +// "\\nExperience: "+resumeData.getPersonalInfo().getExperienceYears()+ +// "\\nSkills: "+JSONUtil.toJsonStr(resumeData.getSkills())+ +// "\\nEducation: "+JSONUtil.toJsonStr(resumeData.getEducation())+ +// "\\nCertifications: "+JSONUtil.toJsonStr(resumeData.getPersonalInfo().getCertifications())+ +// "\\nSummary: Experienced construction worker with strong safety record"); +// list.add(mapEntityOne); +// String promptText = JSONUtil.toJsonStr(list); +// String resultMsg = chatGPTClient.handleAiChat(promptText,"CV"); +// log.info("返回初始化问题:{}",resultMsg); + //生成预设问题记录 + //先删除该用户的预设问题 + hotakeProblemBaseInfoService.deleteHotakeProblemBaseInfoByUserId(SecurityUtils.getUserId()); + HotakeProblemBaseInfo problemBaseInfo = new HotakeProblemBaseInfo(); + problemBaseInfo.setUserId(SecurityUtils.getUserId()); + problemBaseInfo.setContents("Can you provide an example of a situation where you had to work in a physically demanding environment?,How do you plan to handle tasks that require specific construction knowledge or skills that you may not have yet?"); + hotakeProblemBaseInfoService.insertHotakeProblemBaseInfo(problemBaseInfo); }catch (Exception e) { } diff --git a/vetti-hotakes/src/main/java/com/vetti/hotake/service/impl/HotakeProblemBaseInfoServiceImpl.java b/vetti-hotakes/src/main/java/com/vetti/hotake/service/impl/HotakeProblemBaseInfoServiceImpl.java index 545164c..d0ea634 100644 --- a/vetti-hotakes/src/main/java/com/vetti/hotake/service/impl/HotakeProblemBaseInfoServiceImpl.java +++ b/vetti-hotakes/src/main/java/com/vetti/hotake/service/impl/HotakeProblemBaseInfoServiceImpl.java @@ -3,6 +3,7 @@ package com.vetti.hotake.service.impl; import java.util.List; import com.vetti.common.core.service.BaseServiceImpl; +import com.vetti.common.enums.FillTypeEnum; import com.vetti.common.utils.DateUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -61,7 +62,7 @@ public class HotakeProblemBaseInfoServiceImpl extends BaseServiceImpl implements @Override public int insertHotakeProblemBaseInfo(HotakeProblemBaseInfo hotakeProblemBaseInfo) { - hotakeProblemBaseInfo.setCreateTime(DateUtils.getNowDate()); + fill(FillTypeEnum.INSERT.getCode(), hotakeProblemBaseInfo); return hotakeProblemBaseInfoMapper.insertHotakeProblemBaseInfo(hotakeProblemBaseInfo); } @@ -115,4 +116,15 @@ public class HotakeProblemBaseInfoServiceImpl extends BaseServiceImpl implements public int batchInsertHotakeProblemBaseInfo(List hotakeProblemBaseInfoList){ return hotakeProblemBaseInfoMapper.batchInsertHotakeProblemBaseInfo(hotakeProblemBaseInfoList); } + + /** + * 删除面试者问题库信息信息 + * @param userId 面试者用户ID + * @return + */ + @Override + public int deleteHotakeProblemBaseInfoByUserId(Long userId) { + + return hotakeProblemBaseInfoMapper.deleteHotakeProblemBaseInfoByUserId(userId); + } } diff --git a/vetti-hotakes/src/main/resources/mapper/hotake/HotakeProblemBaseInfoMapper.xml b/vetti-hotakes/src/main/resources/mapper/hotake/HotakeProblemBaseInfoMapper.xml index 42764bf..3160b40 100644 --- a/vetti-hotakes/src/main/resources/mapper/hotake/HotakeProblemBaseInfoMapper.xml +++ b/vetti-hotakes/src/main/resources/mapper/hotake/HotakeProblemBaseInfoMapper.xml @@ -81,6 +81,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" delete from hotake_problem_base_info where id = #{id} + + delete from hotake_problem_base_info where user_id = #{userId} + + delete from hotake_problem_base_info where id in diff --git a/vetti-hotakes/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/vetti-hotakes/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index d2d72ed..a932e48 100644 --- a/vetti-hotakes/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/vetti-hotakes/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -1,17 +1,17 @@ com/vetti/hotake/mapper/HotakeCvInfoMapper.class -com/vetti/hotake/service/impl/HotakeSysNoticeServiceImpl.class -com/vetti/hotake/domain/dto/HotakeSysNoticeTypeNameDto.class -com/vetti/hotake/domain/vo/HotakeSysFileVo.class com/vetti/hotake/service/impl/HotakeSysFileServiceImpl.class -com/vetti/hotake/domain/HotakeSysFile.class -com/vetti/hotake/domain/dto/HotakeSysNoticeViewDto.class com/vetti/hotake/domain/dto/HotakeSysFileDto.class com/vetti/hotake/service/IHotakeSysNoticeService.class -com/vetti/hotake/domain/HotakeSysNotice.class com/vetti/hotake/domain/dto/HotakeSysNoticeDto.class com/vetti/hotake/mapper/HotakeSysFileMapper.class com/vetti/hotake/mapper/HotakeSysNoticeMapper.class com/vetti/hotake/domain/HotakeCvInfo.class +com/vetti/hotake/service/impl/HotakeSysNoticeServiceImpl.class +com/vetti/hotake/domain/dto/HotakeSysNoticeTypeNameDto.class +com/vetti/hotake/domain/vo/HotakeSysFileVo.class +com/vetti/hotake/domain/HotakeSysFile.class +com/vetti/hotake/domain/dto/HotakeSysNoticeViewDto.class +com/vetti/hotake/domain/HotakeSysNotice.class com/vetti/hotake/service/IHotakeSysFileService.class com/vetti/hotake/service/impl/HotakeCvInfoServiceImpl.class com/vetti/hotake/service/IHotakeCvInfoService.class