@3-/aiapi 0.1.16 → 0.1.18

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
@@ -9,16 +9,16 @@ import utf8e from '@3-/utf8/utf8e.js';
9
9
 
10
10
  // @3-/read
11
11
  // @3-/write
12
- SHOW_KIND = ['严重失实'];
12
+ SHOW_KIND = ['严重失实', '略有出入'];
13
13
 
14
14
  PREFIX = `对下文问答对做事实核查,只输出与事实不符的观点。
15
15
  必须搜索到明确的反面事实才算失实,模棱两可算无法核实。
16
16
  输出文本必须是简体中文,格式如下:
17
17
  - id:
18
- 标题: 要简短,一两个词即可
18
+ 标题: 要简短,几个词即可
19
19
  观点:
20
20
  事实: 须标注搜索到的事实网页
21
- 失实度: ${SHOW_KIND.join(' / ')} / 略有出入 / 基本一致 / 无法核实
21
+ 失实度: ${SHOW_KIND.join(' / ')} / 基本一致 / 无法核实
22
22
  ---\n`;
23
23
 
24
24
  realUrl = async(url) => {
@@ -95,14 +95,15 @@ addUrl = (text, items) => {
95
95
  };
96
96
 
97
97
  txtLi = (txt) => {
98
- var i, id, msg, pos, pre, r, ref, reset, t, tag, trim;
98
+ var i, id, msg, pos, pre, r, ref, reset, t, tag, trim, txt_li;
99
99
  r = [];
100
100
  reset = () => {
101
101
  r.push(t);
102
102
  pre = t = void 0;
103
103
  };
104
- ref = txt.replaceAll('**', '').split('\n');
105
- for (i of ref) {
104
+ txt_li = txt_li.replaceAll('**', '').split('\n');
105
+ out: //;
106
+ for (i of txt_li) {
106
107
  if (i.startsWith('- id:')) {
107
108
  if (t) {
108
109
  reset();
@@ -112,18 +113,19 @@ txtLi = (txt) => {
112
113
  t = {id};
113
114
  }
114
115
  } else if (t) {
115
- trim = i.trimStart();
116
- pos = trim.indexOf(': ');
117
- if (pos > 0) {
118
- tag = trim.slice(0, pos).replace('- ', '').trim();
119
- if (['标题', '观点', '事实', '失实度'].includes(tag)) {
116
+ trim = i.trimStart().replace('- ', '');
117
+ ref = ['标题', '观点', '事实', '失实度'];
118
+ for (t of ref) {
119
+ if (trim.startsWith(t + ':')) {
120
+ pos = trim.indexOf(':');
121
+ tag = trim.slice(0, pos).trim();
120
122
  pre = tag;
121
123
  msg = trim.slice(pos + 1).trim();
122
124
  t[tag] = msg;
123
125
  if (tag === '失实度') {
124
126
  reset();
125
127
  }
126
- continue;
128
+ continue out;
127
129
  }
128
130
  }
129
131
  if (pre) {
@@ -12,7 +12,7 @@ import txtFmt from '@3-/txt_li/txtFmt.js';
12
12
  // @3-/read
13
13
  // @3-/write
14
14
  check = async(chat, json) => {
15
- var j, k, li, n, x, y, z, 答, 问, 问答;
15
+ var j, k, li, n, tip, x, y, z, 答, 问, 问答;
16
16
  li = [];
17
17
  for (x of json) {
18
18
  ({问答} = x);
@@ -29,7 +29,12 @@ check = async(chat, json) => {
29
29
  li = check.get(++n);
30
30
  if (li) {
31
31
  for (k of li) {
32
- j.答 += `\n#### ⚠️ 失实: ${k.标题}
32
+ if (k.失实度 === '严重失实') {
33
+ tip = '❗ 失实:';
34
+ } else {
35
+ tip = '⚠️';
36
+ }
37
+ j.答 += `\n#### ${tip} ${k.标题}
33
38
 
34
39
  观点: ${k.观点}
35
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3-/aiapi",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://atomgit.com/i18n/lib.git"