TomLBZ / koishi-plugin-openai

Calls OpenAI API for Koishi.js
48 stars 10 forks source link

无法启动该插件 #2

Closed yi03 closed 1 year ago

yi03 commented 1 year ago

在koishi上安装好这个插件后,点击启动按钮没有反应,我启动其他的插件都没有问题,目前只有这个插件出现了这个问题。

点击启动后页面 dev tools console 会报这个错:

runtime-core.esm-bundler.js:38 

       [Vue warn]: Unhandled error during execution of native event handler 
  at <ElOnlyChild key=0 class="el-tooltip__trigger" aria-controls=undefined  ... > 
  at <ElPopperTrigger id="el-id-9829-14" virtual-ref=undefined open=true  ... > 
  at <ElTooltipTrigger disabled=false trigger="hover" trigger-keys= (2) ['Enter', 'Space']0: "Enter"1: "Space"length: 2[[Prototype]]: Array(0)  ... > 
  at <ElPopperRoot ref="popperRef" role="tooltip" > 
  at <ElTooltip disabled=false content="启用插件" placement="bottom" > 
  at <LayoutHeader> 
  at <KLayout menu= (5) [{…}, {…}, {…}, {…}, {…}]0: {icon: 'play', label: '启用插件', disabled: false, action: ƒ}action: async () => {…}disabled: falseicon: "play"label: "启用插件"[[Prototype]]: Object1: {type: undefined, icon: 'save', label: '保存配置', disabled: false, action: ƒ}action: ƒ async action()disabled: falseicon: "save"label: "保存配置"type: undefined[[Prototype]]: Object2: {type: 'error', icon: 'trash-can', label: '移除插件', disabled: false, action: ƒ}3: {icon: 'add-plugin', label: '添加插件', disabled: true, action: ƒ}4: {icon: 'add-group', label: '添加分组', disabled: true, action: ƒ}length: 5[[Prototype]]: Array(0) > 
  at <Index onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< Proxy {…} > > 
  at <KeepAlive> 
  at <RouterView key=0 > 
  at <Index>
warn2 @ runtime-core.esm-bundler.js:38
logError @ runtime-core.esm-bundler.js:212
handleError @ runtime-core.esm-bundler.js:204
(匿名) @ runtime-core.esm-bundler.js:167
Promise.catch(异步)
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:166
invoker @ runtime-dom.esm-bundler.js:339

openai:36tunc:1 

       Uncaught (in promise) TypeError: missing required value
    at Function.resolve (C:\Users\65151\koishi-bot\koishi-app\node_modules\schemastery\src\index.ts:203:37)
    at property (C:\Users\65151\koishi-bot\koishi-app\node_modules\schemastery\src\index.ts:321:35)
    at <anonymous> (C:\Users\65151\koishi-bot\koishi-app\node_modules\schemastery\src\index.ts:369:19)
    at Function.resolve (C:\Users\65151\koishi-bot\koishi-app\node_modules\schemastery\src\index.ts:210:24)
    at schema (C:\Users\65151\koishi-bot\koishi-app\node_modules\schemastery\src\index.ts:92:19)
    at resolveConfig (C:\Users\65151\koishi-bot\koishi-app\node_modules\cordis\src\utils.ts:19:54)
    at NodeLoader.forkPlugin (C:\Users\65151\koishi-bot\koishi-app\node_modules\@koishijs\loader\src\shared.ts:105:5)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at NodeLoader.reloadPlugin (C:\Users\65151\koishi-bot\koishi-app\node_modules\@koishijs\loader\src\shared.ts:126:16)
    at ConfigWriter.reload (C:\Users\65151\koishi-bot\koishi-app\node_modules\@koishijs\plugin-market\src\shared\writer.ts:151:5)

日志没有报错,只有这些(点了四次启动)

2022-10-30 16:03:23 [I] app apply plugin @tomlbz/openai:36tunc
2022-10-30 16:03:23 [I] app apply plugin @tomlbz/openai:36tunc
2022-10-30 16:03:24 [I] app apply plugin @tomlbz/openai:36tunc
2022-10-30 16:03:24 [I] app apply plugin @tomlbz/openai:36tunc

如果改koishi.yml配置文件把这个插件前边的波浪号去掉,启动koishi的时候会报这个错:

--------^
     60 |     apikey: xxxxxxxxxxxxxxxxxxxxxxx...
     61 |   ~:qzxqli: {}
        at generateError (C:\Users\65151\koishi-bot\koishi-app\node_modules\js-yaml\lib\loader.js:183:10)
        at throwError (C:\Users\65151\koishi-bot\koishi-app\node_modules\js-yaml\lib\loader.js:187:9)
        at readBlockMapping (C:\Users\65151\koishi-bot\koishi-app\node_modules\js-yaml\lib\loader.js:1182:7)
        at composeNode (C:\Users\65151\koishi-bot\koishi-app\node_modules\js-yaml\lib\loader.js:1441:12)
        at readDocument (C:\Users\65151\koishi-bot\koishi-app\node_modules\js-yaml\lib\loader.js:1625:3)
        at loadDocuments (C:\Users\65151\koishi-bot\koishi-app\node_modules\js-yaml\lib\loader.js:1688:5)
        at Object.load (C:\Users\65151\koishi-bot\koishi-app\node_modules\js-yaml\lib\loader.js:1714:19)
        at NodeLoader.readConfig (C:\Users\65151\koishi-bot\koishi-app\node_modules\@koishijs\loader\src\node.ts:85:26)
        at Object.<anonymous> (C:\Users\65151\koishi-bot\koishi-app\node_modules\@koishijs\cli\src\worker\index.ts:51:23)
        at Module._compile (node:internal/modules/cjs/loader:1155:14)
error Command failed with exit code 1.

我koishi版本目前都是最新版,

{
  "name": "koishi-app",
  "version": "0.0.0",
  "private": true,
  "files": [
    ".env",
    "koishi.yml"
  ],
  "license": "GPL-3.0",
  "workspaces": [
    "packages/*",
    "plugins/*"
  ],
  "scripts": {
    "new": "koishi-scripts new",
    "setup": "koishi-scripts setup",
    "build": "yakumo build",
    "bump": "yakumo version",
    "dep": "yakumo upgrade",
    "pub": "yakumo publish",
    "dev": "cross-env NODE_ENV=development koishi start -r esbuild-register -r yml-register --watch",
    "start": "koishi start -r yml-register"
  },
  "devDependencies": {
    "@koishijs/client": "^4.6.8",
    "@koishijs/scripts": "^3.2.4",
    "@types/node": "^18.6.4",
    "cross-env": "^7.0.3",
    "esbuild": "^0.14.51",
    "esbuild-register": "^3.3.3",
    "typescript": "^4.8.3",
    "yakumo": "^0.3.6",
    "yakumo-esbuild": "^0.3.17",
    "yakumo-esbuild-yaml": "^0.3.1",
    "yakumo-publish": "^0.3.0",
    "yakumo-publish-sync": "^0.3.1",
    "yakumo-tsc": "^0.3.5",
    "yakumo-upgrade": "^0.3.2",
    "yakumo-version": "^0.3.1"
  },
  "dependencies": {
    "@koishijs/cli": "4.9.9",
    "@koishijs/plugin-adapter-discord": "3.3.0",
    "@koishijs/plugin-adapter-kook": "3.4.0",
    "@koishijs/plugin-adapter-onebot": "5.3.2",
    "@koishijs/plugin-adapter-telegram": "3.5.0",
    "@koishijs/plugin-admin": "^1.1.5",
    "@koishijs/plugin-assets-git": "1.0.6",
    "@koishijs/plugin-assets-local": "2.0.10",
    "@koishijs/plugin-auth": "^2.2.0",
    "@koishijs/plugin-bind": "^1.3.2",
    "@koishijs/plugin-chat": "3.1.8",
    "@koishijs/plugin-commands": "2.1.4",
    "@koishijs/plugin-console": "4.6.9",
    "@koishijs/plugin-database-memory": "1.5.0",
    "@koishijs/plugin-database-mysql": "4.6.0",
    "@koishijs/plugin-database-sqlite": "1.5.0",
    "@koishijs/plugin-dataview": "2.1.6",
    "@koishijs/plugin-help": "^1.2.5",
    "@koishijs/plugin-insight": "3.1.7",
    "@koishijs/plugin-locales": "1.0.3",
    "@koishijs/plugin-logger": "2.1.6",
    "@koishijs/plugin-market": "1.4.2",
    "@koishijs/plugin-rate-limit": "^1.2.2",
    "@koishijs/plugin-sandbox": "2.3.3",
    "@koishijs/plugin-status": "^6.1.5",
    "@koishijs/plugin-suggest": "^1.1.5",
    "@minatojs/core": "1.3.2",
    "@satorijs/satori": "1.3.4",
    "@tomlbz/koishi-plugin-openai": "1.0.9",
    "koishi": "4.9.9",
    "yml-register": "^1.1.0"
  }
}

我感觉可能是因为插件名的第一个字符是@,我目前装的第三方插件只有这一个是@开头的。不过我不懂js,瞎猜的。 谢谢!

ZayrexDev commented 1 year ago

我也遇到了相同情况。我在 Discord 上询问过,有人告诉我需要在 koishi.yml 用单引号把插件名括起来。括起来之后能够启动,但尽管填了 apikey,也会提示 Missing Required Value ,而且插件也不工作。 屏幕截图 2022-10-31 120740

TomLBZ commented 1 year ago

看样子出于某种原因required schema没有在配置插件时被自动写入koishi.yml,导致报错“缺少必须的值”。这是bug,会修的,等我过几天考完试…… 在修好这个bug之前,一个暂时应付的办法就是手动把所有的配置项写进koishi.yml。大概类似这种样子(按需更改):

plugins:
  ......
  group:ai:
    '@tomlbz/openai':
      botname: 半灵
      apikey: *********************************
      model: text-davinci-002
      ntokens: 128
      temperature: 0.9
      presencePenalty: 0.6
      frequencyPenalty: 0
      randomReplyFrequency: 0.1
      botIdentitySettings: 聪明、友好、学识渊博的式神,外表是可爱的银发少女,梦想是成为世界最强
      botMoePoint: 会在每句结尾加上“(^_^)”的表情
      memoryShortLength: 2
      memoryLongLength: 16

(memoryShortLength不建议调大,因为会让机器人变得非常执著于某些说话方式,救都救不回来。2就不错,哪怕陷入某些执着的回答方式也可以通过聊别的救回来) (最后感谢各位对这个自娱自乐的拙劣小插件感兴趣,等我考完第一时间修bug)

yi03 commented 1 year ago
      botname: 半灵
      apikey: *********************************
      model: text-davinci-002
      ntokens: 128
      temperature: 0.9
      presencePenalty: 0.6
      frequencyPenalty: 0
      randomReplyFrequency: 0.1
      botIdentitySettings: 聪明、友好、学识渊博的式神,外表是可爱的银发少女,梦想是成为世界最强
      botMoePoint: 会在每句结尾加上“(^_^)”的表情
      memoryShortLength: 2
      memoryLongLength: 16

十分感谢!这么设置后成功跑起来了,已经在玩了。

Rinlity commented 1 year ago

it works! thx a lot

kuyin commented 1 year ago

嘿,我遇到了同样的问题,求更新~

TomLBZ commented 1 year ago

已更新1.1.0,修复了该bug,并且改进了记忆与人设相关的功能。 只需要删除存在的插件,然后重新安装最新版的插件即可~