structure saas with tools
This commit is contained in:
0
src/config/__init__.py
Normal file
0
src/config/__init__.py
Normal file
BIN
src/config/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
src/config/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/config/__pycache__/database.cpython-310.pyc
Normal file
BIN
src/config/__pycache__/database.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/config/__pycache__/settings.cpython-310.pyc
Normal file
BIN
src/config/__pycache__/settings.cpython-310.pyc
Normal file
Binary file not shown.
18
src/config/database.py
Normal file
18
src/config/database.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from src.config.settings import settings
|
||||
|
||||
SQLALCHEMY_DATABASE_URL = settings.POSTGRES_CONNECTION_STRING
|
||||
|
||||
engine = create_engine(SQLALCHEMY_DATABASE_URL)
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
def get_db():
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
36
src/config/settings.py
Normal file
36
src/config/settings.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import os
|
||||
from typing import Optional
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Configurações do projeto"""
|
||||
|
||||
# Configurações da API
|
||||
API_TITLE: str = "Agent Runner API"
|
||||
API_DESCRIPTION: str = "API para execução de agentes de IA"
|
||||
API_VERSION: str = "1.0.0"
|
||||
|
||||
# Configurações do banco de dados
|
||||
POSTGRES_CONNECTION_STRING: str = os.getenv(
|
||||
"POSTGRES_CONNECTION_STRING",
|
||||
"postgresql://postgres:root@localhost:5432/google-a2a-saas"
|
||||
)
|
||||
|
||||
# Configurações do OpenAI
|
||||
OPENAI_API_KEY: Optional[str] = os.getenv("OPENAI_API_KEY")
|
||||
|
||||
# Configurações da aplicação
|
||||
APP_NAME: str = "app"
|
||||
USER_ID: str = "user_1"
|
||||
SESSION_ID: str = "session_001"
|
||||
|
||||
# Configurações de logging
|
||||
LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")
|
||||
LOG_DIR: str = "logs"
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
case_sensitive = True
|
||||
|
||||
# Instância global das configurações
|
||||
settings = Settings()
|
||||
Reference in New Issue
Block a user