-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig.rs
More file actions
79 lines (69 loc) · 2.03 KB
/
Copy pathconfig.rs
File metadata and controls
79 lines (69 loc) · 2.03 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
// Copyright (c) 2026 vectorless developers
// SPDX-License-Identifier: Apache-2.0
//! Config Python wrapper.
use pyo3::prelude::*;
/// Advanced configuration for Engine internals.
///
/// Create a Config to customize storage, retrieval, concurrency,
/// and other engine parameters beyond the basic builder API.
///
/// Example:
///
/// ```python
/// from vectorless import Config, Engine
///
/// config = Config()
/// config.set_workspace_dir("/data/vectorless")
/// config.set_top_k(10)
/// config.set_max_concurrent_requests(20)
///
/// engine = Engine(api_key="sk-...", model="gpt-4o", config=config)
/// ```
#[pyclass(name = "Config")]
pub struct PyConfig {
pub(crate) inner: vectorless::Config,
}
#[pymethods]
impl PyConfig {
/// Create a new Config with defaults.
#[new]
fn new() -> Self {
Self {
inner: vectorless::Config::default(),
}
}
/// Set the workspace directory for persisted documents.
///
/// Default: ~/.vectorless
fn set_workspace_dir(&mut self, dir: &str) {
self.inner.storage.workspace_dir = std::path::PathBuf::from(dir);
}
/// Set the number of top-k results to return from queries.
///
/// Default: 3
fn set_top_k(&mut self, k: usize) {
self.inner.retrieval.top_k = k;
}
/// Set the maximum concurrent LLM API calls.
///
/// Default: 10
fn set_max_concurrent_requests(&mut self, max: usize) {
self.inner.llm.throttle.max_concurrent_requests = max;
}
/// Set the rate limit (requests per minute).
///
/// Default: 500
fn set_requests_per_minute(&mut self, rpm: usize) {
self.inner.llm.throttle.requests_per_minute = rpm;
}
/// Set the maximum iterations for retrieval search.
fn set_max_iterations(&mut self, max: usize) {
self.inner.retrieval.search.max_iterations = max;
}
/// Enable or disable metrics collection.
///
/// Default: True
fn set_metrics_enabled(&mut self, enabled: bool) {
self.inner.metrics.enabled = enabled;
}
}