🔧 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
# build a new ".env" file when you clone the repo. Keep this file up-to-date
# when you add new variables to `.env`.
# Deployment Environment:
NODE_ENV=development
# This file will be committed to version control, so make sure not to have any
# secrets in it. If you are cloning this repo, create a copy of this file named
# ".env" and populate it with your secrets.
# When adding additional environment variables, the schema in "/env/schema.mjs"
# should be updated accordingly.
# Next Auth config:
# Generate a secret with `openssl rand -base64 32`
NEXTAUTH_SECRET=changeme
NEXTAUTH_URL=http://localhost:3000
# Prisma
# https://www.prisma.io/docs/reference/database-reference/connection-urls#env
DATABASE_URL="file:./db.sqlite"
DATABASE_URL=file:./db.sqlite
# Next Auth
# You can generate a new secret on the command line with:
# 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=""
# External APIs:
OPENAI_API_KEY=changeme

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" />
</p>
<p align="center">
<a href="https://agentgpt.reworkd.ai">🔗 Short link</a>
<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:
- Long term memory 🧠
- Web browsing 🌐
- Interaction with websites and people 👨‍👩‍👦
## 🎉 Features
Coming soon...
More Coming soon...
## 🚀 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).
```bash
# Next Auth Secrets
NODE_ENV=production
NEXTAUTH_SECRET=
NEXTAUTH_URL=http://localhost:3000
# Deployment Environment:
NODE_ENV=development
# Next Auth config:
NEXTAUTH_SECRET=
NEXTAUTH_URL=
# Generate a secret with `openssl rand -base64 32`
NEXTAUTH_SECRET=changeme
NEXTAUTH_URL=http://localhost:3000
# Database URLs:
DATABASE_URL=
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
# Prisma
DATABASE_URL=file:./db.sqlite
# External APIs:
OPENAI_API_KEY=changeme
```
5. Ready 🥳, now run:

13
src/env/schema.mjs vendored
View File

@@ -1,6 +1,10 @@
// @ts-check
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.
* 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({
DATABASE_URL: z.string().url(),
NODE_ENV: z.enum(["development", "test", "production"]),
NEXTAUTH_SECRET:
process.env.NODE_ENV === "production"
? z.string().min(1)
: z.string().min(1).optional(),
NEXTAUTH_SECRET: requiredForProduction(),
NEXTAUTH_URL: z.preprocess(
// This makes Vercel deployments not fail if you don't set NEXTAUTH_URL
// 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
process.env.VERCEL ? z.string() : z.string().url(),
),
DISCORD_CLIENT_ID: z.string(),
DISCORD_CLIENT_SECRET: z.string(),
OPENAI_API_KEY: z.string()
});
@@ -34,8 +33,6 @@ export const serverEnv = {
NODE_ENV: process.env.NODE_ENV,
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
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,
};

View File

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