AgentGPT icon indicating copy to clipboard operation
AgentGPT copied to clipboard

✨ Update the setup CLI to allow vector db configuration

Open asim-shrestha opened this issue 2 years ago • 3 comments

Right now, the CLI will just put the docker URL for Weaviate if running the docker compose route. We should also add a question that asks if they have their own custom URL and API key they'd like to use and then place it in the ENV if so.

This is in the cli folder

asim-shrestha avatar Jun 06 '23 23:06 asim-shrestha

@asim-shrestha here is a proposal for how we can solve this.

As I suggested before, we can add two new questions to this file to ask the user for their custom Weaviate URL and API key.

Here's the updated code:

import { isValidSkKey } from "../helpers.js";
import { RUN_OPTION_QUESTION } from "./sharedQuestions.js";

export const newEnvQuestions = [
  RUN_OPTION_QUESTION,
  {
    type: "input",
    name: "OpenAIApiKey",
    message:
      "Enter your openai key (eg: sk...) or press enter to continue with no key:",
    validate: (apikey) => {
      if (isValidSkKey(apikey) || apikey === "") {
        return true;
      } else {
        return "\\nInvalid api key. Please try again.";
      }
    },
  },
  {
    type: "input",
    name: "serpApiKey",
    message:
      "What is your SERP API key (https://serper.dev/)? Leave empty to disable web search.",
  },
  {
    type: "input",
    name: "replicateApiKey",
    message:
      "What is your Replicate API key (https://replicate.com/)? Leave empty to just use DALL-E for image generation.",
  },
  {
    type: "input",
    name: "weaviateUrl",
    message: "Enter your custom Weaviate URL or press enter to use the default URL:",
  },
  {
    type: "input",
    name: "weaviateApiKey",
    message: "Enter your custom Weaviate API key or press enter to use the default API key:",
  },
];

After reviewing the envGenerator.js and helpers.js files, I can see how the environment variables are being set.

The generateEnv function in the envGenerator.js file is responsible for creating the environment variables. It does so by generating a configuration object (envDefinition) based on the answers received from the CLI. Then, the generateEnvFileContent function transforms this configuration object into a string format that can be written into the .env file. Finally, the saveEnvFile function writes this string into the .env file.

The getEnvDefinition function builds the environment configuration object. To add the Weaviate URL and API key to this object, we need to modify the getEnvDefinition function to include these new variables.

Here is how the updated getEnvDefinition function might look:

const getEnvDefinition = (envValues, isDockerCompose, dbPort, platformUrl) => {
  return {
    // ... existing code ...

    Backend: {
      REWORKD_PLATFORM_ENVIRONMENT: "development",
      REWORKD_PLATFORM_FF_MOCK_MODE_ENABLED: false,
      REWORKD_PLATFORM_MAX_LOOPS: "${NEXT_PUBLIC_MAX_LOOPS}",
      REWORKD_PLATFORM_OPENAI_API_KEY:
        envValues.OpenAIApiKey || \'"<change me>"\',
      REWORKD_PLATFORM_FRONTEND_URL: "http://localhost:3000",
      REWORKD_PLATFORM_RELOAD: true,
      REWORKD_PLATFORM_OPENAI_API_BASE: "https://api.openai.com/v1",
      REWORKD_PLATFORM_SERP_API_KEY: envValues.serpApiKey || \'""\',
      REWORKD_PLATFORM_REPLICATE_API_KEY: envValues.replicateApiKey || \'""\',
      REWORKD_PLATFORM_WEAVIATE_URL: envValues.weaviateUrl || \'"<change me>"\', // new line
      REWORKD_PLATFORM_WEAVIATE_API_KEY: envValues.weaviateApiKey || \'"<change me>"\', // new line
    },

    // ... existing code ...
  };
};

In the updated getEnvDefinition function, we've added two new lines to the Backend section. These lines add the Weaviate URL and API key to the environment configuration object, using the values provided by the user. If the user didn't provide these values, the default values ("") are used.

This change, in combination with the previous updates to the newEnvQuestions.js file, should solve the problem described by the project manager. The CLI will now ask the user for their custom Weaviate URL and API key, and these values will be written into the .env file. If the user doesn't provide these values, the default values will be used.

bhctest123 avatar Jun 12 '23 02:06 bhctest123

Hello @bhctest123 Would you like to send in a Pull Request!! so we can get a better review of this!!

jasangill1 avatar Jul 22 '23 20:07 jasangill1

Hello @asim-shrestha is this issue still active?

ikthedar avatar Dec 12 '24 16:12 ikthedar