Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VINalyze — VIN Risk Scoring Service

A REST service that reads a vehicle CSV and, for a given VIN, returns a JSON report:

  • summary: short human-readable market position
  • risk_score: 1–10 (1=low risk, 10=high risk) — computed deterministically from CSV metrics
  • reasoning: concise explanation (from the LLM)

Requirements

  • Your Azure OpenAI resource deployed with a model (e.g., o4-mini) and deployment name
  • A CSV with columns: vin, make, model, year, price, price_to_market, days_on_lot, mileage, vdp_views, sales_opportunities
  • Docker (for container run) or Python 3.11+

Environment variables

Set these (match your setup):

# Azure resource endpoint (no trailing /openai/v1)
AZURE_OPENAI_ENDPOINT=https://<your-resource>.openai.azure.com

# API key (either name works)
AZURE_OPENAI_API_KEY=<key>   # preferred per docs
# or
AZURE_OPENAI_KEY=<key>

# Deployment name you created for the model (e.g., o4-mini)
AZURE_OPENAI_DEPLOYMENT=o4-mini

# Optional: lock a specific API version
AZURE_OPENAI_API_VERSION=2024-12-01-preview

# Path to your CSV (mounted into the container or local path)
CSV_PATH=/app/data/vehicles.csv

Note: The SDK call pattern follows the Azure Responses API examples (Python) where the client is created with OpenAI(base_url=..., api_key=...) and responses.create(...) (see Microsoft Learn).

Run locally (Python)

python -m venv .venv && source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -r requirements.txt

export AZURE_OPENAI_ENDPOINT="https://<your-resource>.openai.azure.com"
export AZURE_OPENAI_API_KEY="<your-key>"
export AZURE_OPENAI_DEPLOYMENT="o4-mini"
export AZURE_OPENAI_API_VERSION="2024-12-01-preview"   # optional
export CSV_PATH="<absolute/path/to/your/vehicles.csv>"

uvicorn app.main:app --reload --port 8000

Run in Docker

docker build -t VINalyze .
docker run --rm -p 8000:8000 \
  -e AZURE_OPENAI_ENDPOINT="https://<your-resource>.openai.azure.com" \
  -e AZURE_OPENAI_API_KEY="<your-key>" \
  -e AZURE_OPENAI_DEPLOYMENT="o4-mini" \
  -e AZURE_OPENAI_API_VERSION="2024-12-01-preview" \
  -e CSV_PATH="/app/data/vehicles.csv" \
  -v /absolute/path/to/your.csv:/app/data/vehicles.csv:ro \
  VINalyze

Test the API

  1. Get a few VINs to test:
curl http://localhost:8000/vins
  1. Request a report:
curl -X POST http://localhost:8000/report \
  -H "Content-Type: application/json" \
  -d '{"vin": "PUT_A_VIN_FROM_YOUR_CSV_HERE"}'

PowerShell:

Invoke-RestMethod -Method Post "http://localhost:8000/report" `
  -ContentType "application/json" `
  -Body (@{ vin = "PUT_A_VIN" } | ConvertTo-Json)

The response is a strict JSON object:

{
  "summary": "",
  "risk_score": 7,
  "reasoning": ""
}

CSV

Place your CSV at data/vehicles.csv or set CSV_PATH to your file. The service loads it once at startup.

Notes & Troubleshooting

  • If you see LLM call failed: Missing AZURE_OPENAI_ENDPOINT (or KEY/DEPLOYMENT), double‑check your env vars.
  • If your Azure stack requires an explicit api-version, set AZURE_OPENAI_API_VERSION (the client will attach it).
  • The LLM is only used to craft summary and reasoning. The numeric risk_score is computed deterministically so tests are reproducible.

License

MIT

Azure Resource Naming

  • Resource Name: VINalyze
  • Project Name: VINalyze Use these names consistently in Azure AI Studio/Foundry and your deployment’s AZURE_OPENAI_DEPLOYMENT (e.g., o4-mini).

About

A REST service that reads a vehicle CSV and, for a given VIN, returns a JSON report:

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages