Python bindings for vectorless — a reasoning-native document intelligence engine for AI.
pip install vectorlessimport asyncio
from vectorless import Engine, IndexContext, QueryContext
async def main():
# Create engine — api_key and model are required
engine = Engine(
api_key="sk-...",
model="gpt-4o",
)
# Index a document
result = await engine.index(IndexContext.from_path("./report.pdf"))
doc_id = result.doc_id
print(f"Indexed: {doc_id}")
# Query the document
result = await engine.query(
QueryContext("What is the total revenue?").with_doc_ids([doc_id])
)
item = result.single()
print(f"Answer: {item.content}")
print(f"Score: {item.score:.2f}")
# List all documents
for doc in await engine.list():
print(f" - {doc.name} ({doc.id})")
# Cleanup
await engine.remove(doc_id)
asyncio.run(main())The main entry point for vectorless.
class Engine:
def __init__(
self,
config_path: str | None = None,
api_key: str | None = None,
model: str | None = None,
endpoint: str | None = None,
): ...
async def index(self, ctx: IndexContext) -> IndexResult: ...
async def query(self, ctx: QueryContext) -> QueryResult: ...
async def list(self) -> list[DocumentInfo]: ...
async def remove(self, doc_id: str) -> bool: ...
async def clear(self) -> int: ...
async def exists(self, doc_id: str) -> bool: ...
async def get_graph(self) -> DocumentGraph | None: ...Context for indexing documents.
class IndexContext:
@staticmethod
def from_path(path: str, name: str | None = None) -> IndexContext: ...
@staticmethod
def from_paths(paths: list[str]) -> IndexContext: ...
@staticmethod
def from_dir(path: str, recursive: bool = True) -> IndexContext: ...
@staticmethod
def from_content(
content: str,
name: str | None = None,
format: str = "markdown",
) -> IndexContext: ...
@staticmethod
def from_bytes(
data: bytes,
name: str,
format: str,
) -> IndexContext: ...
def with_options(self, options: IndexOptions) -> IndexContext: ...
def with_mode(self, mode: str) -> IndexContext: ...Supported formats:
"markdown"/"md"- Markdown content"pdf"- PDF documents
Context for querying documents.
class QueryContext:
def __init__(self, query: str): ...
def with_doc_ids(self, doc_ids: list[str]) -> QueryContext: ...
def with_workspace(self) -> QueryContext: ...
def with_max_tokens(self, tokens: int) -> QueryContext: ...
def with_include_reasoning(self, include: bool) -> QueryContext: ...
def with_depth_limit(self, depth: int) -> QueryContext: ...class IndexResult:
@property
def doc_id(self) -> str | None: ...
@property
def items(self) -> list[IndexItem]: ...
@property
def failed(self) -> list[FailedItem]: ...
def has_failures(self) -> bool: ...
def total(self) -> int: ...
def __len__(self) -> int: ...class QueryResult:
@property
def items(self) -> list[QueryResultItem]: ...
@property
def failed(self) -> list[FailedItem]: ...
def single(self) -> QueryResultItem | None: ...
def has_failures(self) -> bool: ...
def __len__(self) -> int: ...class QueryResultItem:
@property
def doc_id(self) -> str: ...
@property
def content(self) -> str: ...
@property
def score(self) -> float: ...
@property
def node_ids(self) -> list[str]: ...class IndexItem:
@property
def doc_id(self) -> str: ...
@property
def name(self) -> str: ...
@property
def format(self) -> str: ...
@property
def description(self) -> str | None: ...
@property
def source_path(self) -> str | None: ...
@property
def page_count(self) -> int | None: ...
@property
def metrics(self) -> IndexMetrics | None: ...class DocumentInfo:
@property
def id(self) -> str: ...
@property
def name(self) -> str: ...
@property
def format(self) -> str: ...
@property
def description(self) -> str | None: ...
@property
def source_path(self) -> str | None: ...
@property
def page_count(self) -> int | None: ...
@property
def line_count(self) -> int | None: ...class VectorlessError(Exception):
@property
def message(self) -> str: ...
@property
def kind(self) -> str: ... # "config", "parse", "not_found", "llm"# Install maturin
pip install maturin
# Build and install (from project root)
maturin develop
# Run tests
pytestmaturin build --release
maturin publishApache-2.0