Skip to content

Commit

Permalink
Merge pull request #132 from l3vels/build/docker
Browse files Browse the repository at this point in the history
Build: add postgres to docker compose, add azure pubsub and zep configuration to docs
  • Loading branch information
Chkhikvadze authored Sep 19, 2023
2 parents f9eb5f0 + 1f8e609 commit b298846
Show file tree
Hide file tree
Showing 20 changed files with 96 additions and 44 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 24 additions & 21 deletions apps/server/.env.example
Original file line number Diff line number Diff line change
@@ -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
18 changes: 6 additions & 12 deletions apps/server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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")
3 changes: 1 addition & 2 deletions apps/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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%
Expand Down
1 change: 0 additions & 1 deletion apps/server/models/agent_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apps/server/models/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion apps/server/terraform/*.auto.tfvars
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ----** Task Container Environment Config **----
NODE_ENV="development"
ENV="development"

task_desired_count = 2
2 changes: 1 addition & 1 deletion apps/server/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apps/server/terraform/varfiles/dev.tfvars
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ----** Task Container Environment Config **----
NODE_ENV="development"
ENV="development"

task_desired_count = 2
2 changes: 1 addition & 1 deletion apps/server/terraform/varfiles/prod.tfvars
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ----** Task Container Environment Config **----
NODE_ENV="production"
ENV="production"

task_desired_count = 2
2 changes: 1 addition & 1 deletion apps/server/terraform/variables-container.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# DB Config
variable "NODE_ENV" {
variable "ENV" {
type = string
}
variable "OPENAI_API_KEY" {
Expand Down
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Binary file added docs/assets/azure/create-pubsub-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/azure/create-pubsub-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/azure/create-pubsub-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/azure/create-pubsub-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/azure/create-pubsub-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/azure/create-pubsub-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/azure/create-pubsub-7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions docs/azure.md
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit b298846

Please sign in to comment.