🔧 Update documentation on environment variables

This commit is contained in:
adam.watkins
2023-04-09 14:22:00 +03:00
parent 09c26ebb36
commit 593bbf5f0a
4 changed files with 30 additions and 51 deletions

View File

@@ -1,25 +1,13 @@
# Since the ".env" file is gitignored, you can use the ".env.example" file to # Deployment Environment:
# build a new ".env" file when you clone the repo. Keep this file up-to-date NODE_ENV=development
# when you add new variables to `.env`.
# This file will be committed to version control, so make sure not to have any # Next Auth config:
# secrets in it. If you are cloning this repo, create a copy of this file named # Generate a secret with `openssl rand -base64 32`
# ".env" and populate it with your secrets. NEXTAUTH_SECRET=changeme
NEXTAUTH_URL=http://localhost:3000
# When adding additional environment variables, the schema in "/env/schema.mjs"
# should be updated accordingly.
# Prisma # Prisma
# https://www.prisma.io/docs/reference/database-reference/connection-urls#env DATABASE_URL=file:./db.sqlite
DATABASE_URL="file:./db.sqlite"
# Next Auth # External APIs:
# You can generate a new secret on the command line with: OPENAI_API_KEY=changeme
# openssl rand -base64 32
# https://next-auth.js.org/configuration/options#secret
# NEXTAUTH_SECRET=""
NEXTAUTH_URL="http://localhost:3000"
# Next Auth Discord Provider
DISCORD_CLIENT_ID=""
DISCORD_CLIENT_SECRET=""

View File

@@ -8,7 +8,6 @@
<img alt="Node version" src="https://img.shields.io/static/v1?label=node&message=%20%3E=16.0.0&logo=node.js&color=2334D058" /> <img alt="Node version" src="https://img.shields.io/static/v1?label=node&message=%20%3E=16.0.0&logo=node.js&color=2334D058" />
</p> </p>
<p align="center"> <p align="center">
<a href="https://agentgpt.reworkd.ai">🔗 Short link</a> <a href="https://agentgpt.reworkd.ai">🔗 Short link</a>
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span> <span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
@@ -19,18 +18,19 @@
--- ---
AgentGPT allows you to configure and deploy Autonomous AI agents. Name your own custom AI and have it embark on any goal imaginable. It will attempt to reach the goal by thinking of tasks to do, executing them, and learning from the results 🚀. AgentGPT allows you to configure and deploy Autonomous AI agents.
Name your own custom AI and have it embark on any goal imaginable.
It will attempt to reach the goal by thinking of tasks to do, executing them, and learning from the results 🚀.
## 🎉 Features
This platform is currently in beta, we are currently working on: This platform is currently in beta, we are currently working on:
- Long term memory 🧠 - Long term memory 🧠
- Web browsing 🌐 - Web browsing 🌐
- Interaction with websites and people 👨‍👩‍👦 - Interaction with websites and people 👨‍👩‍👦
More Coming soon...
## 🎉 Features
Coming soon...
## 🚀 Tech Stack ## 🚀 Tech Stack
@@ -68,19 +68,19 @@ npm install
> 🚧 The environment variables must match the following [schema](https://github.com/reworkd/AgentGPT/blob/main/src/env/schema.mjs). > 🚧 The environment variables must match the following [schema](https://github.com/reworkd/AgentGPT/blob/main/src/env/schema.mjs).
```bash ```bash
# Next Auth Secrets # Deployment Environment:
NODE_ENV=production NODE_ENV=development
NEXTAUTH_SECRET=
NEXTAUTH_URL=http://localhost:3000
# Next Auth config: # Next Auth config:
NEXTAUTH_SECRET= # Generate a secret with `openssl rand -base64 32`
NEXTAUTH_URL= NEXTAUTH_SECRET=changeme
NEXTAUTH_URL=http://localhost:3000
# Database URLs: # Prisma
DATABASE_URL= DATABASE_URL=file:./db.sqlite
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY= # External APIs:
OPENAI_API_KEY=changeme
``` ```
5. Ready 🥳, now run: 5. Ready 🥳, now run:

13
src/env/schema.mjs vendored
View File

@@ -1,6 +1,10 @@
// @ts-check // @ts-check
import { z } from "zod"; import { z } from "zod";
const requiredForProduction = () => process.env.NODE_ENV === "production"
? z.string().min(1).trim()
: z.string().min(1).trim().optional()
/** /**
* Specify your server-side environment variables schema here. * Specify your server-side environment variables schema here.
* This way you can ensure the app isn't built with invalid env vars. * This way you can ensure the app isn't built with invalid env vars.
@@ -8,10 +12,7 @@ import { z } from "zod";
export const serverSchema = z.object({ export const serverSchema = z.object({
DATABASE_URL: z.string().url(), DATABASE_URL: z.string().url(),
NODE_ENV: z.enum(["development", "test", "production"]), NODE_ENV: z.enum(["development", "test", "production"]),
NEXTAUTH_SECRET: NEXTAUTH_SECRET: requiredForProduction(),
process.env.NODE_ENV === "production"
? z.string().min(1)
: z.string().min(1).optional(),
NEXTAUTH_URL: z.preprocess( NEXTAUTH_URL: z.preprocess(
// This makes Vercel deployments not fail if you don't set NEXTAUTH_URL // This makes Vercel deployments not fail if you don't set NEXTAUTH_URL
// Since NextAuth.js automatically uses the VERCEL_URL if present. // Since NextAuth.js automatically uses the VERCEL_URL if present.
@@ -19,8 +20,6 @@ export const serverSchema = z.object({
// VERCEL_URL doesn't include `https` so it cant be validated as a URL // VERCEL_URL doesn't include `https` so it cant be validated as a URL
process.env.VERCEL ? z.string() : z.string().url(), process.env.VERCEL ? z.string() : z.string().url(),
), ),
DISCORD_CLIENT_ID: z.string(),
DISCORD_CLIENT_SECRET: z.string(),
OPENAI_API_KEY: z.string() OPENAI_API_KEY: z.string()
}); });
@@ -34,8 +33,6 @@ export const serverEnv = {
NODE_ENV: process.env.NODE_ENV, NODE_ENV: process.env.NODE_ENV,
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET, NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
NEXTAUTH_URL: process.env.NEXTAUTH_URL, NEXTAUTH_URL: process.env.NEXTAUTH_URL,
DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID,
DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET,
OPENAI_API_KEY: process.env.OPENAI_API_KEY, OPENAI_API_KEY: process.env.OPENAI_API_KEY,
}; };

View File

@@ -4,9 +4,7 @@ import {
type NextAuthOptions, type NextAuthOptions,
type DefaultSession, type DefaultSession,
} from "next-auth"; } from "next-auth";
import DiscordProvider from "next-auth/providers/discord";
import { PrismaAdapter } from "@next-auth/prisma-adapter"; import { PrismaAdapter } from "@next-auth/prisma-adapter";
import { env } from "../env/server.mjs";
import { prisma } from "./db"; import { prisma } from "./db";
/** /**
@@ -47,10 +45,6 @@ export const authOptions: NextAuthOptions = {
}, },
adapter: PrismaAdapter(prisma), adapter: PrismaAdapter(prisma),
providers: [ providers: [
DiscordProvider({
clientId: env.DISCORD_CLIENT_ID,
clientSecret: env.DISCORD_CLIENT_SECRET,
}),
/** /**
* ...add more providers here * ...add more providers here
* *