mirror of https://github.com/kortix-ai/suna.git
conf
This commit is contained in:
parent
b4ac29f366
commit
7325559d26
|
@ -6,7 +6,7 @@ from agentpress.thread_manager import ThreadManager
|
|||
from services.supabase import DBConnection
|
||||
from datetime import datetime, timezone
|
||||
from dotenv import load_dotenv
|
||||
from utils.config import config
|
||||
from utils.config import config, EnvMode
|
||||
import asyncio
|
||||
from utils.logger import logger
|
||||
import uuid
|
||||
|
@ -112,9 +112,20 @@ app = FastAPI(lifespan=lifespan)
|
|||
# logger.info(f"New connection from IP {client_ip}. Total connections: {len(ip_tracker)}")
|
||||
# return await call_next(request)
|
||||
|
||||
# Define allowed origins based on environment
|
||||
allowed_origins = ["https://www.suna.so", "https://suna.so", "https://staging.suna.so"]
|
||||
|
||||
# Add staging-specific origins
|
||||
if config.ENV_MODE == EnvMode.STAGING:
|
||||
allowed_origins.append("http://localhost:3000")
|
||||
|
||||
# Add local-specific origins
|
||||
if config.ENV_MODE == EnvMode.LOCAL:
|
||||
allowed_origins.append("http://localhost:3000")
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["https://www.suna.so", "https://suna.so", "https://staging.suna.so", "http://localhost:3000"], #http://localhost:3000
|
||||
allow_origins=allowed_origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
||||
allow_headers=["Content-Type", "Authorization"],
|
||||
|
@ -126,7 +137,7 @@ app.include_router(agent_api.router, prefix="/api")
|
|||
# Include the sandbox router with a prefix
|
||||
app.include_router(sandbox_api.router, prefix="/api")
|
||||
|
||||
@app.get("/api/health-check")
|
||||
@app.get("/api/")
|
||||
async def health_check():
|
||||
"""Health check endpoint to verify API is working."""
|
||||
logger.info("Health check endpoint called")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"""
|
||||
Configuration management for AgentPress backend.
|
||||
Configuration management.
|
||||
|
||||
This module provides a centralized way to access configuration settings and
|
||||
environment variables across the application. It supports different environment
|
||||
|
@ -52,7 +52,7 @@ class Configuration:
|
|||
AWS_REGION_NAME: Optional[str] = None
|
||||
|
||||
# Model configuration
|
||||
MODEL_TO_USE: str = "claude-3-haiku-20240307"
|
||||
MODEL_TO_USE: str = "anthropic/claude-3-7-sonnet-latest"
|
||||
|
||||
# Supabase configuration
|
||||
SUPABASE_URL: Optional[str] = None
|
||||
|
@ -82,7 +82,7 @@ class Configuration:
|
|||
|
||||
# Open Router configuration
|
||||
OR_SITE_URL: Optional[str] = None
|
||||
OR_APP_NAME: Optional[str] = "AgentPress"
|
||||
OR_APP_NAME: Optional[str] = "Suna.so"
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize configuration by loading from environment variables."""
|
||||
|
|
|
@ -19,6 +19,8 @@ from functools import wraps
|
|||
import traceback
|
||||
from logging.handlers import RotatingFileHandler
|
||||
|
||||
from utils.config import config, EnvMode
|
||||
|
||||
# Context variable for request correlation ID
|
||||
request_id: ContextVar[str] = ContextVar('request_id', default='')
|
||||
|
||||
|
@ -64,6 +66,11 @@ def setup_logger(name: str = 'agentpress') -> logging.Logger:
|
|||
logging.Logger: Configured logger instance
|
||||
"""
|
||||
logger = logging.getLogger(name)
|
||||
|
||||
# Set console logging level based on environment
|
||||
if config.ENV_MODE == EnvMode.PRODUCTION:
|
||||
logger.setLevel(logging.WARNING)
|
||||
else:
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
# Create logs directory if it doesn't exist
|
||||
|
@ -83,6 +90,11 @@ def setup_logger(name: str = 'agentpress') -> logging.Logger:
|
|||
|
||||
# Console handler
|
||||
console_handler = logging.StreamHandler(sys.stdout)
|
||||
|
||||
# Set console logging level based on environment
|
||||
if config.ENV_MODE == EnvMode.PRODUCTION:
|
||||
console_handler.setLevel(logging.INFO)
|
||||
else:
|
||||
console_handler.setLevel(logging.DEBUG)
|
||||
|
||||
# Create formatters
|
||||
|
|
Loading…
Reference in New Issue