From b07e8152cb1f25aca192b903eb10f8aa38393fc5 Mon Sep 17 00:00:00 2001 From: "adam.watkins" Date: Sun, 9 Apr 2023 07:42:41 +0300 Subject: [PATCH 1/5] :art: Add dots animation --- src/components/ChatWindow.tsx | 17 ++++++++++++----- src/components/motions/expand.tsx | 7 ++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/components/ChatWindow.tsx b/src/components/ChatWindow.tsx index 068fc4d..8559df2 100644 --- a/src/components/ChatWindow.tsx +++ b/src/components/ChatWindow.tsx @@ -3,6 +3,7 @@ import React, { useEffect, useRef, useState } from "react"; import { FaBrain, FaListAlt, FaPlayCircle, FaStar } from "react-icons/fa"; import autoAnimate from "@formkit/auto-animate"; import PopIn from "./motions/popin"; +import Expand from "./motions/expand"; interface ChatWindowProps { children?: ReactNode; @@ -57,7 +58,7 @@ const ChatWindow = ({ messages, children, className }: ChatWindowProps) => { {children} {messages.length === 0 ? ( - + { "> Create an agent by adding a name / goal, and hitting deploy!", }} /> - + ) : ( "" )} @@ -77,9 +78,15 @@ const ChatWindow = ({ messages, children, className }: ChatWindowProps) => { const MacWindowHeader = () => { return (
-
-
-
+ +
+ + +
+ + +
+
); }; diff --git a/src/components/motions/expand.tsx b/src/components/motions/expand.tsx index 3d3f09f..e40569b 100644 --- a/src/components/motions/expand.tsx +++ b/src/components/motions/expand.tsx @@ -4,13 +4,18 @@ import type { PropsWithChildren } from "react"; interface MotionProps extends PropsWithChildren { className?: string; delay?: number; + type?: "spring" | "tween"; } const Expand = (props: MotionProps) => ( {props.children} From 7149d0414bde3490722245ac87fa36d026b58497 Mon Sep 17 00:00:00 2001 From: Asim Shrestha <50181239+asim-shrestha@users.noreply.github.com> Date: Sun, 9 Apr 2023 00:00:39 -0700 Subject: [PATCH 2/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index da58e1f..8fc8af0 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ 🔗 Short link   •   🤝 Contribute +🐦 Twitter

--- From 7e892bafbc595f898318dad3dc98ce999b250e90 Mon Sep 17 00:00:00 2001 From: Asim Shrestha <50181239+asim-shrestha@users.noreply.github.com> Date: Sun, 9 Apr 2023 00:00:54 -0700 Subject: [PATCH 3/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8fc8af0..458ad4e 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ 🔗 Short link   •   🤝 Contribute +  •   🐦 Twitter

From 74a16cdaf8b27bd83ed247ee58eeff35bf8d7f8d Mon Sep 17 00:00:00 2001 From: "adam.watkins" Date: Sun, 9 Apr 2023 10:23:58 +0300 Subject: [PATCH 4/5] :wrench: Create chroma db instance --- aws/cf/agent.cf.json | 316 ++++++++++++++++++++++++++++++++++++++ aws/cf/deploy.sh | 5 + src/components/Drawer.tsx | 14 +- 3 files changed, 327 insertions(+), 8 deletions(-) create mode 100644 aws/cf/agent.cf.json create mode 100644 aws/cf/deploy.sh diff --git a/aws/cf/agent.cf.json b/aws/cf/agent.cf.json new file mode 100644 index 0000000..7de4bd0 --- /dev/null +++ b/aws/cf/agent.cf.json @@ -0,0 +1,316 @@ +{ + "AWSTemplateFormatVersion": "2010-09-09", + "Description": "Create a stack that runs Chroma hosted on a single instance", + "Parameters": { + "KeyName": { + "Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance", + "Type": "String", + "ConstraintDescription": "If present, must be the name of an existing EC2 KeyPair.", + "Default": "" + }, + "InstanceType": { + "Description": "EC2 instance type", + "Type": "String", + "Default": "t3.small" + }, + "ChromaVersion": { + "Description": "Chroma version to install", + "Type": "String", + "Default": "0.3.21" + } + }, + "Conditions": { + "HasKeyName": { + "Fn::Not": [ + { + "Fn::Equals": [ + { + "Ref": "KeyName" + }, + "" + ] + } + ] + } + }, + "Resources": { + "ChromaInstance": { + "Type": "AWS::EC2::Instance", + "Properties": { + "ImageId": { + "Fn::FindInMap": [ + "Region2AMI", + { + "Ref": "AWS::Region" + }, + "AMI" + ] + }, + "InstanceType": { + "Ref": "InstanceType" + }, + "UserData": { + "Fn::Base64": { + "Fn::Join": [ + "", + [ + "Content-Type: multipart/mixed; boundary=\"//\"\n", + "MIME-Version: 1.0\n", + "\n", + "--//\n", + "Content-Type: text/cloud-config; charset=\"us-ascii\"\n", + "MIME-Version: 1.0\n", + "Content-Transfer-Encoding: 7bit\n", + "Content-Disposition: attachment; filename=\"cloud-config.txt\"\n", + "\n", + "\n", + "#cloud-config\n", + "cloud_final_modules:\n", + "- [scripts-user, always]\n", + "\n", + "\n", + "--//\n", + "Content-Type: text/x-shellscript; charset=\"us-ascii\"\n", + "MIME-Version: 1.0\n", + "Content-Transfer-Encoding: 7bit\n", + "Content-Disposition: attachment; filename=\"userdata.txt\"\n", + "\n", + "\n", + "#!/bin/bash\n", + "amazon-linux-extras install docker\n", + "usermod -a -G docker ec2-user\n", + "curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose\n", + "chmod +x /usr/local/bin/docker-compose\n", + "ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose\n", + "systemctl enable docker\n", + "systemctl start docker\n", + "\n", + "cat << EOF > /home/ec2-user/docker-compose.yml\n", + "version: '3.9'\n", + "\n", + "networks:\n", + " net:\n", + " driver: bridge\n", + "\n", + "services:\n", + " server:\n", + { + "Fn::Sub": " image: ghcr.io/chroma-core/chroma:${ChromaVersion}\n" + }, + " volumes:\n", + " - index_data:/index_data\n", + " environment:\n", + " - CHROMA_DB_IMPL=clickhouse\n", + " - CLICKHOUSE_HOST=clickhouse\n", + " - CLICKHOUSE_PORT=8123\n", + " ports:\n", + " - 8000:8000\n", + " depends_on:\n", + " - clickhouse\n", + " networks:\n", + " - net\n", + "\n", + " clickhouse:\n", + " image: clickhouse/clickhouse-server:22.9-alpine\n", + " environment:\n", + " - ALLOW_EMPTY_PASSWORD=yes\n", + " - CLICKHOUSE_TCP_PORT=9000\n", + " - CLICKHOUSE_HTTP_PORT=8123\n", + " ports:\n", + " - '8123:8123'\n", + " - '9000:9000'\n", + " volumes:\n", + " - clickhouse_data:/bitnami/clickhouse\n", + " - backups:/backups\n", + " - ./config/backup_disk.xml:/etc/clickhouse-server/config.d/backup_disk.xml\n", + " - ./config/chroma_users.xml:/etc/clickhouse-server/users.d/chroma.xml\n", + " networks:\n", + " - net\n", + "\n", + "volumes:\n", + " clickhouse_data:\n", + " driver: local\n", + " index_data:\n", + " driver: local\n", + " backups:\n", + " driver: local\n", + "\n", + "EOF\n", + "\n", + "mkdir /home/ec2-user/config\n", + "\n", + "cat << EOF > /home/ec2-user/config/backup_disk.xml\n", + "\n", + " \n", + " \n", + " \n", + " local\n", + " /etc/clickhouse-server/\n", + " \n", + " \n", + " \n", + " \n", + " backups\n", + " /etc/clickhouse-server/\n", + " \n", + "\n", + "EOF\n", + "\n", + "cat << EOF > /home/ec2-user/config/chroma_users.xml\n", + "\n", + " \n", + " \n", + " 1\n", + " 1\n", + " \n", + " \n", + "\n", + "\n", + "EOF\n", + "\n", + "docker-compose -f /home/ec2-user/docker-compose.yml up -d\n", + "\n", + "--//--\n" + ] + ] + } + }, + "SecurityGroupIds": [ + { + "Ref": "ChromaInstanceSecurityGroup" + } + ], + "KeyName": { + "Fn::If": [ + "HasKeyName", + { + "Ref": "KeyName" + }, + { + "Ref": "AWS::NoValue" + } + ] + }, + "BlockDeviceMappings": [ + { + "DeviceName": { + "Fn::FindInMap": [ + "Region2AMI", + { + "Ref": "AWS::Region" + }, + "RootDeviceName" + ] + }, + "Ebs": { + "VolumeSize": 24 + } + } + ] + } + }, + "ChromaInstanceSecurityGroup": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupDescription": "Chroma Instance Security Group", + "SecurityGroupIngress": [ + { + "IpProtocol": "tcp", + "FromPort": "22", + "ToPort": "22", + "CidrIp": "0.0.0.0/0" + }, + { + "IpProtocol": "tcp", + "FromPort": "8000", + "ToPort": "8000", + "CidrIp": "0.0.0.0/0" + } + ] + } + } + }, + "Outputs": { + "ServerIp": { + "Description": "IP address of the Chroma server", + "Value": { + "Fn::GetAtt": [ + "ChromaInstance", + "PublicIp" + ] + } + } + }, + "Mappings": { + "Region2AMI": { + "ap-south-1": { + "AMI": "ami-0a26068186838e542", + "RootDeviceName": "/dev/xvda" + }, + "eu-north-1": { + "AMI": "ami-04429d960e0f4871e", + "RootDeviceName": "/dev/xvda" + }, + "eu-west-3": { + "AMI": "ami-00575c0cbc20caf50", + "RootDeviceName": "/dev/xvda" + }, + "eu-west-2": { + "AMI": "ami-0acf1d0fb2c50538d", + "RootDeviceName": "/dev/xvda" + }, + "eu-west-1": { + "AMI": "ami-09e2d756e7d78558d", + "RootDeviceName": "/dev/xvda" + }, + "ap-northeast-3": { + "AMI": "ami-0bfdfe2977c12e24b", + "RootDeviceName": "/dev/xvda" + }, + "ap-northeast-2": { + "AMI": "ami-02de72c5dc79358c9", + "RootDeviceName": "/dev/xvda" + }, + "ap-northeast-1": { + "AMI": "ami-0329eac6c5240c99d", + "RootDeviceName": "/dev/xvda" + }, + "ca-central-1": { + "AMI": "ami-0f6b3aca8444b4f04", + "RootDeviceName": "/dev/xvda" + }, + "sa-east-1": { + "AMI": "ami-078f9645b086944ab", + "RootDeviceName": "/dev/xvda" + }, + "ap-southeast-1": { + "AMI": "ami-00653100209f2247d", + "RootDeviceName": "/dev/xvda" + }, + "ap-southeast-2": { + "AMI": "ami-0d6fb2916ee0ab9fe", + "RootDeviceName": "/dev/xvda" + }, + "eu-central-1": { + "AMI": "ami-06616b7884ac98cdd", + "RootDeviceName": "/dev/xvda" + }, + "us-east-1": { + "AMI": "ami-09d3b3274b6c5d4aa", + "RootDeviceName": "/dev/xvda" + }, + "us-east-2": { + "AMI": "ami-0beaa649c482330f7", + "RootDeviceName": "/dev/xvda" + }, + "us-west-1": { + "AMI": "ami-0e4d9ed95865f3b40", + "RootDeviceName": "/dev/xvda" + }, + "us-west-2": { + "AMI": "ami-098e42ae54c764c35", + "RootDeviceName": "/dev/xvda" + } + } + } +} \ No newline at end of file diff --git a/aws/cf/deploy.sh b/aws/cf/deploy.sh new file mode 100644 index 0000000..99e54ae --- /dev/null +++ b/aws/cf/deploy.sh @@ -0,0 +1,5 @@ +#!/bin/bash +cd "$(dirname "$0")" + +aws cloudformation create-stack --stack-name agent \ + --template-body file:///$PWD/agent.cf.json \ No newline at end of file diff --git a/src/components/Drawer.tsx b/src/components/Drawer.tsx index 4f6fc36..a07506e 100644 --- a/src/components/Drawer.tsx +++ b/src/components/Drawer.tsx @@ -60,13 +60,11 @@ const Drawer = ({ handleHelp }: { handleHelp: () => void }) => { ))} - {agents.length === 0 ? ( + {agents.length === 0 && (
Click the above button to restart. In the future, this will be a list of your deployed agents!
- ) : ( - "" )}
@@ -123,11 +121,11 @@ const DrawerItem = ({ }: DrawerItemProps) => { return (
{icon} From 593bbf5f0ad9e76c9bd27a6f4238d94ced44b1ef Mon Sep 17 00:00:00 2001 From: "adam.watkins" Date: Sun, 9 Apr 2023 14:22:00 +0300 Subject: [PATCH 5/5] :wrench: Update documentation on environment variables --- .env.example | 30 +++++++++--------------------- README.md | 32 ++++++++++++++++---------------- src/env/schema.mjs | 13 +++++-------- src/server/auth.ts | 6 ------ 4 files changed, 30 insertions(+), 51 deletions(-) diff --git a/.env.example b/.env.example index 7190bb7..dee118a 100644 --- a/.env.example +++ b/.env.example @@ -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 diff --git a/README.md b/README.md index 458ad4e..b04a954 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ Node version

-

🔗 Short link   •   @@ -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: diff --git a/src/env/schema.mjs b/src/env/schema.mjs index 6292334..36f2978 100644 --- a/src/env/schema.mjs +++ b/src/env/schema.mjs @@ -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, }; diff --git a/src/server/auth.ts b/src/server/auth.ts index f127672..2027358 100644 --- a/src/server/auth.ts +++ b/src/server/auth.ts @@ -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 *