labring / FastGPT

FastGPT is a knowledge-based platform built on the LLMs, offers a comprehensive suite of out-of-the-box capabilities such as data processing, RAG retrieval, and visual AI workflow orchestration, letting you easily develop and deploy complex question-answering systems without the need for extensive setup or configuration.
https://tryfastgpt.ai
Other
17.45k stars 4.69k forks source link

本地运行源码报mongoDB错误 #2552

Closed lichengdu closed 1 month ago

lichengdu commented 1 month ago

例行检查

你的版本

问题描述, 日志截图 运行源码时如下错误 mongo error MongooseError: The uri parameter to openUri() must be a string, got "undefined". Make sure the first parameter to mongoose.connect() or mongo e.createConnection() is a string. at NativeConnection.createClient (webpack-internal:///(api)/../../node_modules/.pnpm/mongoose@7.7.0/node_modules/mongoose/lib/drivers/node-mongodb-native/co ection.js:206:11) at NativeConnection.openUri (webpack-internal:///(api)/../../node_modules/.pnpm/mongoose@7.7.0/node_modules/mongoose/lib/connection.js:759:34) at Mongoose.connect (webpack-internal:///(api)/../../node_modules/.pnpm/mongoose@7.7.0/node_modules/mongoose/lib/index.js:405:15) at connectMongo (webpack-internal:///(api)/../../packages/service/common/mongo/init.ts:30:67) at NativeConnection.eval (webpack-internal:///(api)/../../packages/service/common/mongo/init.ts:25:13) at runNextTicks (node:internal/process/task_queues:60:5) at listOnTimeout (node:internal/timers:545:9) at process.processTimers (node:internal/timers:519:7) 如图 98e3ef30686cdaf5de62434acd88109 mongodb是可以连上的 image

复现步骤 按照官网运行源码步骤 确认mongo可以通过内网连接 pnpm dev image

访问http://localhost:3000/时报错 Load model====== chatitems mongo start connect [Error] 2024-08-28 11:27:20 mongo connect error { message: 'The uri parameter to openUri() must be a string, got "undefined". Make sure the first parameter to mongoose.connect() or mongoose.createConne ction() is a string.', stack: 'MongooseError: The uri parameter to openUri() must be a string, got "undefined". Make sure the first parameter to mongoose.connect() or mongoos e.createConnection() is a string.\n' + ' at NativeConnection.createClient (webpack-internal:///(api)/../../node_modules/.pnpm/mongoose@7.7.0/node_modules/mongoose/lib/drivers/node-mongodb-nati ve/connection.js:206:11)\n' + ' at NativeConnection.openUri (webpack-internal:///(api)/../../node_modules/.pnpm/mongoose@7.7.0/node_modules/mongoose/lib/connection.js:759:34)\n' + ' at Mongoose.connect (webpack-internal:///(api)/../../node_modules/.pnpm/mongoose@7.7.0/node_modules/mongoose/lib/index.js:405:15)\n' + ' at connectMongo (webpack-internal:///(api)/../../packages/service/common/mongo/init.ts:30:67)\n' + ' at connectToDatabase (webpack-internal:///(api)/./src/service/mongo.ts:45:92)\n' + ' at handler (webpack-internal:///(api)/./src/pages/api/common/system/getInitData.ts:13:76)\n' + ' at K (E:\outgit\fastgpt1\FastGPT\nodemodules\.pnpm\next@14.2.5@babel+core@7.24.9_react-dom@18.3.1_react@18.3.1__react@18.3.1sass@1.77.8\node modules\next\dist\compiled\next-server\pages-api.runtime.dev.js:21:2877)\n' +

修改后的配置文件 LOG_DEPTH=3

默认用户密码,用户名为 root,每次重启时会自动更新。

DEFAULT_ROOT_PSW=123456

数据库最大连接数

DB_MAX_LINK=5

token

TOKEN_KEY=dfdasfdas

文件阅读时的秘钥

FILE_TOKEN_KEY=filetokenkey

root key, 最高权限

ROOT_KEY=fdafasd

openai 基本地址,可用作中转。

OPENAI_BASE_URL=http://192.168.41.214:3001/v1

oneapi 地址,可以使用 oneapi 来实现多模型接入

ONEAPI_URL=https://xxxx.cloud.sealos.io/openai/v1

通用key。可以是 openai 的也可以是 oneapi 的。

此处逻辑:优先走 ONEAPI_URL,如果填写了 ONEAPI_URL,key 也需要是 ONEAPI 的 key

CHAT_API_KEY=sk-fastgpt

mongo 数据库连接参数,本地开发时,mongo可能需要增加 directConnection=true 参数,才能连接上。

MONGODB_URI=mongodb://myusername:mypassword@192.168.41.214:27017/fastgpt?authSource=admin&directConnection=true

向量库优先级: pg > milvus

PG 向量库连接参数

PG_URL=postgresql://username:password@192.168.41.214:5432/postgres

milvus 向量库连接参数

MILVUS_ADDRESS=https://in03-78bd7f60e6e2a7c.api.gcp-us-west1.zillizcloud.com MILVUS_TOKEN=133964348b00b4b4e4b51bef680a61350950385c8c64a3ec16b1ab92d3c67dcc4e0370fb9dd15791bcd6dadaf765e98a98735d0d

code sandbox url 这个地址在214上但是官网没有说如何修改

SANDBOX_URL=http://localhost:3001

商业版地址

PRO_URL=

首页路径

HOME_URL=/

日志等级: debug, info, warn, error

LOG_LEVEL=debug STORE_LOG_LEVEL=warn

Loki Log Path

预期结果 正常连上mongo

相关截图

lichengdu commented 1 month ago

已解决 env修改后文件名缺失点(.)读取不了

Essence9999 commented 1 month ago

你好,你这个mongo是装在本地还是dockers容器中?