Tiny FastAPI demo that uses Groq + LangChain to score how disruptive a company is. Pulls real-time data from Yahoo Finance (yfinance) and returns clean JSON.
The API validates the stock ticker, fetches company info, and then generates a short JSON report containing:
summary: 3-sentence disruptor explanationrisk_score(1–5)opportunity_score(1–5)
- Validates real stock tickers
- Fetches live company data from Yahoo Finance
- Forces the LLM to return valid JSON (using Pydantic output parser)
- Proper error handling (400/404/500 with clear messages)
- Python 3.11+
- uv (faster than pip/poetry, recommended)
- Install uv if you don’t have it:
pip install uv # or brew install uv, or curl -LsSf https://astral.sh/uv/install.sh | sh-
Clone the repo and cd into it
-
Install dependencies
- With
pyproject.toml(creates venv + installs all deps including dev):
uv sync --frozen- With
requirements.txtonly:
py -m venv .venv
.venv/scripts/activate
pip install -r requirements.txt- Configure your .env
cp .env.example .envThen edit .env and add your Groq key:
GROQ_API_KEY=gsk_your_key_here
Get one for free at: https://console.groq.com/keys
uv run fastapi devor
fastapi devSwagger docs → http://127.0.0.1:8000/docs
POST /score-company
Request Body
{
"ticker": "NVDA"
}Example Response
{
"ticker": "NVDA",
"summary": "NVIDIA basically prints money with AI chips and has a near monopoly on training hardware...",
"risk_score": 2,
"opportunity_score": 5
}400→ invalid ticker (numbers, too long, garbage)404→ ticker doesn’t exist on Yahoo Finance500→ LLM returned invalid JSON (rare with Groq + output parser)