Agentic AI Decision Engine is a business-oriented demo that turns product and competitor inputs into actionable pricing decisions. It is built for presentations, interviews, and workshops, with a polished UI aimed at executive-style storytelling.
The flow is:
- Data ingestion: Product from DummyJSON (external catalog simulation) or a manual product (SKU / what-if).
- Competitor benchmarking: Title + price rows (typed in, or example competitors loaded from the same DummyJSON catalog via API).
- Decision engine: With
OPENAI_API_KEY, you can use LLM reasoning (use_llm: true, or the default when a key is present). Without a key, or with simulated mode, deterministic rules drive pricing, promotion, and inventory guidance using the same JSON shape. - Presentation layer: HTML UI at
/with a decision hero, confidence, insight, product context, and a visual price comparison; stable contract onPOST /v1/decisions.
This is not a replacement for an ERP or enterprise pricing platform. It demonstrates how AI can structure real or simulated inputs into business-ready outputs.
- Start the API (see Quick start), open
http://127.0.0.1:8000/, enter a Product ID, click Fetch product, review competitors (or Load example competitors), choose Use AI (LLM) or Simulated logic, then Get Pricing Recommendation. A guided tour is available in the header. /docs: OpenAPI; tryPOST /v1/decisionswithproduct_idorproduct+competitors, and optionaluse_llm.GET /api/readiness:openai_configured,llm_decisions_ready,rag_ready, etc. (no secrets exposed).
Use Python 3.10+ (3.11 recommended; the repo may include .python-version).
python3.11 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# Optional FAISS index (RAG extension / demos)
python scripts/build_index.py
# Optional: OpenAI embeddings when building the index
export OPENAI_API_KEY=...
export EMBEDDING_MODE=embedding-3-small
python scripts/build_index.py
make dev
# or: uvicorn api.index:app --reload --host 0.0.0.0 --port 8000Open http://localhost:8000/docs for interactive API documentation.
curl -s http://localhost:8000/v1/decisions \
-H 'content-type: application/json' \
-d @- <<'JSON'
{
"product_id": 1,
"use_llm": false,
"competitors": [
{ "title": "Brand A", "price": 100 },
{ "title": "Brand B", "price": 130 }
]
}
JSONThe response includes product, competitors, decisions (strategy, recommended price, promotion, inventory, reasoning, and confidence when applicable), source (dummyjson API | manual), and decision_engine (llm | simulated).
GET /api/example-competitors/{product_id}?limit=3Returns suggested peer rows from the same catalog (same category when possible).
See .env.example. Important variables:
| Variable | Purpose |
|---|---|
OPENAI_API_KEY |
Enables LLM mode on /v1/decisions (unless use_llm forces otherwise). |
OPENAI_CHAT_MODEL |
Defaults to gpt-4o-mini. |
EMBEDDING_MODE |
embedding-3-small or pseudo (offline). |
OPENAI_EMBEDDING_MODEL |
Defaults to text-embedding-3-small. |
Query-time embeddings must stay consistent with how the FAISS index was built.
- Blueprint:
render.yaml(install dependencies, runscripts/build_index.py, startuvicornon$PORT). - Health:
GET /health. - Set
OPENAI_API_KEYas a secret if you use LLM or OpenAI embeddings at build time.
pytestapi/index.py # FastAPI (demo HTML, decisions, DummyJSON)
app/services/ # ai_decision_engine (LLM), rule_decisions (simulated)
app/integrations/ # dummyjson.py
app/rag/ # FAISS + retriever (extension)
app/static/demo.html # Demo UI
docs/images/mvp.png # MVP screenshot
- The MVP does not require an external database; the RAG corpus is versioned JSON plus an on-disk index.
- DummyJSON is sample data; production would wire real sources and policies.
Rusben Madrigal
San José, Costa Rica
- LinkedIn: linkedin.com/in/rusmadrigal
- GitHub: @rusmadrigal
- Website: www.rusmadrigal.com
