diff --git a/src/app/database.py b/src/app/database.py index c4634873..29036993 100644 --- a/src/app/database.py +++ b/src/app/database.py @@ -114,11 +114,15 @@ def initialize_database() -> None: match db_config.db_type: case "sqlite": + logger.info("Initialize SQLite database") sqlite_config = db_config.config + logger.debug("Configuration: %s", sqlite_config) assert isinstance(sqlite_config, SQLiteDatabaseConfiguration) engine = _create_sqlite_engine(sqlite_config, **create_engine_kwargs) case "postgres": + logger.info("Initialize PostgreSQL database") postgres_config = db_config.config + logger.debug("Configuration: %s", postgres_config) assert isinstance(postgres_config, PostgreSQLDatabaseConfiguration) engine = _create_postgres_engine(postgres_config, **create_engine_kwargs) diff --git a/src/app/endpoints/query.py b/src/app/endpoints/query.py index 43c3eb60..167d16c4 100644 --- a/src/app/endpoints/query.py +++ b/src/app/endpoints/query.py @@ -184,6 +184,9 @@ async def query_endpoint_handler( user_conversation: UserConversation | None = None if query_request.conversation_id: + logger.debug( + "Conversation ID specified in query: %s", query_request.conversation_id + ) user_conversation = validate_conversation_ownership( user_id=user_id, conversation_id=query_request.conversation_id, @@ -205,6 +208,8 @@ async def query_endpoint_handler( "cause": "You do not have permission to access this conversation", }, ) + else: + logger.debug("Query does not contain conversation ID") try: # try to get Llama Stack client diff --git a/src/utils/endpoints.py b/src/utils/endpoints.py index e17a76d0..27687af2 100644 --- a/src/utils/endpoints.py +++ b/src/utils/endpoints.py @@ -1,7 +1,6 @@ """Utility functions for endpoint handlers.""" from contextlib import suppress -import logging from fastapi import HTTPException, status from llama_stack_client._client import AsyncLlamaStackClient from llama_stack_client.lib.agents.agent import AsyncAgent @@ -16,7 +15,9 @@ from utils.types import GraniteToolParser -logger = logging.getLogger("utils.endpoints") +from log import get_logger + +logger = get_logger(__name__) def delete_conversation(conversation_id: str) -> None: @@ -164,6 +165,8 @@ async def get_agent( await agent.initialize() if existing_agent_id and conversation_id: + logger.debug("Existing conversation ID: %s", conversation_id) + logger.debug("Existing agent ID: %s", existing_agent_id) orphan_agent_id = agent.agent_id agent._agent_id = conversation_id # type: ignore[assignment] # pylint: disable=protected-access await client.agents.delete(agent_id=orphan_agent_id) @@ -182,6 +185,8 @@ async def get_agent( ) from e else: conversation_id = agent.agent_id + logger.debug("New conversation ID: %s", conversation_id) session_id = await agent.create_session(get_suid()) + logger.debug("New session ID: %s", session_id) return agent, conversation_id, session_id