arunbandari / mongo-gui

A web-based MongoDB graphical user interface
http://20.106.238.56:4321/
MIT License
290 stars 87 forks source link

version 0.0.20 broken #125

Open AndrewMarchukov opened 10 months ago

AndrewMarchukov commented 10 months ago

When i trying just start mongo-gui i get this:

/opt/mongo-gui/lib/node_modules/mongo-gui/node_modules/openai/index.js:50
    constructor({ apiKey = Core.readEnv('OPENAI_API_KEY'), organization = Core.readEnv('OPENAI_ORG_ID') ?? null, ...opts } = {}) {
                                                                                                         ^

SyntaxError: Unexpected token '?'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/opt/mongo-gui/lib/node_modules/mongo-gui/src/services/openai.js:1:16)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
tesorogaming commented 10 months ago

Setting Up the OpenAI Prompt Query To enable the OpenAI-powered prompt querying in Mongo GUI, you'll need to obtain an API key from OpenAI and add it to your project. Here's a step-by-step guide:

Obtain an OpenAI API Key:

Visit OpenAI's platform Sign up or log in, and navigate to the API section to generate your unique API key. Add the API Key to Your Project:

In the root directory of your project, look for a .env file (or create one if it doesn't exist). Add the following line to the .env file: OPENAI_API_KEY=YOUR_API_KEY_HERE Replace YOUR_API_KEY_HERE with the API key you obtained from OpenAI. Save the .env file and restart Mongo GUI if it's currently running. With this, the AI-powered prompt querying should be activated!

🔐 Security Note: Remember to keep your .env file confidential. Never push it to public repositories or share it. It contains sensitive information.

mariusrak commented 10 months ago

But I don't want to use openai at all. This should be optional.

arunbandari commented 10 months ago

Thank you for bringing this to our attention. We will take a look at it.

arunbandari commented 10 months ago

@AndrewMarchukov which version of node.js you are using?

ehsand commented 10 months ago

i have same issue and i use node v18.19.0

/usr/lib/node_modules/mongo-gui/node_modules/openai/index.js:52 throw new Errors.OpenAIError("The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' })."); ^

OpenAIError: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }). at new OpenAI (/usr/lib/node_modules/mongo-gui/node_modules/openai/index.js:52:19) at Object. (/usr/lib/node_modules/mongo-gui/src/services/openai.js:3:16) at Module._compile (node:internal/modules/cjs/loader:1356:14) at Module._extensions..js (node:internal/modules/cjs/loader:1414:10) at Module.load (node:internal/modules/cjs/loader:1197:32) at Module._load (node:internal/modules/cjs/loader:1013:12) at Module.require (node:internal/modules/cjs/loader:1225:19) at require (node:internal/modules/helpers:177:18) at Object. (/usr/lib/node_modules/mongo-gui/src/controllers/document.js:3:16) at Module._compile (node:internal/modules/cjs/loader:1356:14)

awsms commented 4 months ago

Thank you for bringing this to our attention. We will take a look at it.

?

kchojhu commented 4 months ago

Yeah, having OPENAI_API_KEY should be 'opt-in' feature and not enable by default. Easy way would be to enable OPENAI_API_KEY exists then enable it. Thanks for the library!

mariusrak commented 3 months ago

Is there any plan on fixing this issue?