Skip to content

Commit 506c46c

Browse files
Merge pull request #6 from VectifyAI/v0.3
update readme and config
2 parents 32704f0 + 0afc4f0 commit 506c46c

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
@@ -63,7 +63,7 @@ import contextdb
6363
db = contextdb.open("my_docs.sqlite")
6464

6565
# Configure LLM
66-
db.set_llm(provider="anthropic", model="claude-sonnet-4-20250514")
66+
db.set_llm(provider="anthropic", model="claude-sonnet-4-6")
6767

6868
# Store a document tree
6969
tree_id = db.store(document_tree_json, format="document")
@@ -93,20 +93,31 @@ ct.close()
9393

9494
### Configuration
9595

96-
Create a `.env` file:
96+
Create a `.env` file with your API keys:
9797

9898
```
9999
ANTHROPIC_API_KEY=sk-...
100100
OPENAI_API_KEY=sk-...
101-
LLM_PROVIDER=anthropic
102-
LLM_MODEL=claude-sonnet-4-20250514
103101
```
104102

105-
Or configure programmatically:
103+
Model and provider settings live in `contextdb/config/config.yaml`:
106104

107-
```python
108-
from contextdb.config import Config
109-
llm = Config.get_llm_client()
105+
```yaml
106+
llm:
107+
provider: anthropic # anthropic or openai
108+
model: claude-sonnet-4-6 # any model the provider supports
109+
context_limit: 100000
110+
max_concurrent: 10
111+
112+
retriever:
113+
beam_size: 3
114+
max_turns: 5
115+
```
116+
117+
Override at runtime with environment variables:
118+
119+
```bash
120+
LLM_MODEL=claude-opus-4-6 python your_script.py
110121
```
111122

112123
---
@@ -132,17 +143,25 @@ result = db.query(tree_id, "question", strategy="block", beam_size=3)
132143

133144
Current filesystem benchmark summary lives in [bench/fs_block_beam_vertical.md](bench/fs_block_beam_vertical.md).
134145

135-
Run setup for the snapshot below: `beam_size=3`, `max_turns=10`, `5` filesystem queries on `context7` only.
146+
Run setup: `fs_query_order=prefix`, `beam_size=3`, `max_turns=10`, `5` filesystem queries on `context7` only.
147+
148+
### Claude Opus 4.6
149+
150+
| Retriever | Avg Time (s) | Avg LLM Calls | Hit@1 | Hit@10 | Total Cost (USD) |
151+
|---|---:|---:|---:|---:|---:|
152+
| **Block** | 9.27 | 2.6 | 1.00 | 1.00 | 0.1416 |
153+
| **Vertical** | 22.85 | 6.8 | 0.40 | 1.00 | 0.1682 |
154+
| **Beam** | 18.37 | 5.0 | 0.60 | 1.00 | 0.1331 |
136155

137-
### Block vs Beam vs Vertical
156+
### Claude Sonnet 4.6
138157

139158
| Retriever | Avg Time (s) | Avg LLM Calls | Hit@1 | Hit@10 | Total Cost (USD) |
140159
|---|---:|---:|---:|---:|---:|
141-
| **Block** | 5.47 | 1.00 | 1.00 | 1.00 | 0.0762 |
142-
| **Vertical** | 7.31 | 1.60 | 1.00 | 1.00 | 0.1486 |
143-
| **Beam** | 20.18 | 4.60 | 0.60 | 0.80 | 0.1328 |
160+
| **Block** | 7.95 | 2.8 | 1.00 | 1.00 | 0.1670 |
161+
| **Vertical** | 17.85 | 5.8 | 0.40 | 0.80 | 0.1438 |
162+
| **Beam** | 17.41 | 4.8 | 0.60 | 1.00 | 0.1338 |
144163

145-
`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.
164+
`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.
146165

147166
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.
148167

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)