diff --git a/README.md b/README.md index 63be27abd..8ea7fabb9 100644 --- a/README.md +++ b/README.md @@ -152,9 +152,16 @@ L3AGI offers a robust set of functionalities that empower you to design, supervi ./setup.sh ``` - This will build and start both the React UI and FastAPI services. +4. **Create `.env` file from `.env.example` in root directory** + + ```bash + cp .env.example .env + ``` + + - **Configure `Azure Web PubSub` using [our guide here](docs/azure.md)** + - **To configure `Zep Memory`, please see [quick start on Zep](https://docs.getzep.com/deployment/quickstart/)** -4. 🐳 **Run Docker Compose:** +5. 🐳 **Run Docker Compose:** ```bash docker-compose up --build diff --git a/apps/server/.env.example b/apps/server/.env.example index 96ffe80bd..5a41f1950 100644 --- a/apps/server/.env.example +++ b/apps/server/.env.example @@ -1,43 +1,46 @@ -# Run pipenv shell and install after changing this file. See README file for more info. +ENV=local -NODE_ENV=local OPENAI_API_KEY= +# Connects to the db service in docker-compose.yml by default DB_NAME=l3-db -DB_HOST=localhost +DB_HOST=db DB_PORT=5432 DB_USER=postgres -DB_PASS=123456 - -SENTRY_DSN= +DB_PASS=postgres +# Azure pubsub used for chat. Quickstart: https://github.com/l3vels/L3AGI/blob/main/docs/azure.md AZURE_PUBSUB_CONNECTION_STRING= AZURE_PUBSUB_HUB_NAME=hub - + +# Configure Zep for chat memory. Quickstart: https://docs.getzep.com/deployment/quickstart/ ZEP_API_URL= ZEP_API_KEY= -SERPAPI_API_KEY= - -LANGCHAIN_TRACING_V2=true -LANGCHAIN_ENDPOINT= -LANGCHAIN_API_KEY= -LANGCHAIN_PROJECT= - -TEST_USER_EMAIL= -TEST_USER_PASSWORD= - JWT_EXPIRY=120 JWT_SECRET_KEY=l3_secret +# Configure for GitHub OAuth GITHUB_CLIENT_ID= GITHUB_CLIENT_SECRET= -FRONTEND_URL=http://localhost:3000 - -GOOGLE_API_KEY=YOUR_GOOGLE_API_KEY - +# Configure AWS for S3 storage AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_REGION= AWS_S3_BUCKET= + +# Optionally configure sentry for error tracking +SENTRY_DSN= + +# Optionally configure LangSmith to log the runs +LANGCHAIN_TRACING_V2=true +LANGCHAIN_ENDPOINT= +LANGCHAIN_API_KEY= +LANGCHAIN_PROJECT= + +# Optionally configure to run tests on the user +TEST_USER_EMAIL= +TEST_USER_PASSWORD= + +FRONTEND_URL=http://localhost:3000 diff --git a/apps/server/config.py b/apps/server/config.py index fdf81be02..3e8431d39 100644 --- a/apps/server/config.py +++ b/apps/server/config.py @@ -4,7 +4,7 @@ class Config: """Config class for the application.""" - NODE_ENV = os.environ.get("NODE_ENV") + ENV = os.environ.get("ENV") OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY") @@ -15,32 +15,26 @@ class Config: DB_PASS = os.environ.get("DB_PASS") DB_URI = f"postgresql+psycopg2://{DB_USER}:{DB_PASS}@{DB_HOST}:{DB_PORT}/{DB_NAME}" - SENTRY_DSN = os.environ.get("SENTRY_DSN") - AZURE_PUBSUB_CONNECTION_STRING = os.environ.get("AZURE_PUBSUB_CONNECTION_STRING") AZURE_PUBSUB_HUB_NAME = os.environ.get("AZURE_PUBSUB_HUB_NAME") ZEP_API_URL = os.environ.get("ZEP_API_URL") ZEP_API_KEY = os.environ.get("ZEP_API_KEY") - SERPAPI_API_KEY = os.environ.get("SERPAPI_API_KEY") - - TEST_USER_EMAIL = os.environ.get("TEST_USER_EMAIL") - TEST_USER_PASSWORD = os.environ.get("TEST_USER_PASSWORD") JWT_EXPIRY = os.environ.get("JWT_EXPIRY") JWT_SECRET_KEY = os.environ.get("JWT_SECRET_KEY") GITHUB_CLIENT_ID = os.environ.get("GITHUB_CLIENT_ID") GITHUB_CLIENT_SECRET = os.environ.get("GITHUB_CLIENT_SECRET") - FRONTEND_URL = os.environ.get("FRONTEND_URL") - - GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY") AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID") AWS_SECRET_ACCESS_KEY = os.environ.get("AWS_SECRET_ACCESS_KEY") AWS_REGION = os.environ.get("AWS_REGION") AWS_S3_BUCKET = os.environ.get("AWS_S3_BUCKET") + SENTRY_DSN = os.environ.get("SENTRY_DSN") + + TEST_USER_EMAIL = os.environ.get("TEST_USER_EMAIL") + TEST_USER_PASSWORD = os.environ.get("TEST_USER_PASSWORD") -def get_config(key: str, default: str = None) -> str: - return # _config_instance.get_config(key, default) + FRONTEND_URL = os.environ.get("FRONTEND_URL") diff --git a/apps/server/main.py b/apps/server/main.py index d9e97b97b..a428b206a 100644 --- a/apps/server/main.py +++ b/apps/server/main.py @@ -57,8 +57,7 @@ class Mutation(AccountMutation, UserMutation): graphql_app = GraphQLRouter(schema, context_getter=get_context) app.include_router(graphql_app, prefix="/graphql") - -if Config.NODE_ENV != "local": +if Config.ENV != "local" and Config.SENTRY_DSN: sentry_sdk.init( dsn=Config.SENTRY_DSN, # Set traces_sample_rate to 1.0 to capture 100% diff --git a/apps/server/models/agent_config.py b/apps/server/models/agent_config.py index 6a2315c7d..838e63793 100644 --- a/apps/server/models/agent_config.py +++ b/apps/server/models/agent_config.py @@ -3,7 +3,6 @@ from sqlalchemy.exc import SQLAlchemyError from typing import Union -from config import get_config from utils.encyption import decrypt_data from models.base_model import BaseModel import uuid diff --git a/apps/server/models/db.py b/apps/server/models/db.py index c927974b1..e3909acec 100644 --- a/apps/server/models/db.py +++ b/apps/server/models/db.py @@ -2,5 +2,5 @@ from sqlalchemy import create_engine from config import Config -engine = create_engine(Config.DB_URI, echo=Config.NODE_ENV == "local") +engine = create_engine(Config.DB_URI, echo=Config.ENV == "local") Base = declarative_base() diff --git a/apps/server/terraform/*.auto.tfvars b/apps/server/terraform/*.auto.tfvars index 7b2a584c3..cfe4c314d 100644 --- a/apps/server/terraform/*.auto.tfvars +++ b/apps/server/terraform/*.auto.tfvars @@ -1,4 +1,4 @@ # ----** Task Container Environment Config **---- -NODE_ENV="development" +ENV="development" task_desired_count = 2 diff --git a/apps/server/terraform/main.tf b/apps/server/terraform/main.tf index c9ebbeea7..314084847 100644 --- a/apps/server/terraform/main.tf +++ b/apps/server/terraform/main.tf @@ -30,7 +30,7 @@ module "backend" { environment = var.environment tags = {} kubernetes_secret_config_map_data = { - NODE_ENV = var.NODE_ENV + ENV = var.ENV } kubernetes_secret_name_data = { OPENAI_API_KEY = var.OPENAI_API_KEY diff --git a/apps/server/terraform/varfiles/dev.tfvars b/apps/server/terraform/varfiles/dev.tfvars index 7b2a584c3..cfe4c314d 100644 --- a/apps/server/terraform/varfiles/dev.tfvars +++ b/apps/server/terraform/varfiles/dev.tfvars @@ -1,4 +1,4 @@ # ----** Task Container Environment Config **---- -NODE_ENV="development" +ENV="development" task_desired_count = 2 diff --git a/apps/server/terraform/varfiles/prod.tfvars b/apps/server/terraform/varfiles/prod.tfvars index c86b23237..ea054241d 100644 --- a/apps/server/terraform/varfiles/prod.tfvars +++ b/apps/server/terraform/varfiles/prod.tfvars @@ -1,4 +1,4 @@ # ----** Task Container Environment Config **---- -NODE_ENV="production" +ENV="production" task_desired_count = 2 diff --git a/apps/server/terraform/variables-container.tf b/apps/server/terraform/variables-container.tf index bb6f504cb..5aaf5ad35 100644 --- a/apps/server/terraform/variables-container.tf +++ b/apps/server/terraform/variables-container.tf @@ -1,5 +1,5 @@ # DB Config -variable "NODE_ENV" { +variable "ENV" { type = string } variable "OPENAI_API_KEY" { diff --git a/docker-compose.yml b/docker-compose.yml index d86e2a189..9e73be44c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,3 +19,20 @@ services: - ./apps/server:/code ports: - "4000:4000" + depends_on: + - db + + db: + image: postgres:14 + restart: always + environment: + POSTGRES_DB: l3-db + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + ports: + - "5434:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + +volumes: + postgres_data: diff --git a/docs/assets/azure/create-pubsub-1.png b/docs/assets/azure/create-pubsub-1.png new file mode 100644 index 000000000..316da82a4 Binary files /dev/null and b/docs/assets/azure/create-pubsub-1.png differ diff --git a/docs/assets/azure/create-pubsub-2.png b/docs/assets/azure/create-pubsub-2.png new file mode 100644 index 000000000..15ed6a91a Binary files /dev/null and b/docs/assets/azure/create-pubsub-2.png differ diff --git a/docs/assets/azure/create-pubsub-3.png b/docs/assets/azure/create-pubsub-3.png new file mode 100644 index 000000000..f59504cd9 Binary files /dev/null and b/docs/assets/azure/create-pubsub-3.png differ diff --git a/docs/assets/azure/create-pubsub-4.png b/docs/assets/azure/create-pubsub-4.png new file mode 100644 index 000000000..9e6316d57 Binary files /dev/null and b/docs/assets/azure/create-pubsub-4.png differ diff --git a/docs/assets/azure/create-pubsub-5.png b/docs/assets/azure/create-pubsub-5.png new file mode 100644 index 000000000..02c5d6114 Binary files /dev/null and b/docs/assets/azure/create-pubsub-5.png differ diff --git a/docs/assets/azure/create-pubsub-6.png b/docs/assets/azure/create-pubsub-6.png new file mode 100644 index 000000000..908d0c017 Binary files /dev/null and b/docs/assets/azure/create-pubsub-6.png differ diff --git a/docs/assets/azure/create-pubsub-7.png b/docs/assets/azure/create-pubsub-7.png new file mode 100644 index 000000000..1d69f389f Binary files /dev/null and b/docs/assets/azure/create-pubsub-7.png differ diff --git a/docs/azure.md b/docs/azure.md new file mode 100644 index 000000000..7fde3c182 --- /dev/null +++ b/docs/azure.md @@ -0,0 +1,33 @@ +# Setup Azure Web PubSub Service from UI + +1. Create a free account on [Azure](https://azure.microsoft.com/en-us/free). + +2. Go to [Azure Portal](https://portal.azure.com/#home) + +3. Create Web PubSub Service on [Azure Portal](https://portal.azure.com/#create/Microsoft.AzureWebPubSub) + Choose first option: + ![Create PubSub](assets/azure/create-pubsub-1.png) + +4. Create a new resource group and choose name for your pubsub service: + ![Create new resource group](assets/azure/create-pubsub-2.png) + +5. Click `Review + create` + +6. Wait for validation and then click `Create` + ![Create resource](assets/azure/create-pubsub-3.png) + +7. After creating, you will be redirected. Click `Go to resource`: + ![Go to resource](assets/azure/create-pubsub-4.png) + +8. Go to `Keys` and copy `Connection string`: + ![Get connection string](assets/azure/create-pubsub-5.png) + +9. Paste `Connection string` in `.env` file. + +10. Go to `Settings` and create new `Hub`: + ![Create Hub](assets/azure/create-pubsub-6.png) + ![Save Hub](assets/azure/create-pubsub-7.png) + +11. Paste hub name in `.env` file. + +For more information visit: [Azure Web PubSub Service](https://docs.microsoft.com/en-us/azure/azure-web-pubsub/overview)