From 7af234ef4868c622429e5285a379534c45f9ad72 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Mon, 28 Apr 2025 20:09:04 -0300 Subject: [PATCH] =?UTF-8?q?Refatora=20a=20inicializa=C3=A7=C3=A3o=20dos=20?= =?UTF-8?q?servi=C3=A7os=20no=20main.py=20e=20remove=20importa=C3=A7=C3=B5?= =?UTF-8?q?es=20duplicadas=20no=20auth=5Froutes.py.=20Adiciona=20servi?= =?UTF-8?q?=C3=A7os=20de=20sess=C3=A3o,=20artefatos=20e=20mem=C3=B3ria=20p?= =?UTF-8?q?ara=20melhor=20gerenciamento=20de=20estado.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/auth_routes.py | 2 +- src/main.py | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/api/auth_routes.py b/src/api/auth_routes.py index 655e4815..b5a3b8ce 100644 --- a/src/api/auth_routes.py +++ b/src/api/auth_routes.py @@ -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, diff --git a/src/main.py b/src/main.py index aa2fa5d0..3f191594 100644 --- a/src/main.py +++ b/src/main.py @@ -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,