Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Refer to the [Installation section](https://getdozer.io/docs/installation) for i
| | [IMDB Analytics](./usecases/imdb-analytics) | Use Dozer to get interesting analytics using an IMDb dataset |
| | Use Dozer to Instrument (Coming soon) | Combine Log data to get real time insights |
| | Real Time Model Scoring (Coming soon) | Deploy trained models to get real time insights as APIs |
| | [LLM Vector Banking Chatbot](./usecases/llm-vector-banking-chatbot) | Dozer + LangChain + vector retrieval for card personalization (#1690) |
| | | |
| Client Libraries | [Dozer React Starter](./usecases/react/) | Instantly start building real time views using Dozer and React |
| | [Ingest Polars/Pandas Dataframes](./client-samples/ingest-python-sample) | Instantly ingest Polars/Pandas dataframes using Arrow format and deploy APIs |
Expand Down
9 changes: 9 additions & 0 deletions usecases/llm-vector-banking-chatbot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.dozer/
__pycache__/
*.pyc
.venv/
venv/
.env
.chroma/
*.egg-info/
.pytest_cache/
105 changes: 105 additions & 0 deletions usecases/llm-vector-banking-chatbot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Dozer + LLM + Vector DB + LangChain (Banking Chatbot)

Sample for [getdozer/dozer#1690](https://github.com/getdozer/dozer/issues/1690) ($250 Algora).

Inspired by the Dozer hyper-personalization banking chatbot write-up: unify customer
profiles, accounts, and transactions in Dozer, then pass that context into a LangChain
retrieval flow over credit-card products (vector store + optional LLM).

## What this sample includes

| Piece | Path | Role |
| --- | --- | --- |
| Dozer config | `dozer-config.yaml` | LocalStorage CSV sources + spend-profile SQL + REST endpoints |
| Seed data | `data/*/*.csv` | customers, accounts, transactions, card products |
| RAG stub | `app/rag_chatbot.py` | fixture mode (offline) + `--use-dozer` + optional `--llm` |
| Unit tests | `tests/test_rag_chatbot.py` | fixture load, segment gate, keyword/rerank |
| Deps | `app/requirements.txt` | LangChain / Chroma / OpenAI (optional) |
| Demo log | `demo-log.txt` | text capture of live Dozer REST + chatbot (no video yet) |

## Prerequisites

- **Dozer 0.3.x** on `PATH` for the live path (API-era binary with `endpoints`).
Dozer **≥0.4.0** removed built-in `endpoints` / `dozer-api` — that binary will reject
this config. See [`SAMPLE_NOTES.md`](./SAMPLE_NOTES.md).
- Python 3.10+
- `protoc` (`protobuf-compiler`) for `dozer build` on 0.3.x
- Optional: `OPENAI_API_KEY` for the ChatOpenAI answer path

## Quick start (offline fixture — no Dozer binary)

```bash
cd usecases/llm-vector-banking-chatbot
python3 app/rag_chatbot.py \
--customer C001 \
--question "Which card is best for travel and dining rewards?"
```

Expected shape: a recommendation for **Dozer Travel Signature** grounded in C001's
travel/dining spend.

Student example:

```bash
python3 app/rag_chatbot.py \
--customer C003 \
--question "I need a no-fee student card for education"
```

## Live Dozer path (verified on 0.3.0)

```bash
cd usecases/llm-vector-banking-chatbot
rm -rf .dozer
dozer --ignore-pipe build -c dozer-config.yaml
dozer --ignore-pipe run -c dozer-config.yaml
# elsewhere:
python3 -m venv .venv && .venv/bin/pip install -r app/requirements.txt
.venv/bin/python app/rag_chatbot.py --use-dozer --customer C001 \
--question "Which card is best for travel and dining rewards?"
```

Dozer REST listens at `http://localhost:8080` (override with `--dozer-base` or
`DOZER_API_BASE`). Responses are bare JSON lists; the client filters by `customer_id`.

Optional LLM polish:

```bash
export OPENAI_API_KEY=sk-...
.venv/bin/python app/rag_chatbot.py --use-dozer --llm --customer C001 \
--question "Which card is best for travel and dining rewards?"
```

## Tests

```bash
cd usecases/llm-vector-banking-chatbot
python3 -m venv .venv && .venv/bin/pip install pytest httpx
.venv/bin/pytest -q tests/test_rag_chatbot.py
```

## APIs exposed (once Dozer 0.3.x is up)

- `GET /customer_profiles`
- `GET /accounts`
- `GET /transactions`
- `GET /card_products`
- `GET /customer_spending_profile` — SQL aggregate used as chatbot context

## Architecture (sample)

```
CSV seeds ──► Dozer LocalStorage ──► SQL spend profile ──► REST/gRPC APIs
│
LangChain retriever (Chroma / FakeEmbeddings) │
+ customer-aware rerank ◄─────────────────────┘
│
deterministic answer or ChatOpenAI (--llm)
```

## Status / honesty

See [`SAMPLE_NOTES.md`](./SAMPLE_NOTES.md). Live `dozer run` (0.3.0) + `--use-dozer`
chatbot verified; text demo log attached. **No payout claimed.** Demo *video* and
maintainer confirmation of bounty eligibility remain open. Crowded claim field
(`dozer-samples` #139–#145, etc.).
62 changes: 62 additions & 0 deletions usecases/llm-vector-banking-chatbot/SAMPLE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# SAMPLE_NOTES — getdozer/dozer#1690

**Branch:** `bounty/1690-llm-vector-banking-scaffold`
**PR:** https://github.com/getdozer/dozer-samples/pull/144
**Issue:** https://github.com/getdozer/dozer/issues/1690
**Bounty:** $250 Algora — Dozer + LLM + Vector DB + LangChain sample

## Do NOT invent payout success

No maintainer acceptance, no Algora payout confirmation. Multiple competing open PRs
(`dozer-samples` #139–#145 and others). Algora may already show claims/completed —
treat reward eligibility as **uncertain**.

## What works now (verified locally)

| Check | Result |
| --- | --- |
| Offline fixture chatbot | OK (C001→Travel Signature, C003→Campus Starter) |
| `dozer build/run` **0.3.0** against `dozer-config.yaml` | OK (`--ignore-pipe`; needs `protoc` + OpenSSL 1.1) |
| REST `GET /customer_profiles`, `/customer_spending_profile`, `/card_products` | 200, bare JSON lists |
| `rag_chatbot.py --use-dozer` | OK after client-side customer filter fix |
| Unit tests `tests/test_rag_chatbot.py` | 7 passed |
| Text demo log | `demo-log.txt` |
| Demo **video** | **Still missing** |

### Commands that succeeded

```text
dozer --ignore-pipe build -c dozer-config.yaml # dozer 0.3.0
dozer --ignore-pipe run -c dozer-config.yaml
python3 app/rag_chatbot.py --use-dozer --customer C001 --question "Which card is best for travel and dining rewards?"
python3 app/rag_chatbot.py --use-dozer --customer C003 --question "I need a no-fee student card for education"
pytest -q tests/test_rag_chatbot.py # 7 passed
```

## Config / client fixes in this follow-up

1. Explicit `api.rest` / `api.grpc` host+port (8080 / 50051).
2. Composite PK on `customer_spending_profile`: `customer_id` + `top_category`
(matches `GROUP BY customer_id, category`).
3. `--use-dozer` no longer trusts `?customer_id=` (0.3 ignores it and would always
pick the first profile); always filter client-side on bare lists.
4. Document that **Dozer ≥0.4.0 rejects `endpoints`** (`unknown field endpoints`;
sinks-only era). This sample targets the API-era 0.3.x binary that matches the
historical LocalStorage samples in this repo.

## Remaining gaps

1. **No demo video** (Algora often wants ≤30s screen capture).
2. **Architecture drift:** issue comments note current main may prefer
Dozer→sink→app API. This PR intentionally stays on 0.3-style REST endpoints to
match existing `dozer-samples` patterns; maintainers may ask for a sink rewrite.
3. **Blog URL** `https://getdozer.io/blog/llm-chatbot` still 404 when last checked.
4. **Crowded claims** — many open PRs; confirm with maintainers before banking on $250.
5. Optional Chroma/LangChain path needs `pip install -r app/requirements.txt`; tests
and live demo use keyword retrieve + fixture/Dozer context without Chroma.

## Confidence

**~0.70** that this is a credible, runnable sample PR after live verify + tests.
**~0.20** that it wins $250 given competition + possible architecture preference for
sinks — **do not bank on payout**.
1 change: 1 addition & 0 deletions usecases/llm-vector-banking-chatbot/app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""LangChain RAG stub for the Dozer banking chatbot sample."""
Loading