Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

采用了node方式启动项目,在新建的项目根目录下放了修改后的.env.migpt.js文件,但是仍然报错提示Missing userId or password. #19

Closed
csjuXYZ opened this issue Jun 2, 2024 · 6 comments

Comments

@csjuXYZ
Copy link

csjuXYZ commented Jun 2, 2024

D:\document\Github\mi-gpt-2> node main.js
2024/06/03 01:33:07 MiGPT ❌ Missing userId or password.
file:///D:/document/Github/mi-gpt-2/node_modules/.pnpm/mi-gpt@2.1.1/node_modules/mi-gpt/dist/index.js:231
throw Error("\u274C Assertion failed");
^

Error: ❌ Assertion failed
at _LoggerManager.assert (file:///D:/document/Github/mi-gpt-2/node_modules/.pnpm/mi-gpt@2.1.1/node_modules/mi-gpt/dist/index.js:231:13)
at __Logger.assert (file:///D:/document/Github/mi-gpt-2/node_modules/.pnpm/mi-gpt@2.1.1/node_modules/mi-gpt/dist/index.js:268:19)
at _MiGPT.create (file:///D:/document/Github/mi-gpt-2/node_modules/.pnpm/mi-gpt@2.1.1/node_modules/mi-gpt/dist/index.js:2266:19)
at main (file:///D:/document/Github/mi-gpt-2/main.js:4:24)
at file:///D:/document/Github/mi-gpt-2/main.js:14:1
at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async loadESM (node:internal/process/esm_loader:34:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)

@idootop
Copy link
Owner

idootop commented Jun 2, 2024

在你自己的 Node 项目里导包,需要把 .migpt.js 里的参数放到 MiGPT 对象初始化参数,具体看 example 分支的示例代码。

@idootop
Copy link
Owner

idootop commented Jun 2, 2024

外部引用 mi-gpt package 需要在你自己的项目里传入初始化参数,并确保正确读取了环境变量。此时 mi-gpt 不会主动读取并解析根目录的 .ENV 和 .migpt.js。

@csjuXYZ
Copy link
Author

csjuXYZ commented Jun 2, 2024

外部引用 mi-gpt package 需要在你自己的项目里传入初始化参数,并确保正确读取了环境变量。此时 mi-gpt 不会主动读取并解析根目录的 .ENV 和 .migpt.js。

手动引入了.ENV 和 .migpt.js,同时打印了process.env,发现了.env 已经生效,但是仍然报了401的错误

2024/06/03 02:39:26 Open AI ❌ ❌ openai chat failed AuthenticationError: 401 Invalid Authentication
at APIError.generate (file:///D:/document/Github/mi-gpt-2/node_modules/.pnpm/openai@4.47.3/node_modules/openai/error.mjs:44:20)
at OpenAI.makeStatusError (file:///D:/document/Github/mi-gpt-2/node_modules/.pnpm/openai@4.47.3/node_modules/openai/core.mjs:256:25)
at OpenAI.makeRequest (file:///D:/document/Github/mi-gpt-2/node_modules/.pnpm/openai@4.47.3/node_modules/openai/core.mjs:299:30)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async OpenAIClient.chatStream (file:///D:/document/Github/mi-gpt-2/node_modules/.pnpm/mi-gpt@2.1.1/node_modules/mi-gpt/dist/index.js:1086:20) {
status: 401,
headers: {
connection: 'keep-alive',
'content-length': '84',
'content-type': 'application/json; charset=utf-8',
date: 'Sun, 02 Jun 2024 18:39:26 GMT',
'msh-cache': 'miss',
server: 'nginx',
'server-timing': 'inner; dur=18',
'strict-transport-security': 'max-age=15724800; includeSubDomains',
vary: 'Origin'
},
request_id: undefined,
error: {
message: 'Invalid Authentication',
type: 'invalid_authentication_error'
},
code: undefined,
param: undefined,
type: 'invalid_authentication_error'
}

@idootop
Copy link
Owner

idootop commented Jun 3, 2024

未复现,请检查你的 API_KEY 是否可用。

@idootop idootop closed this as completed Jun 3, 2024
@smallfawn
Copy link

mi-gpt@4.0.0 dev C:\Users\86056\Desktop\米\mi-gpt
node --env-file=.env ./app.js

2024/06/18 13:42:35 database ❌ 初始化数据库失败!
C:\Users\86056\Desktop\米\mi-gpt\node_modules.pnpm\mi-gpt@4.0.0\node_modules\mi-gpt\dist\index.cjs:268
throw Error("\u274C Assertion failed");
^

Error: ❌ Assertion failed
at _LoggerManager.assert (C:\Users\86056\Desktop\米\mi-gpt\node_modules.pnpm\mi-gpt@4.0.0\node_modules\mi-gpt\dist\index.cjs:268:13)
at __Logger.assert (C:\Users\86056\Desktop\米\mi-gpt\node_modules.pnpm\mi-gpt@4.0.0\node_modules\mi-gpt\dist\index.cjs:305:19)
at initDB (C:\Users\86056\Desktop\米\mi-gpt\node_modules.pnpm\mi-gpt@4.0.0\node_modules\mi-gpt\dist\index.cjs:1372:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async _MiGPT.start (C:\Users\86056\Desktop\米\mi-gpt\node_modules.pnpm\mi-gpt@4.0.0\node_modules\mi-gpt\dist\index.cjs:2436:5)
at async main (file:///C:/Users/86056/Desktop/%E7%B1%B3/mi-gpt/app.js:6:3)

Node.js v20.14.0
 ELIFECYCLE  Command failed with exit code 1.

@idootop
Copy link
Owner

idootop commented Jun 18, 2024

@smallfawn 发下你的项目代码,和启动命令。最好给一个最小可复现代码仓库。另外,你可以尝试切换到 example 分支运行演示代码(切换后删掉旧的node_models然后 pnpm i 重新安装依赖),看看是否正常。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants