This FastAPI application provides an endpoint for analyzing chat messages and generating insights for CEO reporting.
- Extracts top 3 frequently mentioned topics from messages
- Generates CEO-friendly summaries
- Performs sentiment analysis on messages
- Uses OpenAI's GPT-3.5 for advanced text analysis
- Uses TextBlob for sentiment analysis
- Python 3.12 or higher
- Docker (optional, for containerized deployment)
- OpenAI API key
- Create a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate- Install dependencies using
uv:
pip install uv
uv pip install -e .- Create a
.envfile in the project root with your OpenAI API key:
OPENAI_API_KEY=your_api_key_here- Build the Docker image:
docker build -t audr-project .- Run the container:
docker run -p 8000:8000 --env-file .env audr-projectStart the server:
uvicorn app.main:app --reloadThe application will automatically start when running the container as shown above.
The API will be available at http://localhost:8000
Once the server is running, you can access:
- Swagger UI documentation:
http://localhost:8000/docs - ReDoc documentation:
http://localhost:8000/redoc
{
"messages": [
{
"employee_id": "EMP001",
"message_text": "The new project timeline looks good, but we need more resources.",
"timestamp": "2024-03-27T10:00:00Z"
},
{
"employee_id": "EMP002",
"message_text": "I'm concerned about the budget constraints for Q2.",
"timestamp": "2024-03-27T10:15:00Z"
}
]
}{
"top_topics": [
{
"topic": "Project Timeline",
"frequency": 5
},
{
"topic": "Resources",
"frequency": 3
},
{
"topic": "Budget",
"frequency": 2
}
],
"ceo_summary": "Key concerns raised include project timeline management and resource allocation. Budget constraints for Q2 need attention.",
"sentiment_breakdown": {
"positive": 1,
"negative": 1,
"neutral": 0
}
}pytestThe project uses several tools for code quality:
rufffor linting and formattingmypyfor type checkingpytestfor testingpre-commithooks for automated checks
audr-project/
├── app/ # Main application package
│ ├── main.py # FastAPI application entry point
│ ├── models.py # Pydantic models
│ └── services.py # Business logic
├── tests/ # Test files
├── scripts/ # Utility scripts
├── pyproject.toml # Project dependencies and configuration
├── Dockerfile # Docker configuration
└── .env.example # Example environment variables