A minimal Flask web application that analyzes SEC filings to extract AI-related risk factors using OpenAI's API.
- Upload SEC filings in .txt format
- Automatically extract AI-related risk factors including:
- Artificial Intelligence (AI)
- Machine Learning (ML)
- Algorithms
- Automation
- Generative AI
- Large Language Models
- Get structured results with:
- Risk factor title
- Summary of the risk
- Confidence score (high/medium/low)
.
├── app.py # Flask application with routes and OpenAI integration
├── templates/
│ └── index.html # Upload form and results display
├── uploads/ # Directory for uploaded files (gitignored)
├── requirements.txt # Python dependencies
├── .env.example # Example environment variables
└── README.md # This file
cd claude-code-risk-factorspython -m venv venv
# On Linux/Mac:
source venv/bin/activate
# On Windows:
venv\Scripts\activatepip install -r requirements.txt-
Copy
.env.exampleto.env:cp .env.example .env
-
Get your OpenAI API key from: https://platform.openai.com/api-keys
-
Edit
.envand replaceyour_openai_api_key_herewith your actual API key:OPENAI_API_KEY=sk-...
python app.pyThe app will start on http://localhost:5000
- Open your browser and navigate to
http://localhost:5000 - Click "Choose File" and select a
.txtfile containing an SEC filing - Click "Analyze File"
- Wait for the analysis to complete
- View the extracted AI-related risk factors with their summaries and confidence scores
You can test the app with a sample SEC filing excerpt. Create a file called sample.txt with content like:
Risk Factors
We may face risks related to our use of artificial intelligence and machine learning
technologies. Our AI systems may produce unexpected results or biased outputs that could
harm our reputation or result in regulatory scrutiny. Additionally, we rely on large
language models and generative AI for customer service automation, which may fail to
meet customer expectations or violate data privacy regulations.
Our algorithms for content recommendation use complex machine learning models that
process user data. Changes in AI regulation, particularly in the European Union, could
require significant modifications to our systems and business practices.
- The app uses OpenAI's
gpt-4o-minimodel for cost-efficient analysis - Maximum file size: 16 MB
- Only
.txtfiles are supported - Files are temporarily stored in the
uploads/directory - The app uses standard Flask patterns (no async, minimal JavaScript)
For production use:
- Set
debug=Falseinapp.py - Use a production WSGI server like gunicorn:
gunicorn -w 4 -b 0.0.0.0:5000 app:app
- Set up proper environment variable management
- Configure HTTPS
- Implement rate limiting and authentication as needed
This app calls the OpenAI API for each file upload. Costs depend on:
- The length of the SEC filing
- The number of requests
- The OpenAI model used (currently
gpt-4o-mini)
Monitor your usage at: https://platform.openai.com/usage
This is a educational project for learning Flask and OpenAI API integration.