Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging utility and refactor app structure #22

Merged
merged 3 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import streamlit as st
import os
import logging
from utils.logging_utils import setup_logging
from typing import Dict, List
from datetime import datetime
from dotenv import load_dotenv
Expand Down Expand Up @@ -95,16 +95,7 @@ def get_svg_base64(svg_content):
</style>
""", unsafe_allow_html=True)

# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('vetsai.log'),
logging.StreamHandler()
]
)
logger = logging.getLogger(__name__)
logger = setup_logging()

# Load environment variables
load_dotenv()
Expand Down
1 change: 1 addition & 0 deletions tests/test_streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def test_translate_military_code_not_found(self, mock_job_codes):
assert isinstance(result["data"]["tech_focus"], list)

class TestChatFunctionality:
@patch.dict(os.environ, {"OPENAI_API_KEY": "test_api_key"})
@patch('openai.OpenAI')
def test_get_chat_response(self, mock_openai):
mock_client = MagicMock()
Expand Down
Empty file added utils/__init__.py
Empty file.
15 changes: 15 additions & 0 deletions utils/logging_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import logging

def setup_logging():

# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('vetsai.log'),
logging.StreamHandler()
]
)
logger = logging.getLogger(__name__)
return logger