@3-/aiapi 0.1.14 → 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 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
- r.push(t);
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
- if (trim.length === i) {
113
- r.push(t);
114
- t = 0;
115
- } else {
116
- pos = trim.indexOf(':');
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) {
@@ -29,7 +29,7 @@ check = async(chat, json) => {
29
29
  li = check.get(++n);
30
30
  if (li) {
31
31
  for (k of li) {
32
- j.答 += `\n#### ⚠️${k.失实度} : ${k.标题}
32
+ j.答 += `\n#### ⚠️ ${k.失实度} : ${k.标题}
33
33
 
34
34
  观点: ${k.观点}
35
35
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3-/aiapi",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://atomgit.com/i18n/lib.git"