ai-workflow-agent / config.py
Hamza4100's picture
Upload 22 files
9c95c55 verified
# AI Workflow Agent - Configuration
import os
from pathlib import Path
from pydantic_settings import BaseSettings
from typing import Optional
# Load environment variables from .env file
from dotenv import load_dotenv
# Load .env file from the M1_only directory
env_path = Path(__file__).parent / '.env'
if env_path.exists():
load_dotenv(env_path)
else:
# Try to load from parent directory
env_path = Path(__file__).parent.parent / '.env'
if env_path.exists():
load_dotenv(env_path)
class Settings(BaseSettings):
"""Application settings loaded from environment variables."""
# LLM Configuration
LLM_PROVIDER: str = os.getenv("LLM_PROVIDER", "gemini") # gemini or ollama
GEMINI_API_KEY: Optional[str] = os.getenv("GEMINI_API_KEY", None)
USE_LLM: bool = os.getenv("USE_LLM", "true").lower() == "true" # Enabled by default if key exists
# Ollama LLM Configuration (fallback)
OLLAMA_HOST: str = os.getenv("OLLAMA_HOST", "http://localhost:11434")
OLLAMA_MODEL: str = os.getenv("OLLAMA_MODEL", "qwen2.5:3b")
# n8n Configuration
N8N_HOST: str = os.getenv("N8N_HOST", "http://localhost:5678")
N8N_API_KEY: Optional[str] = os.getenv("N8N_API_KEY", None)
# ComfyUI Configuration
COMFYUI_HOST: str = os.getenv("COMFYUI_HOST", "http://localhost:8188")
# PostgreSQL Configuration
POSTGRES_HOST: str = os.getenv("POSTGRES_HOST", "localhost")
POSTGRES_PORT: int = int(os.getenv("POSTGRES_PORT", "5432"))
POSTGRES_USER: str = os.getenv("POSTGRES_USER", "agent")
POSTGRES_PASSWORD: str = os.getenv("POSTGRES_PASSWORD", "agent_secret_2026")
POSTGRES_DB: str = os.getenv("POSTGRES_DB", "workflow_agent")
# GitHub Configuration
GITHUB_TOKEN: Optional[str] = os.getenv("GITHUB_TOKEN", None)
# Colab Configuration (Milestone 2)
NGROK_AUTH_TOKEN: Optional[str] = os.getenv("NGROK_AUTH_TOKEN", None)
# Project Directories
PROJECTS_DIR: str = os.getenv("PROJECTS_DIR", "/app/projects")
WORKFLOWS_DIR: str = os.getenv("WORKFLOWS_DIR", "/app/workflows")
@property
def database_url(self) -> str:
return f"postgresql://{self.POSTGRES_USER}:{self.POSTGRES_PASSWORD}@{self.POSTGRES_HOST}:{self.POSTGRES_PORT}/{self.POSTGRES_DB}"
class Config:
env_file = ".env"
case_sensitive = True
# Global settings instance
settings = Settings()
# Project Type Definitions
class ProjectType:
N8N = "n8n"
COMFYUI = "comfyui"
HYBRID = "hybrid"
EXTERNAL_REPO = "external_repo"
UNKNOWN = "unknown"
# Keywords for project classification
CLASSIFICATION_KEYWORDS = {
ProjectType.N8N: [
"automation", "workflow", "integrate", "api", "webhook", "schedule",
"email", "slack", "telegram", "notification", "trigger", "connect",
"sync", "transfer", "backup", "monitor", "alert", "scrape", "fetch",
"social media", "post", "publish", "send", "share", "broadcast",
"twitter", "facebook", "instagram", "linkedin", "discord", "whatsapp",
"bot", "chatbot", "automate", "automated", "batch", "bulk", "mass",
"campaign", "marketing", "crm", "customer", "lead", "contact",
"database", "spreadsheet", "csv", "excel", "google sheets",
"zapier", "ifttt", "data processing", "etl", "pipeline",
"report", "reporting", "export", "transform", "convert", "parse",
"import", "data", "file", "process data", "data export"
],
ProjectType.COMFYUI: [
"image", "generate", "ai art", "stable diffusion", "flux", "sdxl",
"inpaint", "upscale", "controlnet", "lora", "checkpoint", "model",
"txt2img", "img2img", "video", "animation", "diffusion", "generative",
"photo", "picture", "visual", "art", "create image", "make image",
"design", "logo", "banner", "thumbnail", "avatar", "illustration"
],
ProjectType.HYBRID: [
"generate image and", "create image and", "ai image and send",
"photo generation and", "ai art and", "design and automation",
"generate images and automate", "image generation workflow",
"stable diffusion and", "image to", "generate and email with images",
"automated image", "generative ai and automation"
],
ProjectType.EXTERNAL_REPO: [
"github", "repository", "repo", "clone", "download project",
"install", "setup project", "deploy", "docker project",
"existing project", "open source", "template"
]
}