@3-/aiapi 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/factCheck.js +18 -9
- package/fmtWithFactCheck.js +3 -3
- package/package.json +1 -1
package/factCheck.js
CHANGED
|
@@ -95,13 +95,17 @@ addUrl = (text, items) => {
|
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
txtLi = (txt) => {
|
|
98
|
-
var i, id, msg, pos, r, ref, t, tag, trim;
|
|
98
|
+
var i, id, msg, pos, pre, r, ref, reset, t, tag, trim;
|
|
99
99
|
r = [];
|
|
100
|
+
reset = () => {
|
|
101
|
+
r.push(t);
|
|
102
|
+
pre = t = void 0;
|
|
103
|
+
};
|
|
100
104
|
ref = txt.replaceAll('**', '').split('\n');
|
|
101
105
|
for (i of ref) {
|
|
102
106
|
if (i.startsWith('- id:')) {
|
|
103
107
|
if (t) {
|
|
104
|
-
|
|
108
|
+
reset();
|
|
105
109
|
}
|
|
106
110
|
id = parseInt(i.slice(5).trim());
|
|
107
111
|
if (id) {
|
|
@@ -109,17 +113,22 @@ txtLi = (txt) => {
|
|
|
109
113
|
}
|
|
110
114
|
} else if (t) {
|
|
111
115
|
trim = i.trimStart();
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (pos > 0) {
|
|
118
|
-
tag = trim.slice(0, pos).replace('- ', '').trim();
|
|
116
|
+
pos = trim.indexOf(': ');
|
|
117
|
+
if (pos > 0) {
|
|
118
|
+
tag = trim.slice(0, pos).replace('- ', '').trim();
|
|
119
|
+
if (['标题', '观点', '事实', '失实度'].includes(tag)) {
|
|
120
|
+
pre = tag;
|
|
119
121
|
msg = trim.slice(pos + 1).trim();
|
|
120
122
|
t[tag] = msg;
|
|
123
|
+
if (tag === '失实度') {
|
|
124
|
+
reset();
|
|
125
|
+
}
|
|
126
|
+
continue;
|
|
121
127
|
}
|
|
122
128
|
}
|
|
129
|
+
if (pre) {
|
|
130
|
+
t[pre] += '\n' + trim;
|
|
131
|
+
}
|
|
123
132
|
}
|
|
124
133
|
}
|
|
125
134
|
if (t) {
|
package/fmtWithFactCheck.js
CHANGED
|
@@ -29,11 +29,11 @@ check = async(chat, json) => {
|
|
|
29
29
|
li = check.get(++n);
|
|
30
30
|
if (li) {
|
|
31
31
|
for (k of li) {
|
|
32
|
-
j.答 += `\n####
|
|
32
|
+
j.答 += `\n#### ⚠️ ${k.失实度} : ${k.标题}
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
观点: ${k.观点}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
事实: ${k.事实}`;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|