简历业务逻辑完善
This commit is contained in:
@@ -41,7 +41,7 @@ public interface IHotakeCvInfoService
|
||||
* @param hotakeCvInfo 简历信息
|
||||
* @return 结果
|
||||
*/
|
||||
public HotakeCvInfo handleHotakeCvInfo(HotakeCvInfo hotakeCvInfo);
|
||||
public void handleHotakeCvInfo(HotakeCvInfo hotakeCvInfo);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,17 +8,22 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.enums.MinioBucketNameEnum;
|
||||
import com.vetti.common.utils.DateUtils;
|
||||
import com.vetti.common.utils.SecurityUtils;
|
||||
import com.vetti.common.utils.file.MinioUtil;
|
||||
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 io.minio.GetObjectArgs;
|
||||
import io.minio.MinioClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -28,6 +33,8 @@ import com.vetti.hotake.mapper.HotakeCvInfoMapper;
|
||||
import com.vetti.hotake.domain.HotakeCvInfo;
|
||||
import com.vetti.hotake.service.IHotakeCvInfoService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 简历信息Service业务层处理
|
||||
*
|
||||
@@ -39,12 +46,22 @@ import com.vetti.hotake.service.IHotakeCvInfoService;
|
||||
@Service
|
||||
public class HotakeCvInfoServiceImpl extends BaseServiceImpl implements IHotakeCvInfoService
|
||||
{
|
||||
|
||||
/**
|
||||
* 问题前缀
|
||||
*/
|
||||
private final String QUESTION_PREFIX = "Question:";
|
||||
|
||||
|
||||
@Autowired
|
||||
private HotakeCvInfoMapper hotakeCvInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private ChatGPTClient chatGPTClient;
|
||||
|
||||
@Autowired
|
||||
private MinioClient minioClient;
|
||||
|
||||
@Autowired
|
||||
private IHotakeProblemBaseInfoService hotakeProblemBaseInfoService;
|
||||
|
||||
@@ -99,55 +116,56 @@ public class HotakeCvInfoServiceImpl extends BaseServiceImpl implements IHotakeC
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public HotakeCvInfo handleHotakeCvInfo(HotakeCvInfo hotakeCvInfo) {
|
||||
public void 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();
|
||||
// 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}`
|
||||
// }
|
||||
// ]
|
||||
InputStream inputStream = minioClient.getObject(
|
||||
GetObjectArgs.builder()
|
||||
.bucket(MinioBucketNameEnum.CV.getCode())
|
||||
.object(hotakeCvInfo.getCvUrl())
|
||||
.build());
|
||||
String contents = FileContentUtil.readFileContent(inputStream,hotakeCvInfo.getCvFileType());
|
||||
//进行简历数据提取
|
||||
ResumeTextExtractor extractor = new ResumeTextExtractor();
|
||||
ResumeData resumeData = extractor.extractResumeData(contents,"");
|
||||
log.info("返回简历基本内容:{}", resumeData);
|
||||
//调用AI大模型
|
||||
// List<Map<String,String>> list = new LinkedList();
|
||||
// Map<String,String> 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<String,String> 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);
|
||||
List<Map<String,String>> list = new LinkedList();
|
||||
Map<String,String> mapEntity = new HashMap<>();
|
||||
mapEntity.put("role","system");
|
||||
mapEntity.put("content","You are an experienced interviewer for construction management positions. Generate targeted interview questions based on candidate resumes.");
|
||||
list.add(mapEntity);
|
||||
Map<String,String> mapEntityOne = new HashMap<>();
|
||||
mapEntityOne.put("role","user");
|
||||
mapEntityOne.put("content","Position: Construction Labourer"+
|
||||
"\\nCandidate: "+resumeData.getPersonalInfo().getName()+
|
||||
"\\nKey Skills: "+JSONUtil.toJsonStr(resumeData.getSkills())+
|
||||
"\\nExperience: "+resumeData.getPersonalInfo().getExperienceYears()+"years"+
|
||||
"\\nStrengths: Professional certifications, Relevant experience"+
|
||||
"\\nConcerns: "+JSONUtil.toJsonStr(resumeData.getSummary()));
|
||||
list.add(mapEntityOne);
|
||||
String promptText = JSONUtil.toJsonStr(list);
|
||||
String resultMsg = chatGPTClient.handleAiChat(promptText,"CV");
|
||||
resultMsg = resultMsg.replaceAll("\n","#AA#");
|
||||
String question = "";
|
||||
if(StrUtil.isNotEmpty(resultMsg)){
|
||||
String[] results = resultMsg.split("#AA#");
|
||||
question = results[0].replaceAll(QUESTION_PREFIX,"");
|
||||
if(StrUtil.isEmpty(question)){
|
||||
//设置一个默认值
|
||||
question = "Your professional certifications is impressive. Can you give me a specific example of how this benefited a project?";
|
||||
}
|
||||
}
|
||||
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?");
|
||||
problemBaseInfo.setContents(question);
|
||||
hotakeProblemBaseInfoService.insertHotakeProblemBaseInfo(problemBaseInfo);
|
||||
}catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user