koishi-plugin-cocoyyy-console 1.1.0-beta.4 → 1.1.0-beta.5

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/lib/index.js +4 -2
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -2088,6 +2088,7 @@ async function startSituationPuzzle(config) {
2088
2088
  const { err, resp } = await callOpenRouter(config.api_url, config.api_key, config.api_model, chatHistory2);
2089
2089
  if (err != null) {
2090
2090
  logger.error("[startSituationPuzzle Error]: " + err);
2091
+ chatHistory2.pop();
2091
2092
  return null;
2092
2093
  }
2093
2094
  chatHistory2.push({ role: "assistant", content: [{ type: "text", text: resp }] });
@@ -2100,8 +2101,9 @@ async function questSituationPuzzle(content, config) {
2100
2101
  is_thinking = true;
2101
2102
  const { err, resp } = await callOpenRouter(config.api_url, config.api_key, config.api_model, chatHistory2);
2102
2103
  is_thinking = false;
2103
- if (err != null || err != "") {
2104
+ if (err != null) {
2104
2105
  logger.error("[questSituationPuzzle Error]: " + err);
2106
+ chatHistory2.pop();
2105
2107
  return null;
2106
2108
  }
2107
2109
  chatHistory2.push({ role: "assistant", content: [{ type: "text", text: resp }] });
@@ -2114,6 +2116,7 @@ async function endSituationPuzzle(config) {
2114
2116
  const { err, resp } = await callOpenRouter(config.api_url, config.api_key, config.api_model, chatHistory2);
2115
2117
  if (err != null) {
2116
2118
  logger.error("[endSituationPuzzle Error]: " + err);
2119
+ chatHistory2.pop();
2117
2120
  return null;
2118
2121
  }
2119
2122
  return resp;
@@ -2179,7 +2182,6 @@ function registerGameMiddleware(ctx, ai_config) {
2179
2182
  if (is_thinking) return "正在思考,请耐心等待...";
2180
2183
  const withoutTags = content.replace(/<[^>]+>/g, " ");
2181
2184
  const text = withoutTags.replace(/\s+/g, " ").trim();
2182
- logger.info("[game middleware Info]: " + text);
2183
2185
  const resp = await questSituationPuzzle(text, ai_config);
2184
2186
  return checkResp(resp);
2185
2187
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-cocoyyy-console",
3
3
  "description": "自用koishi插件,功能包含复读,记录黑历史,*人等",
4
- "version": "1.1.0-beta.4",
4
+ "version": "1.1.0-beta.5",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [