Refatora a inicialização dos serviços no main.py e remove importações duplicadas no auth_routes.py. Adiciona serviços de sessão, artefatos e memória para melhor gerenciamento de estado.

This commit is contained in:
Davidson Gomes 2025-04-28 20:09:04 -03:00
parent 215e76012e
commit 7af234ef48
2 changed files with 13 additions and 11 deletions

View File

@ -12,6 +12,7 @@ from src.schemas.user import (
MessageResponse,
)
from src.services.user_service import (
authenticate_user,
create_user,
verify_email,
resend_verification,
@ -19,7 +20,6 @@ from src.services.user_service import (
reset_password,
)
from src.services.auth_service import (
authenticate_user,
create_access_token,
get_current_admin_user,
get_current_user,

View File

@ -9,6 +9,18 @@ sys.path.append(str(root_dir))
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from src.config.database import engine, Base
from src.config.settings import settings
from src.utils.logger import setup_logger
from google.adk.artifacts.in_memory_artifact_service import InMemoryArtifactService
from google.adk.sessions import DatabaseSessionService
from google.adk.memory import InMemoryMemoryService
# Initialize service instances
session_service = DatabaseSessionService(db_url=settings.POSTGRES_CONNECTION_STRING)
artifacts_service = InMemoryArtifactService()
memory_service = InMemoryMemoryService()
# Import routers after service initialization to avoid circular imports
from src.api.auth_routes import router as auth_router
from src.api.admin_routes import router as admin_router
from src.api.chat_routes import router as chat_router
@ -18,20 +30,10 @@ from src.api.contact_routes import router as contact_router
from src.api.mcp_server_routes import router as mcp_server_router
from src.api.tool_routes import router as tool_router
from src.api.client_routes import router as client_router
from src.config.settings import settings
from src.utils.logger import setup_logger
from google.adk.artifacts.in_memory_artifact_service import InMemoryArtifactService
from google.adk.sessions import DatabaseSessionService
from google.adk.memory import InMemoryMemoryService
# Configure logger
logger = setup_logger(__name__)
session_service = DatabaseSessionService(db_url=settings.POSTGRES_CONNECTION_STRING)
artifacts_service = InMemoryArtifactService()
memory_service = InMemoryMemoryService()
# FastAPI initialization
app = FastAPI(
title=settings.API_TITLE,