-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
82 lines (64 loc) · 2.35 KB
/
main.py
File metadata and controls
82 lines (64 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"""
ChatCV - Interactive Resume Assistant
A FastAPI application that transforms static resumes into intelligent,
conversational experiences using RAG (Retrieval-Augmented Generation).
"""
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
from fastapi.staticfiles import StaticFiles
from typing import Dict
from app.api.routes import router as chat_router
from app.utils.logging_config import main_logger
from app.config import config
# Initialize logging
logger = main_logger
app = FastAPI(
title="ChatCV-OSS",
description="Interactive Resume Assistant powered by AI",
version="1.0.0",
docs_url="/docs" if config.environment == "development" else None,
redoc_url="/redoc" if config.environment == "development" else None,
)
logger.info("ChatCV application starting up")
app.include_router(chat_router)
app.mount("/static", StaticFiles(directory="static"), name="static")
app.mount("/data", StaticFiles(directory="data"), name="data")
templates = Jinja2Templates(directory="templates")
@app.get("/", response_class=HTMLResponse)
async def index(request: Request) -> HTMLResponse:
"""
Serve the main chat interface.
Args:
request: FastAPI request object
Returns:
HTMLResponse: Rendered chat.html template with candidate information
"""
logger.debug("Serving main chat interface")
return templates.TemplateResponse(
"chat.html",
{
"request": request,
"candidate_name": config.candidate.name,
"candidate_email": config.candidate.email,
"candidate_linkedin": config.candidate.linkedin,
"candidate_github": config.candidate.github,
"cv_path": config.data.cv_path,
},
)
@app.get("/health")
async def health_check() -> Dict[str, str]:
"""
Health check endpoint for monitoring and load balancers.
Returns:
Dict[str, str]: Status and service information
"""
return {"status": "healthy", "service": "ChatCV-OSS"}
@app.on_event("startup")
async def startup_event() -> None:
"""Handle application startup tasks."""
logger.info("ChatCV application startup completed")
@app.on_event("shutdown")
async def shutdown_event() -> None:
"""Handle application shutdown tasks."""
logger.info("ChatCV application shutting down")