Skip to content
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
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ XAI_MODEL_S=grok-3-mini
XAI_MODEL_M=grok-3-fast
XAI_MODEL_L=grok-3-latest
XAI_MODEL_XL=grok-4-0709

# CSV_FOR_SPONSORSHIP
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment 'CSV_FOR_SPONSORSHIP' doesn't match the actual environment variable name 'CSV_SPONSORSHIP'. Consider updating the comment to match: '# CSV_SPONSORSHIP'

Suggested change
# CSV_FOR_SPONSORSHIP
# CSV_SPONSORSHIP

Copilot uses AI. Check for mistakes.
CSV_SPONSORSHIP=2025-07-17-Worker.csv
20 changes: 20 additions & 0 deletions app/logging_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
Logging configuration for the application.
This module should be imported before any other application modules.
"""

import logging


def setup_logging(level=logging.INFO):
"""
Configure logging for the entire application.

Args:
level: Logging level (default: logging.INFO)
"""
logging.basicConfig(
level=level,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
force=True, # Override any existing configuration
)
17 changes: 13 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import asyncio
import logging
from typing import List

from fastapi import FastAPI, Query
from fastapi.responses import StreamingResponse
from fastapi_mcp import FastApiMCP

from app.models import CompanySearchResult
from app.services.ai_investment import investment_agent
from app.services.search import search_companies
from app.utils import lessthan_x
from app.logging_config import setup_logging

# Set up logging FIRST, before importing any app modules that might log
setup_logging()

# Import app modules after logging is configured
from app.models import CompanySearchResult # noqa: E402
from app.services.ai_investment import investment_agent # noqa: E402
from app.services.search import search_companies # noqa: E402
from app.utils import lessthan_x # noqa: E402

logger = logging.getLogger(__name__)

app = FastAPI()
mcp = FastApiMCP(app)
Expand Down
9 changes: 8 additions & 1 deletion app/services/search.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os
from typing import List

Expand All @@ -6,10 +7,16 @@
from pandas import Series

from app.models import CompanySearchResult
from app.utils import validate_env_variables

logger = logging.getLogger(__name__)

# Validate all required environment variables
(csv_file_name,) = validate_env_variables(["CSV_SPONSORSHIP"])
logger.info(f"The CSV name is {csv_file_name}")
# Load CSV into memory at startup
CSV_PATH = os.path.join(
os.path.dirname(os.path.dirname(__file__)), "..", "csv", "2025-07-03-Worker.csv"
os.path.dirname(os.path.dirname(__file__)), "..", "csv", csv_file_name
)
skilled_worker_data_current = pd.read_csv(CSV_PATH)

Expand Down
Loading