Skip to content
Merged

Dev #37

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">

<img src="https://raw.githubusercontent.com/vectorlessflow/vectorless/main/docs/design/logo-title.svg" alt="Vectorless" width="400" style="vertical-align:middle;">
<img src="https://raw.githubusercontent.com/vectorlessflow/vectorless/main/docs/design/with-title.png" alt="Vectorless" width="400" style="vertical-align:middle;">

<h1>Reasoning-native Document Intelligence Engine</h1>

Expand Down Expand Up @@ -43,7 +43,8 @@ from vectorless import Engine, IndexContext
engine = Engine(workspace="./data")

# Index a document (PDF, Markdown, DOCX, HTML)
doc_id = engine.index(IndexContext.from_file("./report.pdf"))
result = engine.index(IndexContext.from_file("./report.pdf"))
doc_id = result.doc_id

# Query
result = engine.query(doc_id, "What is the total revenue?")
Expand All @@ -60,7 +61,7 @@ vectorless = "0.1"
```

```rust
use vectorless::client::{Engine, EngineBuilder, IndexContext};
use vectorless::client::{EngineBuilder, IndexContext, QueryContext};

#[tokio::main]
async fn main() -> vectorless::Result<()> {
Expand All @@ -70,10 +71,13 @@ async fn main() -> vectorless::Result<()> {
.await?;

// Index
let doc_id = engine.index(IndexContext::from_path("./report.pdf")).await?;
let result = engine.index(IndexContext::from_path("./report.pdf")).await?;
let doc_id = result.doc_id().unwrap();

// Query
let result = engine.query(&doc_id, "What is the total revenue?").await?;
let result = engine.query(
QueryContext::new("What is the total revenue?").with_doc_id(doc_id)
).await?;
println!("Answer: {}", result.content);

Ok(())
Expand Down
Binary file added docs/design/with-title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 8 additions & 5 deletions examples/rust/advanced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
//! cargo run --example advanced
//! ```

use vectorless::{Engine, IndexContext};
use vectorless::{EngineBuilder, IndexContext, QueryContext};

#[tokio::main]
async fn main() -> vectorless::Result<()> {
println!("=== Vectorless Advanced Example (Full Configuration) ===\n");

// Method 1: Use explicit config file path
// This loads all settings from the specified config file
let client = Engine::builder()
let client = EngineBuilder::new()
.with_config_path("./config.toml") // or "./my_vectorless.toml"
.build()
.await
Expand All @@ -33,11 +33,14 @@ async fn main() -> vectorless::Result<()> {
println!("✓ Client created with config file\n");

// Index a document
let doc_id = client.index(IndexContext::from_path("./README.md")).await?;
let result = client.index(IndexContext::from_path("./README.md")).await?;
let doc_id = result.doc_id().unwrap().to_string();
println!("✓ Indexed: {}\n", doc_id);

// Query
let result = client.query(&doc_id, "What features does Vectorless provide?").await?;
let result = client
.query(QueryContext::new("What features does Vectorless provide?").with_doc_id(&doc_id))
.await?;
println!("Query: What features does Vectorless provide?");
println!("Score: {:.2}", result.score);
if !result.content.is_empty() {
Expand All @@ -55,7 +58,7 @@ async fn main() -> vectorless::Result<()> {
println!(" 2. Auto-detected config file (vectorless.toml, config.toml, .vectorless.toml)");
println!(" 3. Explicit config file (with_config_path)");
println!(" 4. Environment variables (OPENAI_API_KEY, VECTORLESS_MODEL, etc.)");
println!(" 5. Builder methods (with_openai, with_model, etc.)");
println!(" 5. Builder methods (with_key, with_model, with_endpoint)");
println!();
println!("Environment Variables:");
println!(" OPENAI_API_KEY - LLM API key");
Expand Down
35 changes: 16 additions & 19 deletions examples/rust/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,46 @@

//! Basic usage example for Vectorless.
//!
//! This example demonstrates the core API in ~30 lines.
//!
//! # Usage
//!
//! ```bash
//! cargo run --example basic
//! ```

use vectorless::{Engine, IndexContext};
use vectorless::{EngineBuilder, IndexContext, QueryContext};

#[tokio::main]
async fn main() -> vectorless::Result<()> {
println!("=== Vectorless Basic Example ===\n");

// 1. Create a client
let client = Engine::builder()
// 1. Create an engine
let engine = EngineBuilder::new()
.with_workspace("./workspace")
.build()
.await
.map_err(|e: vectorless::BuildError| vectorless::Error::Config(e.to_string()))?;

println!("✓ Client created\n");
println!("Engine created\n");

// 2. Index a document
let doc_id = client.index(IndexContext::from_path("./README.md")).await?;
println!("✓ Indexed: {}\n", doc_id);
let result = engine.index(IndexContext::from_path("./README.md")).await?;
let doc_id = result.doc_id().unwrap().to_string();
println!("Indexed: {}\n", doc_id);

// 3. List documents
println!("Documents:");
for doc in client.list_documents().await? {
for doc in engine.list().await? {
println!(" - {} ({})", doc.name, doc.id);
}
println!();

// 4. Query
match client.query(&doc_id, "What is vectorless?").await {
match engine
.query(QueryContext::new("What is vectorless?").with_doc_id(&doc_id))
.await
{
Ok(result) => {
println!("Query score: {:.2}", result.score);
println!("Score: {:.2}", result.score);
if !result.content.is_empty() {
let preview: String = result.content.chars().take(150).collect();
println!("Result: {}...", preview);
Expand All @@ -50,14 +52,9 @@ async fn main() -> vectorless::Result<()> {
}
println!();

// 5. Clone for concurrent use (client is Clone + Send + Sync)
let _client1 = client.clone();
let _client2 = client.clone();
println!("✓ Client cloned for concurrent use\n");

// 6. Cleanup
client.remove(&doc_id).await?;
println!("✓ Removed: {}", doc_id);
// 5. Cleanup
engine.remove(&doc_id).await?;
println!("Removed: {}", doc_id);

println!("\n=== Done ===");
Ok(())
Expand Down
Loading