@3-/aiapi 0.1.6 → 0.1.8

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/fmtJson.js CHANGED
@@ -7,9 +7,14 @@ import seg from './seg.js';
7
7
 
8
8
  export default async(chat, txt) => {
9
9
  var gen, i, pli, result, split_li, sum, tmp, txt_li;
10
+ if (!txt) {
11
+ return [];
12
+ }
10
13
  txt_li = txt.split('\n');
11
14
  split_li = (await seg(chat, txt_li));
12
- pli = partition(txt_li, split_li);
15
+ pli = partition(txt_li, split_li.map((i) => {
16
+ return [i.题, i.行];
17
+ }));
13
18
  result = [];
14
19
  sum = 0;
15
20
  tmp = [];
@@ -20,6 +25,7 @@ export default async(chat, txt) => {
20
25
  tmp.push(i);
21
26
  sum += i.length;
22
27
  if (sum > 3000) {
28
+ console.log(sum);
23
29
  gen();
24
30
  sum = 0;
25
31
  tmp = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3-/aiapi",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://atomgit.com/i18n/lib.git"
package/partition.js CHANGED
@@ -10,9 +10,9 @@ export default (lines, title_number) => {
10
10
 
11
11
  // 遍历排序后的行号
12
12
  for (const [t, row] of order) {
13
+ console.log(t)
13
14
  // 将行号转换为从0开始的数组索引
14
15
  const index = row - 1;
15
- console.log(title)
16
16
  result.push(title + lines.slice(start, index).join('\n'));
17
17
  title = '# ' + t + '\n'
18
18
  start = index;
package/seg.js CHANGED
@@ -4,32 +4,31 @@ import TYPE from './TYPE.js';
4
4
  export default async(chat, txt_li) => {
5
5
  var split_li, 提示词;
6
6
  提示词 = `下文第1列为行号,第2列为对话内容,以tab分隔。
7
- 请划分章节,每章以提问开始,包含多组问答。
7
+ 请划分章节,每章以提问开始,包含多组问答,每章三千字左右。
8
8
  输出章节标题和每章首个问题的行号及原文,输出格式为JSON数组:\n` + txt_li.map((i, pos) => {
9
9
  return (pos + 1) + '\t' + i.trim();
10
10
  }).join('\n');
11
11
  return split_li = (await chat(提示词, {
12
12
  type: TYPE.ARRAY,
13
13
  description: '章节和行号的列表',
14
+ minItems: 1,
14
15
  items: {
15
- type: TYPE.ARRAY,
16
- items: false,
17
- minItems: 3,
18
- maxItems: 3,
19
- prefixItems: [
20
- {
21
- description: '章节标题,1-2个词即可',
16
+ type: TYPE.OBJECT,
17
+ properties: {
18
+ 题: {
19
+ description: '章节标题,要概括章节内容',
22
20
  type: TYPE.STRING
23
21
  },
24
- {
22
+ 行: {
25
23
  description: '该章首行行号',
26
24
  type: TYPE.INTEGER
27
25
  },
28
- {
26
+ 文: {
29
27
  description: '该章首行提问的原文',
30
28
  type: TYPE.STRING
31
29
  }
32
- ]
30
+ },
31
+ required: ['题', '行', '文']
33
32
  }
34
33
  }, '你是专业资深的秘书'));
35
34
  };