|
|
@@ -1055,8 +1055,42 @@ const aiSubmit = async () => {
|
|
1055
|
1055
|
aiLoading.value = true;
|
|
1056
|
1056
|
let text = transcripts.value.map((o) => o.page_content).join('');
|
|
1057
|
1057
|
if (text?.length > 10) {
|
|
1058
|
|
- const tx = `请从以下咨询对话中提取关键信息生成结构化工单:
|
|
1059
|
|
- 咨询对话内容:${text}
|
|
|
1058
|
+ const res = await getSearchDocs(text);
|
|
|
1059
|
+ console.log(res, 'res');
|
|
|
1060
|
+
|
|
|
1061
|
+ res.split('\n').forEach((o) => {
|
|
|
1062
|
+ if (o.startsWith('【内容总结】')) form.value.description = o.replace('【内容总结】', '').replace(':', '');
|
|
|
1063
|
+ // if (o.startsWith('【事件地址】')) form.value.address = o.replace('【事件地址】', '').replace(':', '');
|
|
|
1064
|
+ // if (o.startsWith('【姓名】')) form.value.customerName = o.replace('【姓名】', '').replace(':', '');
|
|
|
1065
|
+
|
|
|
1066
|
+ })
|
|
|
1067
|
+
|
|
|
1068
|
+ aiLoading.value = false;
|
|
|
1069
|
+
|
|
|
1070
|
+ } else {
|
|
|
1071
|
+ aiLoading.value = false;
|
|
|
1072
|
+ }
|
|
|
1073
|
+}
|
|
|
1074
|
+async function getSearchDocs (text) {
|
|
|
1075
|
+ // const params = {
|
|
|
1076
|
+ // query: text,
|
|
|
1077
|
+ // mode: "local_kb",
|
|
|
1078
|
+ // kb_name: "mszsk",
|
|
|
1079
|
+ // top_k: 1,
|
|
|
1080
|
+ // score_threshold: 0.5,
|
|
|
1081
|
+ // stream: true,
|
|
|
1082
|
+ // model: "glm-4",
|
|
|
1083
|
+ // temperature: 0.7,
|
|
|
1084
|
+ // max_tokens: 0,
|
|
|
1085
|
+ // prompt_name: "default",
|
|
|
1086
|
+ // return_direct: false
|
|
|
1087
|
+ // }
|
|
|
1088
|
+ const params = {
|
|
|
1089
|
+ "model": "deepseek-r1:32b",
|
|
|
1090
|
+ "messages": [
|
|
|
1091
|
+ {
|
|
|
1092
|
+ "role": "user",
|
|
|
1093
|
+ "content": `请从以下咨询对话中提取关键信息生成结构化工单:
|
|
1060
|
1094
|
地理位置提取:识别来访者明确提到的居住地或当前位置
|
|
1061
|
1095
|
格式:[省/市/区/街道/楼栋号/房间号](如未提及则标记"未知")
|
|
1062
|
1096
|
注意模糊表述(如"北方城市""江浙地区"等需保留原话)
|
|
|
@@ -1083,50 +1117,40 @@ const aiSubmit = async () => {
|
|
1083
|
1117
|
示例输出:
|
|
1084
|
1118
|
【地理位置】:浙江省杭州市
|
|
1085
|
1119
|
【内容总结】:来访者诉持续三个月失眠症状,伴有社交场合手抖等躯体化表现,提及近期出现惊恐发作经历(地铁喘不过气),社会功能受损(工作受影响)
|
|
1086
|
|
-【工单类型】: 焦虑障碍
|
|
1087
|
|
-`;
|
|
1088
|
|
- const res = await getSearchDocs(tx);
|
|
1089
|
|
- console.log(res, 'res');
|
|
1090
|
|
-
|
|
1091
|
|
- res.split('\n').forEach((o) => {
|
|
1092
|
|
- if (o.startsWith('【内容总结】')) form.value.description = o.replace('【内容总结】', '').replace(':', '');
|
|
1093
|
|
- // if (o.startsWith('【事件地址】')) form.value.address = o.replace('【事件地址】', '').replace(':', '');
|
|
1094
|
|
- // if (o.startsWith('【姓名】')) form.value.customerName = o.replace('【姓名】', '').replace(':', '');
|
|
1095
|
|
-
|
|
1096
|
|
- })
|
|
1097
|
|
-
|
|
1098
|
|
- aiLoading.value = false;
|
|
1099
|
|
-
|
|
1100
|
|
- } else {
|
|
1101
|
|
- aiLoading.value = false;
|
|
1102
|
|
- }
|
|
1103
|
|
-}
|
|
1104
|
|
-async function getSearchDocs (text) {
|
|
1105
|
|
- const params = {
|
|
1106
|
|
- query: text,
|
|
1107
|
|
- mode: "local_kb",
|
|
1108
|
|
- kb_name: "mszsk",
|
|
1109
|
|
- top_k: 1,
|
|
1110
|
|
- score_threshold: 0.5,
|
|
1111
|
|
- stream: true,
|
|
1112
|
|
- model: "glm-4",
|
|
1113
|
|
- temperature: 0.7,
|
|
1114
|
|
- max_tokens: 0,
|
|
1115
|
|
- prompt_name: "default",
|
|
1116
|
|
- return_direct: false
|
|
1117
|
|
- }
|
|
|
1120
|
+【工单类型】: 焦虑障碍`
|
|
|
1121
|
+ }, {
|
|
|
1122
|
+ "role": "user",
|
|
|
1123
|
+ "content": text
|
|
|
1124
|
+ }
|
|
|
1125
|
+ ],
|
|
|
1126
|
+ "stream": true
|
|
|
1127
|
+ };
|
|
1118
|
1128
|
try {
|
|
1119
|
1129
|
// 发送请求
|
|
1120
|
|
- let response = await fetch("http://192.168.1.89:7861/chat/chat",
|
|
1121
|
|
- {
|
|
1122
|
|
- method: "post",
|
|
1123
|
|
- // responseType: "stream",
|
|
1124
|
|
- headers: {
|
|
1125
|
|
- "Content-Type": "application/json",
|
|
1126
|
|
- },
|
|
1127
|
|
- body: JSON.stringify(params),
|
|
1128
|
|
- }
|
|
1129
|
|
- );
|
|
|
1130
|
+ // let response = await fetch("http://192.168.1.89:7861/chat/chat",
|
|
|
1131
|
+ // {
|
|
|
1132
|
+ // method: "post",
|
|
|
1133
|
+ // // responseType: "stream",
|
|
|
1134
|
+ // headers: {
|
|
|
1135
|
+ // "Content-Type": "application/json",
|
|
|
1136
|
+ // },
|
|
|
1137
|
+ // body: JSON.stringify(params),
|
|
|
1138
|
+ // }
|
|
|
1139
|
+ // );
|
|
|
1140
|
+
|
|
|
1141
|
+ const url = import.meta.env.VITE_APP_AI_API || 'https://open.bigmodel.cn/api/paas/v4/chat/completions'
|
|
|
1142
|
+ let response = await fetch(url,
|
|
|
1143
|
+
|
|
|
1144
|
+ {
|
|
|
1145
|
+ method: "post",
|
|
|
1146
|
+ responseType: "stream",
|
|
|
1147
|
+ headers: {
|
|
|
1148
|
+ "Content-Type": "application/json",
|
|
|
1149
|
+ "Authorization": `Bearer ${import.meta.env.VITE_APP_AI_API_KEY}`
|
|
|
1150
|
+ },
|
|
|
1151
|
+ body: JSON.stringify(params),
|
|
|
1152
|
+ }
|
|
|
1153
|
+ );
|
|
1130
|
1154
|
|
|
1131
|
1155
|
let resultStr = '';
|
|
1132
|
1156
|
|