Skip to content

Commit 0afc4f0

Browse files
committed
update readme and config
1 parent e86dcbc commit 0afc4f0

5 files changed

Lines changed: 46 additions & 36 deletions

File tree

README.md

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import contextdb
4343
db = contextdb.open("my_docs.sqlite")
4444

4545
# Configure LLM
46-
db.set_llm(provider="anthropic", model="claude-sonnet-4-20250514")
46+
db.set_llm(provider="anthropic", model="claude-sonnet-4-6")
4747

4848
# Store a document tree
4949
tree_id = db.store(document_tree_json, format="document")
@@ -75,20 +75,31 @@ ct.close()
7575

7676
## Configuration
7777

78-
Create a `.env` file:
78+
Create a `.env` file with your API keys:
7979

8080
```
8181
ANTHROPIC_API_KEY=sk-...
8282
OPENAI_API_KEY=sk-...
83-
LLM_PROVIDER=anthropic
84-
LLM_MODEL=claude-sonnet-4-20250514
8583
```
8684

87-
Or configure programmatically:
85+
Model and provider settings live in `contextdb/config/config.yaml`:
8886

89-
```python
90-
from contextdb.config import Config
91-
llm = Config.get_llm_client()
87+
```yaml
88+
llm:
89+
provider: anthropic # anthropic or openai
90+
model: claude-sonnet-4-6 # any model the provider supports
91+
context_limit: 100000
92+
max_concurrent: 10
93+
94+
retriever:
95+
beam_size: 3
96+
max_turns: 5
97+
```
98+
99+
Override at runtime with environment variables:
100+
101+
```bash
102+
LLM_MODEL=claude-opus-4-6 python your_script.py
92103
```
93104

94105
---
@@ -114,17 +125,25 @@ result = db.query(tree_id, "question", strategy="block", beam_size=3)
114125

115126
Current filesystem benchmark summary lives in [bench/fs_block_beam_vertical.md](bench/fs_block_beam_vertical.md).
116127

117-
Run setup for the snapshot below: `beam_size=3`, `max_turns=10`, `5` filesystem queries on `context7` only.
128+
Run setup: `fs_query_order=prefix`, `beam_size=3`, `max_turns=10`, `5` filesystem queries on `context7` only.
129+
130+
### Claude Opus 4.6
131+
132+
| Retriever | Avg Time (s) | Avg LLM Calls | Hit@1 | Hit@10 | Total Cost (USD) |
133+
|---|---:|---:|---:|---:|---:|
134+
| **Block** | 9.27 | 2.6 | 1.00 | 1.00 | 0.1416 |
135+
| **Vertical** | 22.85 | 6.8 | 0.40 | 1.00 | 0.1682 |
136+
| **Beam** | 18.37 | 5.0 | 0.60 | 1.00 | 0.1331 |
118137

119-
### Block vs Beam vs Vertical
138+
### Claude Sonnet 4.6
120139

121140
| Retriever | Avg Time (s) | Avg LLM Calls | Hit@1 | Hit@10 | Total Cost (USD) |
122141
|---|---:|---:|---:|---:|---:|
123-
| **Block** | 5.47 | 1.00 | 1.00 | 1.00 | 0.0762 |
124-
| **Vertical** | 7.31 | 1.60 | 1.00 | 1.00 | 0.1486 |
125-
| **Beam** | 20.18 | 4.60 | 0.60 | 0.80 | 0.1328 |
142+
| **Block** | 7.95 | 2.8 | 1.00 | 1.00 | 0.1670 |
143+
| **Vertical** | 17.85 | 5.8 | 0.40 | 0.80 | 0.1438 |
144+
| **Beam** | 17.41 | 4.8 | 0.60 | 1.00 | 0.1338 |
126145

127-
`Block` is the best default on this `context7` snapshot: same retrieval quality as `Vertical`, with lower latency and fewer model calls. `Beam` is still workable, but it trails clearly on retrieval accuracy.
146+
`Block` is the best default: perfect Hit@1 across both models. `Beam` and `Vertical` are sensitive to model version — `Block` is the most robust choice.
128147

129148
These numbers are benchmark snapshots, not hard guarantees; exact cost and latency will vary with model choice, provider pricing, prompt-cache behavior, and corpus shape.
130149

contextdb/config/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def _load_yaml(path: Path) -> dict:
2424

2525
def get_defaults() -> dict:
2626
"""Get default configuration."""
27-
return _load_yaml(CONFIG_DIR / "defaults.yaml")
27+
return _load_yaml(CONFIG_DIR / "config.yaml")
2828

2929

3030
def get_llm_config(provider: str, model: str) -> dict:
@@ -60,12 +60,16 @@ def get_retriever_config(retriever_type: str) -> dict:
6060

6161

6262
class Config:
63-
"""Configuration class for environment variables and LLM client."""
63+
"""Configuration: .env for keys, config.yaml for settings, env vars override."""
6464

65+
# Keys — from .env only
6566
ANTHROPIC_API_KEY = os.getenv("ANTHROPIC_API_KEY")
6667
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
67-
LLM_PROVIDER = os.getenv("LLM_PROVIDER", "anthropic")
68-
LLM_MODEL = os.getenv("LLM_MODEL", "claude-sonnet-4-20250514")
68+
69+
# Settings — config.yaml, env vars override
70+
_cfg = get_defaults().get("llm", {})
71+
LLM_PROVIDER = os.getenv("LLM_PROVIDER") or _cfg.get("provider", "anthropic")
72+
LLM_MODEL = os.getenv("LLM_MODEL") or _cfg.get("model", "claude-sonnet-4-6")
6973
DB_PATH = os.getenv("DB_PATH", "context.sqlite")
7074

7175
@classmethod
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# Default configuration
1+
# ConDB configuration
22

33
llm:
44
provider: anthropic
5-
model: claude-sonnet-4-20250514
5+
model: claude-sonnet-4-6
66
context_limit: 100000
77
max_concurrent: 10
88

99
retriever:
10-
tokens_per_node: 300
1110
beam_size: 3
1211
max_turns: 5
Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
11
# Anthropic models configuration
22

3-
claude-sonnet-4-20250514:
3+
claude-opus-4-6:
44
context_limit: 200000
55
max_concurrent: 50
66
rpm_limit: 4000
77
tpm_limit: 400000
88

9-
claude-opus-4-20250514:
9+
claude-sonnet-4-6:
1010
context_limit: 200000
1111
max_concurrent: 50
1212
rpm_limit: 4000
1313
tpm_limit: 400000
14-
15-
claude-3-5-sonnet-20241022:
16-
context_limit: 200000
17-
max_concurrent: 50
18-
rpm_limit: 4000
19-
tpm_limit: 400000
20-
21-
claude-3-haiku-20240307:
22-
context_limit: 200000
23-
max_concurrent: 100
24-
rpm_limit: 4000
25-
tpm_limit: 400000

contextdb/llm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def _build_messages(messages: list[dict], system: str = "") -> list[dict]:
180180
# ── Default models ────────────────────────────────────────────────
181181

182182
_DEFAULT_MODELS = {
183-
"anthropic": "claude-sonnet-4-20250514",
183+
"anthropic": "claude-sonnet-4-6",
184184
"openai": "gpt-4",
185185
}
186186

0 commit comments

Comments
 (0)