Skip to content

Commit ce0eda7

Browse files
authored
Merge pull request #25 from vectorlessflow/dev
Dev
2 parents 879c17d + e583086 commit ce0eda7

63 files changed

Lines changed: 2275 additions & 635 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,105 @@ async fn main() -> vectorless::Result<()> {
163163
| **Feedback Learning** | Improves from user feedback over time |
164164
| **Multi-turn Queries** | Handles complex questions with decomposition |
165165

166+
## Configuration
167+
168+
### Zero Configuration (Recommended)
169+
170+
Just set `OPENAI_API_KEY` and you're ready to go:
171+
172+
```bash
173+
export OPENAI_API_KEY="sk-..."
174+
```
175+
176+
<details>
177+
<summary><b>Python</b></summary>
178+
179+
```python
180+
from vectorless import Engine
181+
182+
# Uses OPENAI_API_KEY from environment
183+
engine = Engine(workspace="./data")
184+
```
185+
186+
</details>
187+
188+
<details>
189+
<summary><b>Rust</b></summary>
190+
191+
```rust
192+
use vectorless::Engine;
193+
194+
let client = Engine::builder()
195+
.with_workspace("./workspace")
196+
.build().await?;
197+
```
198+
199+
</details>
200+
201+
### Environment Variables
202+
203+
| Variable | Description |
204+
|----------|-------------|
205+
| `OPENAI_API_KEY` | LLM API key |
206+
| `VECTORLESS_MODEL` | Default model (e.g., `gpt-4o-mini`) |
207+
| `VECTORLESS_ENDPOINT` | API endpoint URL |
208+
| `VECTORLESS_WORKSPACE` | Workspace directory |
209+
210+
### Advanced Configuration
211+
212+
For fine-grained control, use a config file:
213+
214+
```bash
215+
cp config.toml ./vectorless.toml
216+
```
217+
218+
<details>
219+
<summary><b>Python</b></summary>
220+
221+
```python
222+
from vectorless import Engine
223+
224+
# Use full configuration file
225+
engine = Engine(config_path="./vectorless.toml")
226+
227+
# Or override specific settings
228+
engine = Engine(
229+
config_path="./vectorless.toml",
230+
model="gpt-4o", # Override model from config
231+
)
232+
```
233+
234+
</details>
235+
236+
<details>
237+
<summary><b>Rust</b></summary>
238+
239+
```rust
240+
use vectorless::Engine;
241+
242+
// Use full configuration file
243+
let client = Engine::builder()
244+
.with_config_path("./vectorless.toml")
245+
.build().await?;
246+
247+
// Or override specific settings
248+
let client = Engine::builder()
249+
.with_config_path("./vectorless.toml")
250+
.with_model("gpt-4o", None) // Override model
251+
.build().await?;
252+
```
253+
254+
</details>
255+
256+
### Configuration Priority
257+
258+
Later overrides earlier:
259+
260+
1. Default configuration
261+
2. Auto-detected config file (`vectorless.toml`, `config.toml`, `.vectorless.toml`)
262+
3. Explicit config file (`config_path` / `with_config_path`)
263+
4. Environment variables
264+
5. Constructor/builder parameters (highest priority)
166265

167266
## Architecture
168267

@@ -177,7 +276,7 @@ async fn main() -> vectorless::Result<()> {
177276

178277
## Examples
179278

180-
See the [examples/](examples/) directory.
279+
See the [examples/](examples/) directory for more usage patterns.
181280

182281
## Contributing
183282

docs/samples/sample.md

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -29,53 +29,4 @@ The core module provides fundamental types:
2929
The parser module handles document parsing:
3030
- `MarkdownParser` — Parse Markdown files
3131
- `PdfParser` — Parse PDF files (planned)
32-
- `HtmlParser` — Parse HTML files (planned)
33-
34-
## Usage Examples
35-
36-
### Basic Usage
37-
38-
```rust
39-
use vectorless::client::{Vectorless, VectorlessBuilder};
40-
41-
let client = VectorlessBuilder::new()
42-
.with_workspace("./workspace")
43-
.build()?;
44-
45-
let doc_id = client.index("./document.md").await?;
46-
```
47-
48-
### Advanced Usage
49-
50-
You can customize the retrieval process:
51-
52-
```rust
53-
use vectorless::{LlmNavigator, RetrieveOptions};
54-
55-
let retriever = LlmNavigator::with_defaults();
56-
let options = RetrieveOptions::new()
57-
.with_top_k(5)
58-
.with_min_score(0.5);
59-
60-
let results = retriever.retrieve(&tree, "What is vectorless?", &options).await?;
61-
```
62-
63-
## Configuration
64-
65-
The library can be configured via TOML files or programmatically.
66-
67-
### Configuration File
68-
69-
```toml
70-
[summary]
71-
model = "gpt-4"
72-
max_tokens = 200
73-
74-
[retrieval]
75-
model = "gpt-4"
76-
top_k = 3
77-
```
78-
79-
## API Reference
80-
81-
See the API documentation for detailed information about each function and type.
32+
- `HtmlParser` — Parse HTML files (planned)

examples/python/advanced/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Advanced Example - Full Configuration
2+
3+
Use a configuration file for fine-grained control.
4+
5+
## Setup
6+
7+
```bash
8+
pip install vectorless
9+
10+
# Copy the example config
11+
cp ../../../config.toml ./vectorless.toml
12+
13+
# Edit to customize your settings
14+
vim vectorless.toml
15+
```
16+
17+
## Run
18+
19+
```bash
20+
python main.py
21+
```
22+
23+
## Configuration File Structure
24+
25+
```toml
26+
[llm]
27+
api_key = "sk-..."
28+
29+
[llm.summary]
30+
model = "gpt-4o-mini"
31+
max_tokens = 200
32+
33+
[llm.retrieval]
34+
model = "gpt-4o"
35+
max_tokens = 100
36+
37+
[retrieval]
38+
top_k = 5
39+
beam_width = 3
40+
max_iterations = 10
41+
42+
[storage]
43+
workspace_dir = "./workspace"
44+
cache_size = 100
45+
```

examples/python/advanced/main.py

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Advanced example - Full Configuration File.
4+
5+
This example demonstrates how to use a full configuration file
6+
for fine-grained control over all settings.
7+
8+
Usage:
9+
cp ../../../config.toml ./vectorless.toml
10+
# Edit vectorless.toml to customize settings
11+
python main.py
12+
"""
13+
14+
import os
15+
from vectorless import Engine, IndexContext
16+
17+
# Path to config file (relative to this script)
18+
CONFIG_PATH = "./vectorless.toml"
19+
WORKSPACE = "./workspace"
20+
21+
22+
def main():
23+
print("=== Vectorless Advanced Example (Full Configuration) ===\n")
24+
25+
# Check if config file exists
26+
if not os.path.exists(CONFIG_PATH):
27+
print(f"Error: Config file not found: {CONFIG_PATH}")
28+
print("\nCreate it by copying the example:")
29+
print(f" cp ../../../config.toml {CONFIG_PATH}")
30+
print("\nThen edit it to customize your settings.")
31+
return
32+
33+
# Create engine with config file
34+
engine = Engine(config_path=CONFIG_PATH)
35+
36+
print(f"✓ Engine created with config file: {CONFIG_PATH}\n")
37+
38+
# Index a document
39+
content = """
40+
# System Documentation
41+
42+
## Architecture
43+
44+
The system consists of three main components:
45+
46+
1. **Index Pipeline** - Parses documents and builds a navigable tree
47+
2. **Retrieval Pipeline** - Queries and retrieves relevant content
48+
3. **Pilot** - LLM-powered navigation guide
49+
50+
## Configuration Options
51+
52+
### LLM Settings
53+
- `model`: The LLM model to use (e.g., "gpt-4o", "gpt-4o-mini")
54+
- `endpoint`: API endpoint URL
55+
- `api_key`: Your API key
56+
- `temperature`: Generation temperature (0.0 for deterministic)
57+
58+
### Retrieval Settings
59+
- `top_k`: Number of results to return
60+
- `max_iterations`: Maximum search iterations
61+
- `beam_width`: Beam width for multi-path search
62+
63+
### Storage Settings
64+
- `workspace_dir`: Directory for persisted documents
65+
- `cache_size`: LRU cache size
66+
- `compression`: Enable/disable compression
67+
68+
## Performance Tuning
69+
70+
For faster retrieval:
71+
- Use a smaller model like gpt-4o-mini
72+
- Reduce max_iterations
73+
- Enable caching
74+
75+
For higher accuracy:
76+
- Use a more capable model like gpt-4o
77+
- Increase beam_width
78+
- Enable multi-turn decomposition
79+
"""
80+
ctx = IndexContext.from_content(content, name="system_docs", format="markdown")
81+
doc_id = engine.index(ctx)
82+
print(f"✓ Indexed: {doc_id}\n")
83+
84+
# Query examples
85+
questions = [
86+
"What are the main components?",
87+
"How can I improve retrieval speed?",
88+
"What settings are available?",
89+
]
90+
91+
for q in questions:
92+
result = engine.query(doc_id, q)
93+
print(f"Q: {q}")
94+
print(f"A: {result.content[:150]}...")
95+
print(f" Score: {result.score:.2f}\n")
96+
97+
# Cleanup
98+
engine.remove(doc_id)
99+
print("✓ Cleaned up")
100+
101+
# Print configuration info
102+
print("\n" + "=" * 60)
103+
print("Configuration Priority")
104+
print("=" * 60)
105+
print("""
106+
1. Default configuration
107+
2. Auto-detected config file (vectorless.toml, config.toml)
108+
3. Explicit config file (config_path parameter)
109+
4. Environment variables (OPENAI_API_KEY, etc.)
110+
5. Constructor parameters (api_key, model, etc.)
111+
""")
112+
113+
114+
if __name__ == "__main__":
115+
main()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[project]
2+
name = "vectorless-advanced-example"
3+
version = "0.1.0"
4+
requires-python = ">=3.9"
5+
dependencies = [
6+
"vectorless",
7+
]
8+
9+
[build-system]
10+
requires = ["hatchling"]
11+
build-backend = "hatchling.build"

examples/python/basic/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Basic Example - Zero Configuration
2+
3+
The simplest way to use Vectorless.
4+
5+
## Setup
6+
7+
```bash
8+
pip install vectorless
9+
export OPENAI_API_KEY="sk-..."
10+
```
11+
12+
## Run
13+
14+
```bash
15+
python main.py
16+
```

0 commit comments

Comments
 (0)