koishi-plugin-chatluna-think-viewer 1.0.12 → 1.0.14

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.
Files changed (2) hide show
  1. package/index.js +8 -2
  2. package/package.json +29 -9
package/index.js CHANGED
@@ -37,8 +37,14 @@ function extractText(content) {
37
37
  }
38
38
 
39
39
  function extractThink(text) {
40
- const match = text.match(/<think>([\s\S]*?)<\/think>/i);
41
- return match?.[1]?.trim() ?? '';
40
+ // 有些模型/中间件会在同一条消息里多次输出 <think>,取最后一段避免误用旧片段
41
+ let last = '';
42
+ const regex = /<think>([\s\S]*?)<\/think>/gi;
43
+ let m;
44
+ while ((m = regex.exec(text)) !== null) {
45
+ last = m[1];
46
+ }
47
+ return last.trim();
42
48
  }
43
49
 
44
50
  function formatThink(text) {
package/package.json CHANGED
@@ -1,20 +1,40 @@
1
- {
1
+ {
2
2
  "name": "koishi-plugin-chatluna-think-viewer",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "main": "index.js",
5
5
  "description": "Expose a command/shortcut to read the latest <think> block from chatluna-character.",
6
6
  "license": "MIT",
7
- "keywords": ["koishi", "chatluna", "character", "think"],
7
+ "keywords": [
8
+ "koishi",
9
+ "chatluna",
10
+ "character",
11
+ "think"
12
+ ],
8
13
  "homepage": "https://github.com/sCR0WN-s/koishi-plugin-chatluna-think-viewer",
9
- "repository": {"type": "git", "url": "git+https://github.com/sCR0WN-s/koishi-plugin-chatluna-think-viewer.git"},
10
- "contributors": ["sCR0WN-s <2892511968@qq.com>"],
11
- "peerDependencies": {"koishi": "^4.18.0", "koishi-plugin-chatluna-character": "^0.0.180"},
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/sCR0WN-s/koishi-plugin-chatluna-think-viewer.git"
17
+ },
18
+ "contributors": [
19
+ "sCR0WN-s <2892511968@qq.com>"
20
+ ],
21
+ "peerDependencies": {
22
+ "koishi": "^4.18.0",
23
+ "koishi-plugin-chatluna-character": "^0.0.180"
24
+ },
12
25
  "koishi": {
13
26
  "description": {
14
27
  "zh": "通过命令/关键词查看 chatluna-character 最近一次回复的 <think> 思考内容。",
15
28
  "en": "Expose a command/shortcut to read the last <think> block from chatluna-character."
16
29
  },
17
- "service": {"required": ["chatluna_character"]}
30
+ "service": {
31
+ "required": [
32
+ "chatluna_character"
33
+ ]
34
+ }
18
35
  },
19
- "files": ["index.js", "README.md"]
20
- }
36
+ "files": [
37
+ "index.js",
38
+ "README.md"
39
+ ]
40
+ }