-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
103 lines (83 loc) · 3.68 KB
/
Copy pathMakefile
File metadata and controls
103 lines (83 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# ==========================================================================
# chatMed local development / ops helpers
# ==========================================================================
.PHONY: infra infra-full infra-down qdrant-ready ollama-up models dev test index lock check lint clean eval eval-live eval-live-full smoke
OLLAMA_URL := http://localhost:11434/api/tags
QDRANT_URL := http://localhost:6333
## Start backing infra (Qdrant) for local dev
infra:
docker compose -f compose.yaml up -d
## Run the full containerized stack (Qdrant + the app behind the 'app' profile)
infra-full:
docker compose -f compose.yaml --profile app up -d --build
## Stop backing infra
infra-down:
docker compose -f compose.yaml down
## Wait until Qdrant answers /readyz (bounded ~15s) - closes the boot race
## where the app starts before Qdrant accepts connections
qdrant-ready:
@ok=0; i=1; while [ $$i -le 30 ]; do \
curl -sf -m 1 $(QDRANT_URL)/readyz >/dev/null && ok=1 && break; \
sleep 0.5; i=$$((i+1)); done; \
if [ $$ok -eq 1 ]; then echo "✓ Qdrant ready"; else \
echo "✗ Qdrant not ready (is 'make infra' up?)"; exit 1; fi
## Ensure an Ollama server is reachable at localhost:11434 (starts one if not)
ollama-up:
@if curl -sf -m 2 $(OLLAMA_URL) >/dev/null; then \
echo "✓ Ollama already running"; \
else \
echo "→ Starting Ollama..."; \
open -a Ollama 2>/dev/null || nohup ollama serve >>/tmp/chatmed-ollama.log 2>&1 & \
ok=0; i=1; while [ $$i -le 40 ]; do \
curl -sf -m 1 $(OLLAMA_URL) >/dev/null && ok=1 && break; \
sleep 0.5; i=$$((i+1)); done; \
if [ $$ok -eq 1 ]; then echo "✓ Ollama ready"; else \
echo "✗ Ollama failed to start (see /tmp/chatmed-ollama.log)"; exit 1; fi; \
fi
## Check/pull the Ollama models this app expects (idempotent)
models:
@for m in nomic-embed-text deepseek-r1:14b qwen2.5:3b; do \
curl -s $(OLLAMA_URL) | grep -q "\"$${m}" || { echo "→ pulling $${m}"; ollama pull $${m}; }; \
done; echo "✓ model check done"
## Run everything: infra + readiness gates, then the Chainlit app on :8000
dev: infra qdrant-ready ollama-up
@echo "→ App http://localhost:8000 · Qdrant http://localhost:6333/dashboard"
uv run chainlit run app.py
## Run the test suite
test:
uv run pytest -q
## Golden-set eval smoke (offline, no services needed)
eval:
uv run python -m evals.run_eval --mock --strict
## Golden-set eval against live Qdrant + embeddings (no LLM generation)
eval-live:
uv run python -m evals.run_eval --retrieval-only --index-corpus --strict
## Full live eval incl. streamed LLM answers (needs Ollama + Qdrant)
eval-live-full:
uv run python -m evals.run_eval --index-corpus
## Browser smoke harness (needs: uv sync --group smoke && uv run playwright install chromium)
smoke:
uv run --group smoke python browser_smoke.py
## Index PDFs under documents/ into Qdrant
index:
uv run python index_pdfs.py --dir documents
## Re-resolve uv.lock (CPU-only torch index to keep nvidia packages out)
lock:
uv lock --index-strategy unsafe-first-match \
--extra-index-url https://download.pytorch.org/whl/cpu
## Compile the Docker requirements.lock.txt from pyproject.toml
lockfile:
uv pip compile --universal --python-version 3.12 \
--index-strategy unsafe-first-match \
--extra-index-url https://download.pytorch.org/whl/cpu \
-o requirements.lock.txt pyproject.toml
## Syntax-check every module
check:
uv run python -m py_compile app.py index_pdfs.py middleware.py observability.py store.py citations.py
uv run python -m compileall -q rag evals
## Lint (ruff: pycodestyle/pyflakes/import-order/bugbear)
lint:
uv run ruff check .
## Remove caches and build artifacts
clean:
rm -rf __pycache__ .pytest_cache tests/__pycache__ *.egg-info evals/__pycache__