1
This commit is contained in:
@@ -253,6 +253,65 @@ class aiService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 HR 消息判断回复意图并生成内容
|
||||
* @param {object} params - { jobInfo, hrMessage, previousMessages? }
|
||||
* @returns {Promise<{ action: 'text'|'send_resume'|'exchange_wechat'|'exchange_phone', reply_content: string }>}
|
||||
*/
|
||||
async replyIntentAndContent(params) {
|
||||
const { jobInfo = {}, hrMessage = '', previousMessages = [] } = params;
|
||||
const jobName = jobInfo.jobName || jobInfo.title || '未知职位';
|
||||
const companyName = jobInfo.brandName || jobInfo.companyName || '未知公司';
|
||||
|
||||
const prompt = `
|
||||
你正在处理 BOSS 直聘上的求职沟通。根据 HR 最新消息判断求职者应采取的回复动作。
|
||||
|
||||
【职位】${jobName}
|
||||
【公司】${companyName}
|
||||
|
||||
【HR 最新消息】
|
||||
${hrMessage || '(HR 未发文字,仅存在职位卡片等)'}
|
||||
|
||||
请严格按以下 JSON 格式返回(不要包含其他说明或换行):
|
||||
{"action":"动作","reply_content":"内容"}
|
||||
|
||||
action 仅允许以下五种之一:
|
||||
- no_reply:不需要回复(HR 明确表示暂不匹配、感谢关注、有合适机会再沟通、婉拒、不招了等,无需求职者再回复)
|
||||
- text:仅文字回复(普通聊天、打招呼、问是否考虑机会等)
|
||||
- send_resume:发简历(HR 要求发简历、看简历、投递等)
|
||||
- exchange_wechat:换微信(HR 要求加微信、留微信、发微信等)
|
||||
- exchange_phone:换电话(HR 要求留电话、发电话、联系方式等)
|
||||
|
||||
规则:
|
||||
1. 若 HR 明确表示暂不匹配、感谢关注、有合适机会再沟通、与岗位不够匹配、婉拒、不考虑、不招了、已招到 等 → action 为 no_reply,reply_content 留空。
|
||||
2. 若 HR 明确要求发简历/投递/看简历 → action 为 send_resume,reply_content 可为简短附言或空。
|
||||
3. 若 HR 明确要求加微信/留微信/发微信 → action 为 exchange_wechat,reply_content 可为简短附言或空。
|
||||
4. 若 HR 明确要求留电话/发电话/联系方式 → action 为 exchange_phone,reply_content 可为简短附言或空。
|
||||
5. 若仅为普通聊天、打招呼 → action 为 text,reply_content 为一句自然回复(50字以内)。
|
||||
6. reply_content 必须为字符串,不要换行。
|
||||
`.trim();
|
||||
|
||||
const result = await this.callAPI(prompt, {
|
||||
systemPrompt: '你是求职沟通助手。根据 HR 消息判断动作:no_reply(不需要回复)、text(仅文字)、send_resume(发简历)、exchange_wechat(换微信)、exchange_phone(换电话)。HR 婉拒/暂不匹配/感谢关注时用 no_reply。输出 JSON:{"action":"上述五选一","reply_content":"..."}。只返回合法 JSON。',
|
||||
temperature: 0.3,
|
||||
maxTokens: 500,
|
||||
business_type: 'chat_reply_intent',
|
||||
service_type: 'completion'
|
||||
});
|
||||
|
||||
const raw = (result && result.content) ? result.content.trim() : '';
|
||||
const allowed = ['no_reply', 'text', 'send_resume', 'exchange_wechat', 'exchange_phone'];
|
||||
try {
|
||||
const jsonMatch = raw.match(/\{[\s\S]*\}/);
|
||||
const parsed = jsonMatch ? JSON.parse(jsonMatch[0]) : {};
|
||||
const action = allowed.includes(parsed.action) ? parsed.action : 'text';
|
||||
const reply_content = typeof parsed.reply_content === 'string' ? parsed.reply_content.trim() : '';
|
||||
return { action, reply_content };
|
||||
} catch (e) {
|
||||
return { action: 'text', reply_content: raw || '收到,谢谢您。' };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分析简历要素
|
||||
* @param {string} resumeText - 简历文本内容
|
||||
|
||||
Reference in New Issue
Block a user