chat请假优化
This commit is contained in:
1 parent
84010c25bf
commit
86f07cdd5b
1 file changed
+24
-20
@@ -569,9 +569,28 @@ const syncLeaveDuration = (form: LeaveRequestFormData) => {
|
|||||||
|
|
||||||
const getLeaveIntentNormalized = (content: string) => (content || '').replace(/\s+/g, '');
|
const getLeaveIntentNormalized = (content: string) => (content || '').replace(/\s+/g, '');
|
||||||
|
|
||||||
const isLeaveIntent = (content: string) => {
|
const isStrongLeaveIntent = (content: string) => {
|
||||||
const normalized = getLeaveIntentNormalized(content);
|
const normalized = getLeaveIntentNormalized(content);
|
||||||
return /(我要请假|申请请假|发起请假|请假申请|我要休假|申请休假|我要请个假|想请假|我要走请假流程|请假流程)/.test(normalized);
|
return /(我要请假|申请请假|发起请假|请假申请|我要休假|申请休假|我要请个假|想请假|我要走请假流程)/.test(normalized);
|
||||||
|
};
|
||||||
|
|
||||||
|
const startLocalLeaveFlow = (content: string) => {
|
||||||
|
const formId = newLocalMessageId('leave-form');
|
||||||
|
const payload: LeaveFormPayload = {
|
||||||
|
formId,
|
||||||
|
form: createLeaveFormData(),
|
||||||
|
submitting: false,
|
||||||
|
confirmationGenerated: false,
|
||||||
|
};
|
||||||
|
messages.value.push({ role: 'user', content, type: 'text' });
|
||||||
|
messages.value.push({
|
||||||
|
role: 'assistant',
|
||||||
|
type: 'leave-form',
|
||||||
|
content: '已为你生成请假申请表,请直接在下方填写并提交。',
|
||||||
|
payload,
|
||||||
|
local_id: formId,
|
||||||
|
local_only: true,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const getLeaveFormPayload = (msg: any): LeaveFormPayload | null => (
|
const getLeaveFormPayload = (msg: any): LeaveFormPayload | null => (
|
||||||
@@ -726,26 +745,11 @@ const handleSend = async (textOrEvent?: string | Event) => {
|
|||||||
// Clear input if sending from input box (not resending/regenerating)
|
// Clear input if sending from input box (not resending/regenerating)
|
||||||
if (typeof textOrEvent !== 'string') input.value = '';
|
if (typeof textOrEvent !== 'string') input.value = '';
|
||||||
|
|
||||||
if (isLeaveIntent(content)) {
|
if (isStrongLeaveIntent(content)) {
|
||||||
const formId = newLocalMessageId('leave-form');
|
startLocalLeaveFlow(content);
|
||||||
const payload: LeaveFormPayload = {
|
|
||||||
formId,
|
|
||||||
form: createLeaveFormData(),
|
|
||||||
submitting: false,
|
|
||||||
confirmationGenerated: false,
|
|
||||||
};
|
|
||||||
messages.value.push({ role: 'user', content, type: 'text' });
|
|
||||||
messages.value.push({
|
|
||||||
role: 'assistant',
|
|
||||||
type: 'leave-form',
|
|
||||||
content: '已为你生成请假申请表,请直接在下方填写并提交。',
|
|
||||||
payload,
|
|
||||||
local_id: formId,
|
|
||||||
local_only: true,
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await sendMessage(content, agentId, selectedKb.value);
|
await sendMessage(content, agentId, selectedKb.value);
|
||||||
|
|
||||||
// 发送完成后刷新历史记录,确保新会话出现
|
// 发送完成后刷新历史记录,确保新会话出现
|
||||||
|
|||||||
Reference in new issue
Block a user