77//! - [`Engine`] — The main client for indexing and querying documents
88//! - [`EngineBuilder`] — Builder pattern for client configuration
99//! - [`IndexContext`] — Unified input for document indexing
10- //! - [`Session`] — Multi-document session management
11- //!
12- //! # Architecture
13- //!
14- //! The client module is organized into specialized sub-modules:
15- //!
16- //! ```text
17- //! client/
18- //! ├── mod.rs → Re-exports and documentation
19- //! ├── engine.rs → Main orchestrator
20- //! ├── builder.rs → Builder pattern
21- //! ├── index_context.rs → Index input types
22- //! ├── types.rs → Public API types
23- //! ├── context.rs → Request context and configuration
24- //! ├── session.rs → Session management
25- //! ├── indexer.rs → Document indexing operations
26- //! ├── retriever.rs → Query and retrieval operations
27- //! ├── workspace.rs → Workspace CRUD operations
28- //! └── events.rs → Event system and callbacks
29- //! ```
10+ //! - [`QueryContext`] — Unified input for document queries
3011//!
3112//! # Quick Start
3213//!
3314//! ```rust,no_run
34- //! use vectorless::client::{Engine, EngineBuilder, IndexContext};
15+ //! use vectorless::client::{EngineBuilder, IndexContext, QueryContext };
3516//!
3617//! # #[tokio::main]
3718//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
4122//! .build()
4223//! .await?;
4324//!
44- //! // Index a document from file
45- //! let doc_id = client.index(IndexContext::from_path("./document.md")).await?;
46- //!
47- //! // Index HTML content directly
48- //! let html = "<html><body><h1>Title</h1><p>Content</p></body></html>";
49- //! let doc_id2 = client.index(
50- //! IndexContext::from_content(html, vectorless::parser::DocumentFormat::Html)
51- //! .with_name("webpage")
52- //! ).await?;
25+ //! // Index a document
26+ //! let result = client.index(IndexContext::from_path("./document.md")).await?;
27+ //! let doc_id = result.doc_id().unwrap();
5328//!
5429//! // Query the document
55- //! let result = client.query(&doc_id, "What is this?").await?;
30+ //! let result = client.query(
31+ //! QueryContext::new("What is this?").with_doc_id(doc_id)
32+ //! ).await?;
5633//! println!("{}", result.content);
5734//!
5835//! // List all documents
59- //! for doc in client.list_documents ().await? {
36+ //! for doc in client.list ().await? {
6037//! println!("{}: {}", doc.id, doc.name);
6138//! }
6239//! # Ok(())
6340//! # }
6441//! ```
6542//!
66- //! # Session-Based Operations
67- //!
68- //! For multi-document operations, use sessions:
69- //!
70- //! ```rust,no_run
71- //! # use vectorless::client::{Engine, EngineBuilder, IndexContext};
72- //! # #[tokio::main]
73- //! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
74- //! let client = EngineBuilder::new()
75- //! .with_workspace("./workspace")
76- //! .build()
77- //! .await?;
78- //!
79- //! let session = client.session().await;
80- //!
81- //! // Index multiple documents
82- //! let doc1 = session.index(IndexContext::from_path("./doc1.md")).await?;
83- //! let doc2 = session.index(IndexContext::from_path("./doc2.md")).await?;
84- //!
85- //! // Query across all documents
86- //! let results = session.query_all("What is the architecture?").await?;
87- //! # Ok(())
88- //! # }
89- //! ```
90- //!
9143//! # Events and Progress
9244//!
9345//! Monitor operation progress with events:
9446//!
9547//! ```rust,no_run
96- //! # use vectorless::client::{Engine, EngineBuilder, EventEmitter, IndexEvent};
48+ //! # use vectorless::client::{EngineBuilder, EventEmitter, IndexEvent};
9749//! # #[tokio::main]
9850//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
9951//! let events = EventEmitter::new()
10961//! # Ok(())
11062//! # }
11163//! ```
112- //!
113- //! # Features
114- //!
115- //! - **Document Indexing** — Parse and index Markdown, PDF, and text files
116- //! - **Tree-Based Structure** — Documents organized as hierarchical trees
117- //! - **Workspace Persistence** — Save and load indexed documents
118- //! - **Session Management** — Multi-document operations with caching
119- //! - **Event System** — Progress callbacks and monitoring
12064
12165mod builder;
12266mod context;
@@ -138,61 +82,28 @@ pub use builder::{BuildError, EngineBuilder};
13882pub use engine:: Engine ;
13983
14084// ============================================================
141- // Index Context
142- // ============================================================
143-
144- pub use index_context:: { IndexContext , IndexSource } ;
145-
146- // ============================================================
147- // Query Context
85+ // Context Types
14886// ============================================================
14987
88+ pub use index_context:: IndexContext ;
15089pub use query_context:: QueryContext ;
15190
15291// ============================================================
153- // Sub-Clients
92+ // Events
15493// ============================================================
15594
156- pub use indexer:: IndexerClient ;
157- pub use retriever:: RetrieverClient ;
158- pub use session:: Session ;
159- pub use workspace:: WorkspaceClient ;
95+ pub use events:: EventEmitter ;
16096
16197// ============================================================
162- // Context and Events
163- // ============================================================
164-
165- pub use context:: { ClientContext , FeatureFlags , RequestContextConfig } ;
166- pub use events:: {
167- AsyncEventHandler , Event , EventEmitter , EventHandler , IndexEvent , QueryEvent , WorkspaceEvent ,
168- } ;
169-
170- // ============================================================
171- // Types
98+ // Result & Info Types
17299// ============================================================
173100
174101pub use types:: {
175- // Error types
176102 ClientError ,
177- // Document info
178103 DocumentInfo ,
179- // Index types
180104 IndexItem ,
181105 IndexMode ,
182106 IndexOptions ,
183107 IndexResult ,
184- // Document types
185- IndexedDocument ,
186- PageContent ,
187- // Query types
188108 QueryResult ,
189109} ;
190-
191- // ============================================================
192- // Sub-Client Types
193- // ============================================================
194-
195- pub use indexer:: { IndexerConfig , ValidationResult } ;
196- pub use retriever:: { NodeContext , RetrieverClientConfig } ;
197- pub use session:: { EvictionPolicy , PreloadStrategy , SessionConfig , SessionStats } ;
198- pub use workspace:: { WorkspaceClientConfig , WorkspaceStats } ;
0 commit comments